powered by
Wrapper function for creating PCA scores to be used in a regression analysis.
createPCAmodelmatrix( data, ncomps, covarnames = colnames(data), center = TRUE, scale = TRUE, matrixonly = TRUE )
Matrix or data frame of data
Number of PCA components to return.
Names of variables or column numbers in data on which the PCA is to be run.
data
Logical indicator of whether data should be centered. Passed to prcomp.
prcomp
Logical indicator of whether data should be scaled. Passed to prcomp.
Logical indicator of whether only the model matrix should be returned, or the full output from prcomp.
If matrixonly=TRUE, a matrix of PCA scores. Otherwise a list containing two elements: X, a matrix of scores, and pca, the output from prcomp.
matrixonly=TRUE
X
pca
This is a wrapper around prcomp, which does the necessary computation.
createTPRSmodelmatrix, predkmeansCVest
createTPRSmodelmatrix
predkmeansCVest
# NOT RUN { n <- 100 d <- 15 X <- matrix(rnorm(n*d), ncol=d, nrow=n) X <- as.data.frame(X) mx <- createPCAmodelmatrix(data=X, ncomps=2) # }
Run the code above in your browser using DataLab