data(BadRLG)
out<-smoothLG(R = BadRLG, Penalty = 50000)
cat("\nGradient at solution:", out$gr,"\n")
cat("\nNearest Correlation Matrix\n")
print( round(out$RLG,8) )
################################
## Rousseeuw Molenbergh example
data(BadRRM)
out <- smoothLG(R = BadRRM, PD=TRUE)
cat("\nGradient at solution:", out$gr,"\n")
cat("\nNearest Correlation Matrix\n")
print( round(out$RLG,8) )
## Weights for the weighted solution
W <- matrix(c(1, 1, .5,
1, 1, 1,
.5, 1, 1), nrow = 3, ncol = 3)
tmp <- smoothLG(R = BadRRM, PD = TRUE, eps=.001)
cat("\nGradient at solution:", out$gr,"\n")
cat("\nNearest Correlation Matrix\n")
print( round(out$RLG,8) )
print( eigen(out$RLG)$val )
## Rousseeuw Molenbergh
## non symmetric matrix
T <- matrix(c(.8, -.9, -.9,
-1.2, 1.1, .3,
-.8, .4, .9), nrow = 3, ncol = 3,byrow=TRUE)
out <- smoothLG(R = T, PD = FALSE, eps=.001)
cat("\nGradient at solution:", out$gr,"\n")
cat("\nNearest Correlation Matrix\n")
print( round(out$RLG,8) )
Run the code above in your browser using DataLab