buildRandomImage4PCA: Make a random image (with similar PCA loadings) of a matrix...

View source: R/buildRandomImage4PCA.R

buildRandomImage4PCAR Documentation

Make a random image (with similar PCA loadings) of a matrix of integers data.

Description

buildRandomImage4PCA: Makes a random image (with similar PCA loadings) of a matrix of integer data such as Likert scales data.

Usage

buildRandomImage4PCA(X, nObs = NROW(X), center = TRUE, scale = FALSE)

Arguments

X

The original data

nObs

how many observations for the random data (Default: NROW(X).

center

if TRUE (Default) perform a centered PCA of X.

scale

if FALSE (Default) do not scale the data for the PCA of X. Other options are TRUE (use Z-scores), 'SS1', normalize each variable to length 1.

Details

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.

Value

A matrix of (somewhat) random integers with nObs observations whose factorial structure roughly matches the original matrix.

Author(s)

Hervé Abdi

See Also

epPCA

Examples

library(ExPosition)
data("twentyWines")
test4build <- buildRandomImage4PCA(twentyWines$df.active)

HerveAbdi/data4PCCAR documentation built on Sept. 11, 2022, 4:19 p.m.