Search

Calculate C index (MCT, MUT) with R

#test #http://www.uni-konstanz.de/ag-moral/mut/MCT-C-example_015.pdf ex015=c(-2,-1,1,2,4,4,-4,-4,-4,-4,-3,-3,-1,-1,2,3,4,4,-4,-4,-4,-4,-4,-3) mat1=matrix(ex015,ncol=4) SStot=sum(ex015^2) SSmean=(sum(ex015))^2/24 SSdev=SStot-SSmean SSstage=sum(rowSums(mat1)^2/4) SStype=SSstage-SSmean cindex=SStype/SSdev*100 #write function # dataCS includes raw data, see example www.aydinburak.net/presents ctotal=c() for (i in 1:nrow(dataCS)){ subjdata=as.numeric(dataCS[i,]) mat1=matrix(subjdata,ncol=4) SStot=sum(subjdata^2) SSmean=(sum(subjdata))^2/24 SSdev=SStot-SSmean SSstage=sum(rowSums(mat1)^2/4) SStype=SSstage-SSmean cindex=round(SStype/SSdev*100,3) ctotal[i]=cindex

© 2015-20 by Burak AYDIN