resid <- y - with(s,(u[, 1, drop=FALSE]*d[1]) %*% t(v[, 1, drop=FALSE]))
my_image(cor(resid[index,]), zlim = c(-1,1))
title("Residual Y - PC1")
Warning message in cor(resid[index, ]): “the standard deviation is zero”
Now we calculate the second matrix factorization and its residual:
$Y \approx d_{1,1}U_{1}V_{1}^{T} + d_{2,2}U_{2}V_{2}^{T}$
matrix <- (s$u[index,2, drop=FALSE]*s$d[2]) %*% t(s$v[,2, drop=FALSE])
my_image(matrix)
title("PC2")