View source: R/buildRandomImage4PCA.R
buildRandomImage4PCA | R Documentation |
buildRandomImage4PCA
:
Makes a random image (with similar PCA loadings) of a
matrix of integer data such as Likert scales data.
buildRandomImage4PCA(X, nObs = NROW(X), center = TRUE, scale = FALSE)
X |
The original data |
nObs |
how many observations for the random data
(Default: |
center |
if |
scale |
if |
The procedure starts with a PCA of the original matrix
X
and gets loadings and factor scores.
From the eigenvalues,
buildRandomImage4PCA
generates random observations in
the factor score space. These observations are then used
to recreate (via the reconstitution formula)
a new matrix X.rand
that will store the observations
that will recreate the random factor scores. The
observations in X.rand
are then re-scaled
to match the distribution of the integers in the original matrix.
Doing so gives a matrix of scores with the same basic statistics
(i.e., mean and standard deviation) per column whose PCA will give
roughly the same loadings
(but not the same factor scores, of course)
as the original matrix.
A matrix of (somewhat) random integers with
nObs
observations whose
factorial structure roughly matches the original matrix.
Hervé Abdi
epPCA
library(ExPosition)
data("twentyWines")
test4build <- buildRandomImage4PCA(twentyWines$df.active)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.