Missing Data / Multiple Imputation

2 replies [Last post]
klang's picture
Offline
Joined: 08/23/2009

Hi All,
I've been reviewing the documentation, and I cannot find a procedure for reading in or analyzing multiple data sets resulting from the use of multiple imputation. I saw brief mention of FIML, but I generally use MI when I'm addressing missing data in my analyses. For me, a method of analyzing multiple datasets is imperitive in any package I'm going to be using in my day to day work.

Is there anyone out there who may be able to offer some insight? Am I simply missing something in the documentation?

Thanks Much

Steve's picture
Offline
Joined: 07/30/2009
It is true that there are no

It is true that there are no examples of this type of workflow (yet) in the documentation or on the Wiki. Maybe you'll be the one to write the wiki page!

Your problem (reading in multiple files and running the same mxModel on each of them) is where the interface between R and OpenMx is powerful.

R allows you to create loops so that you can do things such as read in files one at a time and run a model on each of them. This is not a full script, but it will give you a flavor of what you might do.

myModel <- mxModel( blah blah blah ) # define a FIML model but don't put any data in it.
 
myParameters <- matrix(NA, 100, 5) # suppose 100 files and you want to save 5 parameters from each run
 
for (i in 1:100) {
    tempFileName <- paste("myFile",i,".dat", sep=0) # Suppose files name myFile1.dat, myFile2.dat, etc.
    tempData <- read.table(tempFileName)  # Options to read.table would need to be set for your case.
    tempResults <- mxRun(mxModel(myModel, mxData(tempData, type="raw")) #run OpenMx on one file
    myParameters[i,] <- mxEval(A, tempResults)[1:5,6] #Suppose the parameters are in rows 1-5 of col 6 of A
}

Now you have a matrix, myParameters, that has just the parameters you wanted after 100 runs of OpenMx.

If you are interested in multiple imputation or other resampling ideas, I would encourage you to take a look at the alternatives for performing these within R rather than doing them externally and importing 100s of files. Look at
http://cran.r-project.org/ under the "packages" link and search for multiple imputation. Libraries such as 'pan', 'kmi', 'mitools', or 'MICE' may include just what you are looking for!

klang's picture
Offline
Joined: 08/23/2009
Hi Steve, Thanks a bunch for

Hi Steve,
Thanks a bunch for the reply. I'll look into the options in R, and maybe I will be able to write you something for the wiki.