rmse | R Documentation |
Program rmse
calculates the RMSE for a matrix approximation.
rmse(R, Rhat, W = matrix(1, nrow(R), ncol(R)) - diag(nrow(R)),
verbose = FALSE, per.variable = FALSE)
R |
The original matrix |
Rhat |
The approximating matrix |
W |
A symmetric matrix of weights |
verbose |
Print output ( |
per.variable |
Calculate the RMSE for the whole matrix ( |
By default, function rmse
assumes a symmetric correlation matrix as input, together with its approximation. The approximation does not need to be symmetric.
Weight matrix W has to be symmetric. By default, the diagonal is excluded from RMSE calcuations (W = J - I). To include it, specify W = J, that is set W = matrix(1, nrow(R), ncol(R))
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. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/00031305.2023.2186952")}
data(banknotes)
X <- as.matrix(banknotes[,1:6])
p <- ncol(X)
J <- matrix(1,p,p)
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,W=J)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.