Calculate C index (MCT, MUT) with R

December 30, 2016

 

 

 

 

 

 

 

 

 

 

 

 

#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
}
dataCS$ctotal=ctotal
 

    

Please reload

Featured Posts

Automated ANOVA, Pseudo instrument analyses

January 1, 2016

1/4
Please reload

Recent Posts

November 15, 2017

November 5, 2017

September 25, 2017

Please reload

Archive