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 bymspca().- C
(optional) A numeric matrix (p x p). The covariance or correlation matrix used when fitting. Not required:
mspca()stores the per-PC variance figures and the variable names on the fitted object, for both input types. SupplyingCrecomputes the variance figures from it and takes the row labels from its dimnames.- digits
An integer or
NULL. Number of significant digits for display. WhenNULL(the default),getOption("digits")is used, so the output respectsoptions(digits = ...).- ...
Further arguments required by the
print()generic; not used by this method.
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)
#>
#> msPCA solution: 2 sparse PCs
#> Pct. variance explained: 32.19810 27.98031
#> Non-zero loadings per PC: 4 4
#>
#> Sparse PCs
#> [,1] [,2]
#> mpg 0.5231892 0.0000000
#> cyl -0.4135157 0.0000000
#> disp -0.5327976 0.0000000
#> hp 0.0000000 -0.5180501
#> wt -0.5209650 0.0000000
#> qsec 0.0000000 0.5056638
#> vs 0.0000000 0.4935986
#> carb 0.0000000 -0.4819634