Finds principal components of a weitrix. If varimax rotation is enabled, these are then rotated to enhance interpretability.
weitrix_components( weitrix, p = 0, design = ~1, n_restarts = 3, max_iter = 1000, tol = 1e-05, use_varimax = TRUE, initial = NULL, verbose = TRUE ) weitrix_components_seq( weitrix, p, design = ~1, n_restarts = 3, max_iter = 1000, tol = 1e-05, use_varimax = TRUE, verbose = TRUE )
A weitrix object, or an object that can be converted to a weitrix
Number of components to find.
A formula referring to
Number of restarts of the iteration to use.
Stop iterating if R-squared increased by less than this amount in an iteration.
Use varimax rotation to enhance interpretability of components.
Optional, an initial guess for column components (scores).
Can have fewer columns than
Show messages about the progress of the iterations.
A "Components" object with the following elements accessible using
row Row matrix, aka loadings. Rows are rows in the weitrix, and columns contain the experimental design (usually just an intercept term), and components.
col Column matrix, aka scores. Rows are columns in the weitrix, and columns contain fitted coefficients for the experimental design, and components.
R2 Weighted R squared statistic. The proportion of total variance explained by the components.
all_R2s R2 statistics from all restarts. This can be used to check how consistently the iteration finds optimal components.
ind_designColumn indices associated with experimental design.
ind_componentsColumn indices associated with components.
For a result
the original measurements are approximated
comp$row %*% t(comp$col).
weitrix_components_seq returns a list of Components objects,
with increasing numbers of components from 1 up to p.
Note that this is a slow numerical method to solve a gnarly problem, for the case where weights are not uniform. The case of uniform weights or weights that can be written as an outer product of row and column weights is somewhat faster, however there are much faster algorithms for this available elsewhere.
An iterative method is used,
starting from a random initial set of components.
It is possible for this to get stuck at a local minimum.
To ameliorate this, the iteration is initially run
and the best result used.
This is then iterated further.
all_R2s in the output to see if this is happening --
if the values are not all nearly identital,
the iteration is sometimes getting stuck at local minima.
increase the odds of finding the global minimum.
weitrix_components: Find a matrix decomposition with the specified number of components.
weitrix_components_seq: Produce a sequence of weitrix decompositions with 1 to p components.