## Process results from Mplus

proc.res<-function(pat, r){
  filename<-paste(pat,'-',r,'.txt', sep='')
  res<-read.table(filename)
  res<-res[!is.na(res[,8]),]
      iL<-dim(res)[1]
      est<-mean(res[,6])
      bias<-(est-.1521)/.1521

      cvg<-sum( res[,5]<.1521 & res[,7]>.1521 )/iL
      power<-sum(res[,5]>0 | res[,7]<0)/iL
      cat(c(est,bias, cvg,power, iL), "\n")  

  }

mis.pat<-c('mcar0','mcar1','mcar2','mar0','mar1','mar2','mnar0','mnar1','mnar2','mnar0-1','mnar1-1','mnar2-1')

rate1<-c(1.5, 4, 9)
rate2<-c(.1,.2,.4)

for (pat in mis.pat){

  if (substr(pat,1,3)=="mar"){
    rate <- rate1
  }else{
    rate <- rate2
  }

  for (r in rate){
     cat(pat,' ', r, ' \n')
     proc.res(pat, r)
  }
}