Description Usage Arguments Value Examples
A function that generates a realistic dataset based on a sparse PCA model X = XWP^T, with a sparse W and with W = P and W^T W = I
1 | makeDat(n, comdis, variances)
|
n |
The number of objects the data should have |
comdis |
A |
variances |
specifying the variances of the J components these are the J eigenvalues of X^T X |
ncomp |
The number of components that are of interest |
A list with the following items:
X
A data matrix generated from MASS::mvrnorm() with a zero mean structure and Sigma = P %*% diag(variances) %*% t(P), empirical is set FALSE
P
A matrix of dimension J x J, with the loadings/weights the first Q columns have the sparsity structure specified in comdis
, the other Q-J columns are non-sparse.
Sigma
The covariance matrix that is used to generate the data from Sigma = P %*% diag(variances) %*% t(P)
In case of failure the function returns NA
. The function can fail if the comdis
structure specified in P is not possible, i.e. linear dependency
1 2 3 4 5 6 7 | ncomp <- 3
J <- 30
comdis <- matrix(1, J, ncomp)
comdis <- sparsify(comdis, 0.7) #set 70% of the 1's to zero
variances <- makeVariance(varianceOfComps = c(100, 80, 70), J = J, error = 0.05) #create realistic eigenvalues
dat <- makeDat(n = 100, comdis = comdis, variances = variances)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.