lab:r_codes_to_process_the_results_from_mplus_for_table_3
## handle the model comparison results from mplus v500<-scan('all_results500v.txt') v500m<-matrix(v500, nrow=1500, byrow=T) inv500<-scan('all_results500inv.txt') inv500m<-matrix(inv500, nrow=1497, byrow=T) v500f<-v500m[c(1:523, 525:1034, 1036:1279, 1281:1500), c(40:42, 169)] inv500f<-inv500m[, c(40:42, 163)] mean(v500f[,4]) var(v500f[,4]) ks.test(v500f[,4],'pchisq',23) mean(inv500f[,4]) var(inv500f[,4]) ks.test(inv500f[,4],'pchisq',27) chi.diff<-inv500f[,4]-v500f[,4] mean(chi.diff) var(chi.diff) ks.test(chi.diff, 'pchisq', 3) ## for the sample size 100 ## function to delete an element delOne<-function(x, a){ nn<-NULL for (i in 1:length(a)){ nn<-c(nn, which(x==a[i])) } x<-x[-nn] x } ind<-scan("ind.txt") inv<-scan("all_results100inv.txt") invm<-matrix(inv, ncol=179, byrow=T) err.inv<-scan("error-100-inv.log") ind.inv<-delOne(ind,err.inv) chi.inv<-cbind(ind.inv,invm[,163]) v<-scan("all_results100v.txt") vm<-matrix(v, ncol=185, byrow=T) err.v<-scan("error-100-v.log") ind.v<-delOne(ind,err.v) chi.v<-cbind(ind.v, vm[,169]) ## create two NA matrix chi.inv.temp<-array(NA, dim=c(1500,2)) chi.v.temp<-array(NA, dim=c(1500,2)) i<-1 for (i in 1:1500){ temp<-chi.inv[chi.inv[,1]==i ,] if (length(temp)!=0){ chi.inv.temp[i,]<-temp } temp<-chi.v[chi.v[,1]==i ,] if (length(temp)!=0){ chi.v.temp[i,]<-temp } } chi.all<-cbind(chi.inv.temp[,2], chi.v.temp[,2], chi.inv.temp[,2]-chi.v.temp[,2]) chi.all<-chi.all[chi.all[,3]>0, ] apply(chi.all, 2, mean, na.rm=T) apply(chi.all, 2, var, na.rm=T) ks.test(chi.all[,1],'pchisq',27) ks.test(chi.all[,2],'pchisq',24) ks.test(chi.all[,3],'pchisq',3)
lab/r_codes_to_process_the_results_from_mplus_for_table_3.txt · Last modified: 2016/01/24 09:48 by 127.0.0.1