0

I would like to know how to export the outcome of Multiple Imputation Amelia summary to tex or html by texreg or stargazer. However, both type of packages show the error.

library(Amelia)
library(Zelig)
library(texreg)
library(stargazer)

mi <-amelia(x = d,m = 5)
summary(mi)
lmi <- zelig(y ~ x1+x2,
 data = m, model = "logit")
summary(lmi)
mi2 <-amelia(x = d,m = 5)
summary(mi2)
lmi2 <- zelig(y ~ x1+x2,
 data = m2, model = "logit")
summary(lmi2)

stargazer(lmi,lmi2, title="hogehoge", omit.stat=c("f","ser"), align=T, no.space=T)

>Error in envRefInferField(x, what, getClass(class(x)), selfEnv) :
>‘result’ is not a valid field or method name for reference class “Zelig-logit”

models <- list(lmi,lmi2)
texreg(l=models,file="texreg.tex", caption="texreg",
    digits=3, booktabs=T, dcolumn=T, center=T, use.packages=F, caption.above=T, custom.model.names=c("model1", "model2"))

>Error in (function (classes, fdef, mtable)  :
>unable to find an inherited method for function ‘extract’ for signature ‘"Zelig-logit"’

How can I show the result of multiple imputation by R?

P.S.

> summary(lmi)
Model: Combined Imputations 
                    Estimate Std.Error  z value  Pr(>|z|)    
(Intercept)         -4.15186   0.41048 -10.1147 0.000e+00 ***
x1                   9.76225   0.18356  12.4336 0.000e+00 ***
x2                   1.76719   0.18031  10.9489 0.000e+00 ***
---
Signif. codes:  '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

For results from individual imputed datasets, use summary(x, subset = i:j)
Next step: Use 'setx' method

lmi2 is similar to lmi.

user87562
  • 113
  • 5

2 Answers2

2

Not all model objects are currently supported in either package, and I guess that is the case for the models you are using. If stargazer does not support your model object I'm not aware of a solution. However, texreg is extensible: you can write a simple function to extract what you need from the model object and then the normal texreg commands will work with that extract function. This is clearly explained in this article on texreg, see section six.

The author of texreg also wrote out an example of how to write an extract function in answer to a question I asked here, and wrote an even more comprehensive review of how to extend texreg here. I would advise you to write extract functions that work with your model objects and then you can use texreg.

Community
  • 1
  • 1
gfgm
  • 3,627
  • 14
  • 34
0

texreg now handles Zelig objects and works with Amelia, Mice and Mi through Zelig. Use the function to_zelig_mi to create data object that Zelig will recognize.

CZuC
  • 69
  • 6