Skip to contents

S3 print method for objects of class "mspca" returned by mspca(). Displays the sparse loading matrix (restricted to the union of non-zero rows) together with the percentage of variance explained and the number of non-zero loadings per component.

Usage

# S3 method for class 'mspca'
print(x, C = NULL, digits = NULL, ...)

Arguments

x

An object of class "mspca", as returned by mspca().

C

(optional) A numeric matrix (p x p). The covariance or correlation matrix used when fitting. May be omitted for type = "X" results.

digits

An integer or NULL. Number of significant digits for display. When NULL (the default), getOption("digits") is used, so the output respects options(digits = ...).

...

Further arguments required by the print() generic; not used by this method.

Value

Invisibly returns x.

Details

When the model was fit from a covariance/correlation matrix (type = "Sigma"), pass that matrix as C so that per-PC variance figures can be computed; when it was fit from a raw data matrix (type = "X"), C may be omitted because the figures are stored inside the object.

Examples

TestMat <- cor(mtcars)
res <- mspca(TestMat, r = 2, ks = c(4, 4), verbose = FALSE)
print(res, TestMat)
#> 
#> msPCA solution: 2 sparse PCs
#> Pct. variance explained: 32.45835 27.98031 
#> Non-zero loadings per PC: 4 4 
#> 
#> Sparse PCs
#>            [,1]       [,2]
#> mpg  -0.4994877  0.0000000
#> cyl   0.4952709  0.0000000
#> disp  0.5096594  0.0000000
#> hp    0.0000000 -0.5180516
#> wt    0.4954454  0.0000000
#> qsec  0.0000000  0.5056626
#> vs    0.0000000  0.4935996
#> carb  0.0000000 -0.4819620