Title: | Exploratory Principal Component Analysis |
---|---|
Description: | Exploratory principal component analysis for large-scale dataset, including sparse principal component analysis and sparse matrix approximation. |
Authors: | Fan Chen [aut, cre] |
Maintainer: | Fan Chen <[email protected]> |
License: | GPL-3 |
Version: | 1.1.0 |
Built: | 2024-11-13 05:45:24 UTC |
Source: | https://github.com/fchen365/epca |
epca
is for comprehending any data matrix that contains low-rank and sparse underlying signals of interest.
The package currently features two key tools: (1) sca
for sparse principal component analysis and
(2) sma
for sparse matrix approximation, a two-way data analysis for simultaneously row and column dimensionality reductions.
Chen, F. and Rohe K. (2020) "A New Basis for Sparse PCA".
Given a p x k matrix x
,
finds the orthogonal matrix (rotation) that minimizes the absmin.criteria.
absmin(x, r0 = diag(ncol(x)), normalize = FALSE, eps = 1e-05, maxit = 1000L)
absmin(x, r0 = diag(ncol(x)), normalize = FALSE, eps = 1e-05, maxit = 1000L)
x |
a |
r0 |
|
normalize |
logical. Should Kaiser normalization be performed?
If so the rows of |
eps |
The tolerance for stopping: the relative change in the sum of singular values. |
maxit |
|
A list with three elements:
rotated |
the rotated matrix. |
rotmat |
the (orthogonal) rotation matrix. |
n.iter |
the number of iteration taken. |
GPArotation::GPForth
Calculate the absmin criteria. This is a helper function for absmin.
absmin.criteria(x)
absmin.criteria(x)
x |
a |
Calculate the CPVE.
cpve(x, v, is.cov = FALSE)
cpve(x, v, is.cov = FALSE)
x |
|
v |
|
is.cov |
|
a numeric
vector of length ncol(v)
, the i-th value is the CPVE of the first i columns in v
.
## use the "swiss" data ## find two sparse PCs s.sca <- sca(swiss, 2, gamma = sqrt(ncol(swiss))) ld <- loadings(s.sca) cpve(as.matrix(swiss), ld)
## use the "swiss" data ## find two sparse PCs s.sca <- sca(swiss, 2, gamma = sqrt(ncol(swiss))) ld <- loadings(s.sca) cpve(as.matrix(swiss), ld)
Compute the distance between two matrices.
The distance between two matrices is defined as the sum of distances between column pairs.
This function matches the columns of two matrices, such that the matrix distance
(i.e., the sum of paired column distances) is minimized.
This is accomplished by solving an optimization over column permutation.
Given two matrices, x
and y
, find permutation p() that minimizes
sum_i similarity(x[,p(i)], y[,i]
),
where the similarity()
can be "euclidean" distance, 1 - "cosine", or "maximum" difference (manhattan distance).
The solution is computed by clue::solve_LSAP()
.
dist.matrix(x, y, method = "euclidean")
dist.matrix(x, y, method = "euclidean")
x , y
|
|
method |
distance measure, "maximum", "cosine", or "euclidean" are implemented. |
a list
of four components:
dist |
|
match |
|
value |
|
method |
|
nrow |
|
x <- diag(4) y <- x + rnorm(16, sd = 0.05) # add some noise y = t(t(y) / sqrt(colSums(y ^ 2))) ## normalize the columns ## euclidian distance between column pairs, with minimal matches dist.matrix(x, y, "euclidean")
x <- diag(4) y <- x + rnorm(16, sd = 0.05) # add some noise y = t(t(y) / sqrt(colSums(y ^ 2))) ## normalize the columns ## euclidian distance between column pairs, with minimal matches dist.matrix(x, y, "euclidean")
Matrix Distance
distance(x, y, method = "euclidean")
distance(x, y, method = "euclidean")
x , y
|
|
method |
distance measure, "maximum", "cosine", or "euclidean" are implemented. |
numeric
, the distance between two matrices.
Calculate fractional exponent/power, a^(num/den)
, where a could be negative.
## S3 method for class 'frac' exp(a, num, den)
## S3 method for class 'frac' exp(a, num, den)
a |
|
num |
a positive |
den |
a positive |
numeric
, the evaluated a^(num/den)
Perform hard-thresholding given the cut-off value.
hard(x, t)
hard(x, t)
x |
any numerical |
t |
|
Calculate the custom matrix inner product z
of two matrices, x
and y
,
where z[i,j] = FUN(x[,i], y[,j])
.
inner(x, y, FUN = "crossprod", ...)
inner(x, y, FUN = "crossprod", ...)
x , y
|
|
FUN |
|
... |
additional parameters for |
matrix
, inner product of x
and y
.
x <- matrix(1:6, 2, 3) y <- matrix(7:12, 2, 3) ## The default is equivalent to `crossprod(x, y)` inner(x, y) ## We can compute the pair-wise Euclidean distance of columns. EuclideanDistance = function(x, y) crossprod(x, y)^2 inner(x, y, EuclideanDistance)
x <- matrix(1:6, 2, 3) y <- matrix(7:12, 2, 3) ## The default is equivalent to `crossprod(x, y)` inner(x, y) ## We can compute the pair-wise Euclidean distance of columns. EuclideanDistance = function(x, y) crossprod(x, y)^2 inner(x, y, EuclideanDistance)
Assign cluster labels to each row from the membership matrix.
labelCluster(x, ties.method = "random")
labelCluster(x, ties.method = "random")
x |
|
ties.method |
|
integer
vector of the same length as x
. Each entry is one of 1, 2, ..., ncol(x)
.
Compute the empirical MCR, assuming that #cluster = #block, This calculation allows a permutation on clusters.
misClustRate(cluster, truth)
misClustRate(cluster, truth)
cluster |
vector of |
truth |
a vector of the same length as |
numeric
, the MCR.
truth = rep(1:3, each = 30) cluster = rep(3:1, times = c(25, 32, 33)) misClustRate(cluster, truth)
truth = rep(1:3, each = 30) cluster = rep(3:1, times = c(25, 32, 33)) misClustRate(cluster, truth)
Compute element-wise matrix Lp-norm.
This is a helper function to shrinkage()
.
norm.Lp(x, p = 1)
norm.Lp(x, p = 1)
x |
a |
p |
|
numeric(1)
, the absolute sum of all elements.
Perform column permutation of block membership matrix for aesthetic visualization. That is, the k-th column gives k-th cluster. This is done by ranking the column sums of squares (by default).
permColumn(x, s = 2)
permColumn(x, s = 2)
x |
a non-negative matrix, nNode x nBlock, |
s |
integer, order of non-linear |
The pitprops
data is a correlation matrix that was calculated from 180 observations.
There are 13 explanatory variables.
Jeffers (1967) tried to interpret the first six PCs.
This is a classical example showing the difficulty of interpreting principal components.
Jeffers, J. (1967) "Two case studies in the application of principal component", Applied Statistics, 16, 225-236.
## NOT TEST data(pitprops) ggcorrplot::ggcorrplot(pitprops)
## NOT TEST data(pitprops) ggcorrplot::ggcorrplot(pitprops)
Perform the polar decomposition of an n x p (n > p) matrix x
into two parts: u
and h
,
where u
is an n x p unitary matrix with orthogonal columns (i.e. crossprod(u)
is the identity matrix),
and h
is a p x p positive-semidefinite Hermitian matrix.
The function returns the u
matrix.
This is a helper function of prs()
.
polar(x)
polar(x)
x |
a |
a matrix
of the unitary part of the polar decomposition.
Chen, F. and Rohe, K. (2020) "A New Basis for Sparse Principal Component Analysis."
x <- matrix(1:6, nrow = 3) polar_x <- polar(x)
x <- matrix(1:6, nrow = 3) polar_x <- polar(x)
Print SCA
## S3 method for class 'sca' print(x, verbose = FALSE, ...)
## S3 method for class 'sca' print(x, verbose = FALSE, ...)
x |
an |
verbose |
|
... |
additional input to generic print. |
Print an sca
object interactively.
Print SMA
## S3 method for class 'sma' print(x, verbose = FALSE, ...)
## S3 method for class 'sma' print(x, verbose = FALSE, ...)
x |
an |
verbose |
|
... |
additional input to generic print. |
Print an sma
object interactively.
This function is a helper function of sma()
.
It performs polar docomposition, orthogonal rotation, and soft-thresholding shrinkage in order.
The three steps together enable sparse estimates of the SMA and SCA.
prs(x, z.hat, gamma, rotate, shrink, normalize, order, flip, epsilon)
prs(x, z.hat, gamma, rotate, shrink, normalize, order, flip, epsilon)
x , z.hat
|
the matrix product |
gamma |
|
rotate |
|
shrink |
|
normalize |
|
order |
|
flip |
|
epsilon |
|
rotate
: The rotate
option specifies the rotation technique to
use. Currently, there are two build-in options—“varimax” and “absmin”.
The “varimax” rotation maximizes the element-wise L4 norm of the rotated
matrix. It is faster and computationally more stable. The “absmin”
rotation minimizes the absolute sum of the rotated matrix. It is sharper
(as it directly minimizes the L1 norm) but slower and computationally
less stable.
shrink
: The shrink
option specifies the shrinkage operator to
use. Currently, there are two build-in options—“soft”- and
“hard”-thresholding. The “soft”-thresholding universally reduce all
elements and sets the small elements to zeros. The “hard”-thresholding
only sets the small elements to zeros.
normalize
: The argument normalize
gives an indication of if and
how any normalization should be done before rotation, and then undone
after rotation. If normalize is FALSE
(the default) no normalization
is done. If normalize is TRUE
then Kaiser normalization is done. (So
squared row entries of normalized x
sum to 1.0. This is sometimes
called Horst normalization.) For rotate="absmin"
, if normalize
is a
vector of length equal to the number of indicators (i.e., the number of
rows of x
), then the columns are divided by normalize
before
rotation and multiplied by normalize
after rotation. Also, If
normalize
is a function then it should take x
as an argument and
return a vector which is used like the vector above.
order
: In PCA (and SVD), the principal components (and the
singular vectors) are ordered. For this, we order the sparse components
(i.e., the columns of z
or y
) by their explained variance in the
data, which is defined as sum((x %*% y)^2)
, where y is a column of the
sparse component. Note: not to be confused with the cumulative
proportion of variance explained by y
(and z
), particularly when y
(and z
) is may not be strictly orthogonal.
flip
: The argument flip
gives an indication of if and the
columns of estimated sparse component should be flipped. Note that the
estimated (sparse) loadings, i.e., the weights on original variables,
are column-wise invariant to a sign flipping. This is because flipping
of a principal direction does not influence the amount of the explained
variance by the component. If flip=TRUE
, then the columns of loadings
will be flip accordingly, such that each column is positive-skewed. This
means that for each column, the sum of cubic elements (i.e., sum(x^3)
)
are non-negative.
a matrix
of the sparse estimate, of the same dimension as crossprod(x, z.hat)
.
Chen, F. and Rohe, K. (2020) "A New Basis for Sparse Principal Component Analysis."
sma, sca, polar, rotation, shrinkage
Calculate the Proportion of variance explained by a set of linear transformation, (e.g. eigenvectors).
pve(x, v, is.cov = FALSE)
pve(x, v, is.cov = FALSE)
x |
|
v |
|
is.cov |
|
a numeric
value between 0 and 1, the proportion of total variance in x
explained by the PCs whose loadings are in v
.
Shen, H., & Huang, J. Z. (2008). "Sparse principal component analysis via regularized low rank matrix approximation." Journal of multivariate analysis, 99(6), 1015-1034.
## use the "swiss" data ## find two sparse PCs s.sca <- sca(swiss, 2, gamma = sqrt(ncol(swiss))) ld <- loadings(s.sca) pve(as.matrix(swiss), ld)
## use the "swiss" data ## find two sparse PCs s.sca <- sca(swiss, 2, gamma = sqrt(ncol(swiss))) ld <- loadings(s.sca) pve(as.matrix(swiss), ld)
Find the root matrix (x
) from the Gram matrix (i.e., crossprod(x)
).
This is also useful when the input is a covariance matrix, up to a scaling factor of n-1, where n is the sample size.
rootmatrix(x)
rootmatrix(x)
x |
a symmetric |
Perform varimax rotation. Flip the signs of columns so that the resulting matrix is positive-skewed.
rotation( x, rotate = c("varimax", "absmin"), normalize = FALSE, flip = TRUE, eps = 1e-06 )
rotation( x, rotate = c("varimax", "absmin"), normalize = FALSE, flip = TRUE, eps = 1e-06 )
x |
a |
rotate |
|
normalize |
|
flip |
|
eps |
|
rotate
: The rotate
option specifies the rotation technique to
use. Currently, there are two build-in options—“varimax” and “absmin”.
The “varimax” rotation maximizes the element-wise L4 norm of the rotated
matrix. It is faster and computationally more stable. The “absmin”
rotation minimizes the absolute sum of the rotated matrix. It is sharper
(as it directly minimizes the L1 norm) but slower and computationally
less stable.
normalize
: The argument normalize
gives an indication of if and
how any normalization should be done before rotation, and then undone
after rotation. If normalize is FALSE
(the default) no normalization
is done. If normalize is TRUE
then Kaiser normalization is done. (So
squared row entries of normalized x
sum to 1.0. This is sometimes
called Horst normalization.) For rotate="absmin"
, if normalize
is a
vector of length equal to the number of indicators (i.e., the number of
rows of x
), then the columns are divided by normalize
before
rotation and multiplied by normalize
after rotation. Also, If
normalize
is a function then it should take x
as an argument and
return a vector which is used like the vector above.
flip
: The argument flip
gives an indication of if and the
columns of estimated sparse component should be flipped. Note that the
estimated (sparse) loadings, i.e., the weights on original variables,
are column-wise invariant to a sign flipping. This is because flipping
of a principal direction does not influence the amount of the explained
variance by the component. If flip=TRUE
, then the columns of loadings
will be flip accordingly, such that each column is positive-skewed. This
means that for each column, the sum of cubic elements (i.e., sum(x^3)
)
are non-negative.
the rotated matrix of the same dimension as x
.
Chen, F. and Rohe, K. (2020) "A New Basis for Sparse Principal Component Analysis."
## use the "swiss" data fa <- factanal( ~., 2, data = swiss, rotation = "none") rotation(loadings(fa))
## use the "swiss" data fa <- factanal( ~., 2, data = swiss, rotation = "none") rotation(loadings(fa))
sca
performs sparse principal components analysis on the given numeric data matrix.
Choices of rotation techniques and shrinkage operators are available.
sca( x, k = min(5, dim(x)), gamma = NULL, is.cov = FALSE, rotate = c("varimax", "absmin"), shrink = c("soft", "hard"), center = TRUE, scale = FALSE, normalize = FALSE, order = TRUE, flip = TRUE, max.iter = 1000, epsilon = 1e-05, quiet = TRUE )
sca( x, k = min(5, dim(x)), gamma = NULL, is.cov = FALSE, rotate = c("varimax", "absmin"), shrink = c("soft", "hard"), center = TRUE, scale = FALSE, normalize = FALSE, order = TRUE, flip = TRUE, max.iter = 1000, epsilon = 1e-05, quiet = TRUE )
x |
|
k |
|
gamma |
|
is.cov |
|
rotate |
|
shrink |
|
center |
|
scale |
|
normalize |
|
order |
|
flip |
|
max.iter |
|
epsilon |
|
quiet |
|
rotate
: The rotate
option specifies the rotation technique to
use. Currently, there are two build-in options—“varimax” and “absmin”.
The “varimax” rotation maximizes the element-wise L4 norm of the rotated
matrix. It is faster and computationally more stable. The “absmin”
rotation minimizes the absolute sum of the rotated matrix. It is sharper
(as it directly minimizes the L1 norm) but slower and computationally
less stable.
shrink
: The shrink
option specifies the shrinkage operator to
use. Currently, there are two build-in options—“soft”- and
“hard”-thresholding. The “soft”-thresholding universally reduce all
elements and sets the small elements to zeros. The “hard”-thresholding
only sets the small elements to zeros.
normalize
: The argument normalize
gives an indication of if and
how any normalization should be done before rotation, and then undone
after rotation. If normalize is FALSE
(the default) no normalization
is done. If normalize is TRUE
then Kaiser normalization is done. (So
squared row entries of normalized x
sum to 1.0. This is sometimes
called Horst normalization.) For rotate="absmin"
, if normalize
is a
vector of length equal to the number of indicators (i.e., the number of
rows of x
), then the columns are divided by normalize
before
rotation and multiplied by normalize
after rotation. Also, If
normalize
is a function then it should take x
as an argument and
return a vector which is used like the vector above.
order
: In PCA (and SVD), the principal components (and the
singular vectors) are ordered. For this, we order the sparse components
(i.e., the columns of z
or y
) by their explained variance in the
data, which is defined as sum((x %*% y)^2)
, where y is a column of the
sparse component. Note: not to be confused with the cumulative
proportion of variance explained by y
(and z
), particularly when y
(and z
) is may not be strictly orthogonal.
flip
: The argument flip
gives an indication of if and the
columns of estimated sparse component should be flipped. Note that the
estimated (sparse) loadings, i.e., the weights on original variables,
are column-wise invariant to a sign flipping. This is because flipping
of a principal direction does not influence the amount of the explained
variance by the component. If flip=TRUE
, then the columns of loadings
will be flip accordingly, such that each column is positive-skewed. This
means that for each column, the sum of cubic elements (i.e., sum(x^3)
)
are non-negative.
an sca
object that contains:
loadings |
|
scores |
an n x k |
cpve |
a |
center |
|
scale |
|
n.iter |
|
n.obs |
|
Chen, F. and Rohe, K. (2020) "A New Basis for Sparse Principal Component Analysis."
## ------ example 1 ------ ## simulate a low-rank data matrix with some additive Gaussian noise n <- 300 p <- 50 k <- 5 ## rank z <- shrinkage(polar(matrix(runif(n * k), n, k)), sqrt(n)) b <- diag(5) * 3 y <- shrinkage(polar(matrix(runif(p * k), p, k)), sqrt(p)) e <- matrix(rnorm(n * p, sd = .01), n, p) x <- scale(z %*% b %*% t(y) + e) ## perform sparse PCA s.sca <- sca(x, k) s.sca ## ------ example 2 ------ ## use the `pitprops` data from the `elasticnet` package data(pitprops) ## find 6 sparse PCs s.sca <- sca(pitprops, 6, gamma = 6, is.cov = TRUE) print(s.sca, verbose = TRUE)
## ------ example 1 ------ ## simulate a low-rank data matrix with some additive Gaussian noise n <- 300 p <- 50 k <- 5 ## rank z <- shrinkage(polar(matrix(runif(n * k), n, k)), sqrt(n)) b <- diag(5) * 3 y <- shrinkage(polar(matrix(runif(p * k), p, k)), sqrt(p)) e <- matrix(rnorm(n * p, sd = .01), n, p) x <- scale(z %*% b %*% t(y) + e) ## perform sparse PCA s.sca <- sca(x, k) s.sca ## ------ example 2 ------ ## use the `pitprops` data from the `elasticnet` package data(pitprops) ## find 6 sparse PCs s.sca <- sca(pitprops, 6, gamma = 6, is.cov = TRUE) print(s.sca, verbose = TRUE)
Shrink a matrix using soft-thresholding or hard-thresholding.
shrinkage(x, gamma, shrink = c("soft", "hard"), epsilon = 1e-11)
shrinkage(x, gamma, shrink = c("soft", "hard"), epsilon = 1e-11)
x |
|
gamma |
|
shrink |
|
epsilon |
|
A binary search to find the cut-off value.
shrink
: The shrink
option specifies the shrinkage operator to
use. Currently, there are two build-in options—“soft”- and
“hard”-thresholding. The “soft”-thresholding universally reduce all
elements and sets the small elements to zeros. The “hard”-thresholding
only sets the small elements to zeros.
a list
with two components:
matrix |
matrix, the matrix that results from soft-thresholding |
norm |
numeric, the norm of the matrix after soft-thresholding. This value is close to constraint if using the second option. |
Chen, F. and Rohe, K. (2020) "A New Basis for Sparse Principal Component Analysis."
x <- matrix(1:6, nrow = 3) shrink_x <- shrinkage(x, 1)
x <- matrix(1:6, nrow = 3) shrink_x <- shrinkage(x, 1)
Perform the sparse matrix approximation (SMA) of a data matrix x
as three multiplicative components: z
, b
, and t(y)
,
where z
and y
are sparse, and b
is low-rank but not necessarily diagonal.
sma( x, k = min(5, dim(x)), gamma = NULL, rotate = c("varimax", "absmin"), shrink = c("soft", "hard"), center = FALSE, scale = FALSE, normalize = FALSE, order = FALSE, flip = FALSE, max.iter = 1000, epsilon = 1e-05, quiet = TRUE )
sma( x, k = min(5, dim(x)), gamma = NULL, rotate = c("varimax", "absmin"), shrink = c("soft", "hard"), center = FALSE, scale = FALSE, normalize = FALSE, order = FALSE, flip = FALSE, max.iter = 1000, epsilon = 1e-05, quiet = TRUE )
x |
|
k |
|
gamma |
|
rotate |
|
shrink |
|
center |
|
scale |
|
normalize |
|
order |
|
flip |
|
max.iter |
|
epsilon |
|
quiet |
|
rotate
: The rotate
option specifies the rotation technique to
use. Currently, there are two build-in options—“varimax” and “absmin”.
The “varimax” rotation maximizes the element-wise L4 norm of the rotated
matrix. It is faster and computationally more stable. The “absmin”
rotation minimizes the absolute sum of the rotated matrix. It is sharper
(as it directly minimizes the L1 norm) but slower and computationally
less stable.
shrink
: The shrink
option specifies the shrinkage operator to
use. Currently, there are two build-in options—“soft”- and
“hard”-thresholding. The “soft”-thresholding universally reduce all
elements and sets the small elements to zeros. The “hard”-thresholding
only sets the small elements to zeros.
normalize
: The argument normalize
gives an indication of if and
how any normalization should be done before rotation, and then undone
after rotation. If normalize is FALSE
(the default) no normalization
is done. If normalize is TRUE
then Kaiser normalization is done. (So
squared row entries of normalized x
sum to 1.0. This is sometimes
called Horst normalization.) For rotate="absmin"
, if normalize
is a
vector of length equal to the number of indicators (i.e., the number of
rows of x
), then the columns are divided by normalize
before
rotation and multiplied by normalize
after rotation. Also, If
normalize
is a function then it should take x
as an argument and
return a vector which is used like the vector above.
order
: In PCA (and SVD), the principal components (and the
singular vectors) are ordered. For this, we order the sparse components
(i.e., the columns of z
or y
) by their explained variance in the
data, which is defined as sum((x %*% y)^2)
, where y is a column of the
sparse component. Note: not to be confused with the cumulative
proportion of variance explained by y
(and z
), particularly when y
(and z
) is may not be strictly orthogonal.
flip
: The argument flip
gives an indication of if and the
columns of estimated sparse component should be flipped. Note that the
estimated (sparse) loadings, i.e., the weights on original variables,
are column-wise invariant to a sign flipping. This is because flipping
of a principal direction does not influence the amount of the explained
variance by the component. If flip=TRUE
, then the columns of loadings
will be flip accordingly, such that each column is positive-skewed. This
means that for each column, the sum of cubic elements (i.e., sum(x^3)
)
are non-negative.
an sma
object that contains:
z , b , t(y)
|
the three parts in the SMA.
|
The row names of y
inherit the column names of x
.
score |
the total variance explained by the SMA. This is the optimal objective value obtained. |
n.iter |
|
Chen, F. and Rohe, K. (2020) "A New Basis for Sparse Principal Component Analysis."
## simulate a rank-5 data matrix with some additive Gaussian noise n <- 300 p <- 50 k <- 5 ## rank z <- shrinkage(polar(matrix(runif(n * k), n, k)), sqrt(n)) b <- diag(5) * 3 y <- shrinkage(polar(matrix(runif(p * k), p, k)), sqrt(p)) e <- matrix(rnorm(n * p, sd = .01), n, p) x <- scale(z %*% b %*% t(y) + e) ## perform sparse matrix approximation s.sma <- sma(x, k) s.sma
## simulate a rank-5 data matrix with some additive Gaussian noise n <- 300 p <- 50 k <- 5 ## rank z <- shrinkage(polar(matrix(runif(n * k), n, k)), sqrt(n)) b <- diag(5) * 3 y <- shrinkage(polar(matrix(runif(p * k), p, k)), sqrt(p)) e <- matrix(rnorm(n * p, sd = .01), n, p) x <- scale(z %*% b %*% t(y) + e) ## perform sparse matrix approximation s.sma <- sma(x, k) s.sma
Perform soft-thresholding given the cut-off value.
soft(x, t)
soft(x, t)
x |
any numerical |
t |
|
This is a re-implementation of stats::varimax,
which (1) adds a parameter for the maximum number of iterations,
(2) sets the default normalize
parameter to FALSE
,
(3) outputs the number of iteration taken, and
(4) returns regular matrix
rather than in loadings
class.
varimax(x, normalize = FALSE, eps = 1e-05, maxit = 1000L)
varimax(x, normalize = FALSE, eps = 1e-05, maxit = 1000L)
x |
A loadings matrix, with |
normalize |
logical. Should Kaiser normalization be performed?
If so the rows of |
eps |
The tolerance for stopping: the relative change in the sum of singular values. |
maxit |
|
A list with three elements:
rotated |
the rotated matrix. |
rotmat |
the (orthogonal) rotation matrix. |
n.iter |
the number of iterations taken. |
Calculate the varimax criterion
varimax.criteria(x)
varimax.criteria(x)
x |
a |
a numeric
of evaluated varimax criterion.
## use the "swiss" data fa <- factanal( ~., 2, data = swiss, rotation = "none") lds <- loadings(fa) ## compute varimax criterion: varimax.criteria(lds) ## compute varimax criterion (after the varimax rotation): rlds <- rotation(lds, rotate = "varimax") varimax.criteria(rlds)
## use the "swiss" data fa <- factanal( ~., 2, data = swiss, rotation = "none") lds <- loadings(fa) ## compute varimax criterion: varimax.criteria(lds) ## compute varimax criterion (after the varimax rotation): rlds <- rotation(lds, rotate = "varimax") varimax.criteria(rlds)
This is a helper function for absmin and is not to be used directly by users.
vgQ.absmin(x)
vgQ.absmin(x)
x |
a |
a list required by GPArotation::GPForth
for the absmin rotation.
## Not run: ## NOT RUN ## NOT for users to call. ## End(Not run)
## Not run: ## NOT RUN ## NOT for users to call. ## End(Not run)