Learn R Programming

Correlplot (version 1.1.0)

rmsePCAandWALS: Generate a table of root mean square error (RMSE) statistics for principal component analysis (PCA) and weighted alternating least squares (WALS).

Description

Function rmsePCAandWALS creates table with the RMSE for each variable, for a low-rank approximation to the correlation matrix obtained by PCA or WALS.

Usage

rmsePCAandWALS(R, output, digits = 4, omit.diagonals = c(FALSE,FALSE,TRUE,TRUE))

Value

A matrix with one row per variable and four columns for RMSE statistics.

Arguments

R

The correlation matrix

output

A list object with four approximationst to the correlation matrix

digits

The number of digits used in the output

omit.diagonals

Vector of four logicals for omitting the diagonal of the correlation matrix for RMSE calculations. Defaults to c(FALSE,FALSE,TRUE,TRUE), to include the diagonal for PCA and exclude it for WALS

Author

Jan Graffelman (jan.graffelman@upc.edu)

References

Graffelman, J. and De Leeuw, J. (2023) Improved approximation and visualization of the correlation matrix. The American Statistician pp. 1--20. tools:::Rd_expr_doi("10.1080/00031305.2023.2186952")

See Also

FitRwithPCAandWALS

Examples

Run this code
data(HeartAttack)
X <- HeartAttack[,1:7]
X[,7] <- log(X[,7])
colnames(X)[7] <- "logPR"
R <- cor(X)
if (FALSE) {
out <- FitRwithPCAandWALS(R)
Results <- rmsePCAandWALS(R,out)
}

Run the code above in your browser using DataLab