[R] Panel data and imputed datasets
Nathan Paxton
napaxton at fas.harvard.edu
Tue Aug 14 23:50:24 CEST 2007
Hi all,
I am hardly an expert, so I expect that this code is not the easiest/
most efficient way of getting where I want. Any suggestions in that
direction would also be helpful.
I am working on panel analysis with five imputed datasets, generated
by Amelia. To do panel analysis, it seemed that the plm package was
the best, providing a convenient wrapper for fixed and random effects
and Hausman tests. And since I've got five datasets, it seemed
reasonable that what I wanted to do was to combine these as a big
imputation data frame. The plm regression function requires a data
argument, and simply using the imputationList result didn't work, nor
did calling the names(allhiv) work (that resulted in "imputations"
and "call").
Where do I point the plm command to look for the data? Or have I
gone about this in entirely the wrong way?
Thanks in advance for the help.
Best,
-N
Here's the code I have so far:
#Read in the imputed datasets
data1 <- read.dta("outdata1.dta")
data2 <- read.dta("outdata2.dta")
data3 <- read.dta("outdata3.dta")
data4 <- read.dta("outdata4.dta")
data5 <- read.dta("outdata5.dta")
#Set the datasets as panels (for subsequent analysis in plm)
pdata.frame(data1, "country", time="year")
pdata.frame(data2, "country", time="year")
pdata.frame(data3, "country", time="year")
pdata.frame(data4, "country", time="year")
pdata.frame(data5, "country", time="year")
#Using mitools, combine the panel data frames 1-5
allhiv <- imputationList(list(data1,data2,data3,data4,data5))
#A test regression
form2<-APIPolSupport~subnatexpoftotal+adultprev.lag+pressfreedom
#The following is something I tried but which didn't work.
estimateHIV1 <-with(allhiv, plm(form2, data=imputations[1:5,]))
----------
Nathan A. Paxton
Ph.D. Candidate
Dept. of Government, Harvard University
Resident Tutor
John Winthrop House, Harvard University
napaxton AT fas DOT harvard DOT edu
http://www.fas.harvard.edu/~napaxton
========================================================================
===============================
When you have to stay eight years away from California, you live in a
perpetual state of homesickness.
- Ronald Reagan
The most courageous act is still to think for yourself. Aloud.
-Coco Chanel
More information about the R-help
mailing list