Cv<-matrix(c(215, 64, 33, 22,
64, 97, 57, 25,
33, 57,103, 36,
22, 25, 36, 77),ncol=4)
Cv # covariance matrix of a test with 4 subtests
Cr<-cov2cor(Cv) # Correlation matrix of tests
if(require(Rcsdp)) {glb.algebraic(Cv)} # glb of total score
if(require(Rcsdp)) {glb.algebraic(Cr) } # glb of sum of standardized scores
w<-c(1,2,2,1) # glb of weighted total score
# glb.algebraic(diag(w) %*% Cv %*% diag(w))
alphas <- c(0.8,0,0,0) # Internal consistency of first test is known
if(require(Rcsdp)) {glb.algebraic(Cv,LoBounds=alphas*diag(Cv))}
# Fix all diagonal elements to 1 but the first:
if(require(Rcsdp)) {lb<-glb.algebraic(Cr,LoBounds=c(0,1,1,1),UpBounds=c(1,1,1,1))
lb$solution[1] # should be the same as the squared mult. corr.
smc(Cr)[1]
} else {print ('I am sorry, you need to have the package Rcsdp installed to use glb.algebraic') }
Run the code above in your browser using DataLab