rmse | R Documentation |
Program rmse
calculates the RMSE for a matrix approximation.
rmse(R, Rhat, W = matrix(1,nrow=nrow(R),ncol=ncol(R)), omit.diagonal = TRUE, verbose = FALSE, per.variable = FALSE)
R |
The original matrix |
Rhat |
The approximating matrix |
W |
A matrix of weights |
omit.diagonal |
Use all elements ( |
verbose |
Print output ( |
per.variable |
Calculate the RMSE for the whole matrix ( |
By default, function rmse
assumes a symmetric correlation matrix as input, and calculates the RMSE using all
elements below the diagonal of the supplied matrix. If weights are supplied, the RMSE calculation excludes those
observations that have zero weight.
the calculated rmse
Jan Graffelman (jan.graffelman@upc.edu)
Graffelman, J. and De Leeuw, J. (2023) Improved approximation and visualization of the correlation matrix. The American Statistician pp. 1–20. Available online as latest article doi: 10.1080/00031305.2023.2186952
data(banknotes) X <- as.matrix(banknotes[,1:6]) R <- cor(X) out.sd <- eigen(R) V <- out.sd$vectors Dl <- diag(out.sd$values) V2 <- V[,1:2] D2 <- Dl[1:2,1:2] Rhat <- V2%*%D2%*%t(V2) rmse(R,Rhat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.