Hi,
I want to combine multiple amelia runs, and use the zelig function on the entire set of amelia outputs. However, I noticed that when I run zelig on the combined set, the coefficients don't look right. Here are the script and the R outputs:
> require(Amelia)
## Amelia II: Multiple Imputation
## (Version 1.7, built: 2013-02-10)
> library(Zelig)
Attaching package: ‘zoo’
The following object(s) are masked from ‘package:base’:
as.Date, as.Date.numeric
ZELIG (Versions 4.1-3, built: 2013-01-30)
> data(freetrade)
> a.out1 <-amelia(freetrade, m = 1, ts = "year", cs = "country")
-- Imputation 1 --
1 2 3 4 5 6 7 8 9 10 11 12 13 14
> a.out2 <-amelia(freetrade, m = 1, ts = "year", cs = "country")
-- Imputation 1 --
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
> a.out3 <-ameliabind(a.out1, a.out2) # combine the amelia runs
> summary(a.out3)
Amelia output with 2 imputed datasets.
Return code: 1
Message: Normal EM convergence
Chain Lengths:
--------------
Imputation 1: 14
Imputation 2: 15
Rows after Listwise Deletion: 96
Rows after Imputation: 171
Patterns of missingness in the data: 8
Fraction Missing for original variables:
-----------------------------------------
Fraction Missing
year 0.00000000
country 0.00000000
tariff 0.33918129
polity 0.01169591
pop 0.00000000
gdp.pc 0.00000000
intresmi 0.07602339
signed 0.01754386
fiveop 0.10526316
usheg 0.00000000
# run zelig on the first amelia run
> z.out1 <- zelig(tariff ~ polity + pop + gdp.pc, data = a.out1$imputations, model = "ls", cite = FALSE)
> summary(z.out1)
Call:
lm(formula = formula, weights = weights, model = F, data = data)
Residuals:
Min 1Q Median 3Q Max
-29.686 -11.067 -3.367 10.003 45.556
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.317e+01 1.891e+00 17.538 < 2e-16 ***
polity -1.060e-01 2.434e-01 -0.435 0.664
pop 2.925e-08 5.405e-09 5.411 2.15e-07 ***
gdp.pc -2.738e-03 5.235e-04 -5.231 4.99e-07 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 16.62 on 167 degrees of freedom
Multiple R-squared: 0.3234, Adjusted R-squared: 0.3112
F-statistic: 26.6 on 3 and 167 DF, p-value: 4.07e-14
# run zelig on the second amelia run
> z.out2 <- zelig(tariff ~ polity + pop + gdp.pc, data = a.out2$imputations, model = "ls", cite = FALSE)
> summary(z.out2)
Call:
lm(formula = formula, weights = weights, model = F, data = data)
Residuals:
Min 1Q Median 3Q Max
-40.13 -11.72 -3.63 10.16 43.77
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.400e+01 1.984e+00 17.133 < 2e-16 ***
polity -6.123e-02 2.545e-01 -0.241 0.81
pop 3.289e-08 5.689e-09 5.781 3.56e-08 ***
gdp.pc -3.016e-03 5.501e-04 -5.484 1.51e-07 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 17.47 on 167 degrees of freedom
Multiple R-squared: 0.3495, Adjusted R-squared: 0.3378
F-statistic: 29.91 on 3 and 167 DF, p-value: 1.574e-15
# run zelig on the combined amelia runs
> z.out3 <- zelig(tariff ~ polity + pop + gdp.pc, data = a.out3$imputations, model = "ls", cite = FALSE)
> summary(z.out3)
Call:
lm(formula = formula, weights = weights, model = F, data = data)
Residuals:
Min 1Q Median 3Q Max
-29.686 -11.067 -3.367 10.003 45.556
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.317e+01 1.891e+00 17.538 < 2e-16 ***
polity -1.060e-01 2.434e-01 -0.435 0.664
pop 2.925e-08 5.405e-09 5.411 2.15e-07 ***
gdp.pc -2.738e-03 5.235e-04 -5.231 4.99e-07 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 16.62 on 167 degrees of freedom
Multiple R-squared: 0.3234, Adjusted R-squared: 0.3112
F-statistic: 26.6 on 3 and 167 DF, p-value: 4.07e-14
Can someone please tell me why summary(z.out3) is returning the exact same results as summary(z.out1)?
How can I fix this problem so that the ameliabind output is treated the same as a direct output from the amelia function?
Thanks.
Hi,
I am a novice user of Amelia, and I am puzzled on how I can obtain the degrees of freedom, t-statistic, and f-values of combined multiply imputed data using Amelia or Zelig.
To understand how to combine imputations, I used code straight from the Amelia manual. When I loaded Zelig and used the zelig function, I get coefficients that appear to be coefficients of individual imputations, and not those of the combined set. The code I used was:
z.out.imp <- zelig(tariff ~ polity + pop + gdp.pc + year + country, data = a.out$imputations, model = "ls")
summary(z.out.imp)
Furthermore, I have also tried this code:
> b.out <-NULL
> se.out <-NULL
> for(i in 1:a.out$m){
+ ols.out <- lm(tariff ~ polity + pop + gdp.pc, data = a.out$imputations[[i]])
+ b.out <- rbind(b.out, ols.out$coef)
+ se.out <-rbind(se.out, coef(summary(ols.out))[,2])
+ }
> combined.results<-mi.meld(q=b.out, se = se.out)
> combined.results
The returned information reflects the combined values and the combined standard error. It appears that there is no way to get the t-statistic, degrees of freedom, or f-values using mi.meld().
Without having to do a manual calculation or use Stata, how can I obtain the degrees of freedom, t-statistic, and f-values?
Thanks.
AmeliaView 1.6.4 running on a Windows 7 64-bit system, produces "can not
find script file "C:/Windows/system32/amelia.vbs".
Trying again In R I get:
> install.packages("Amelia")
Warning in install.packages("Amelia") :
'lib = "C:/Program Files/R/R-2.15.2/library"' is not writable
Error in install.packages("Amelia") : unable to install packages
> install.packages("Amelia", repos = "http://cran.r-project.org", type
= "source")
Warning in install.packages("Amelia", repos =
"http://cran.r-project.org", :
'lib = "C:/Program Files/R/R-2.15.2/library"' is not writable
Error in install.packages("Amelia", repos = "http://cran.r-project.org", :
unable to install packages
Clearly something is wrong. Any suggestions?
Dear Amelia users,
I am working with a data set that I import from STATA to Amelia. It is a time series cross section data set which I have converted from snapshot to duration data with the snapspan command in Stata.
Is it correct to then mark the time variables that denote time and time0 (created by snapspan) as ID variables before imputation?
Thank you for your help,
Agnes Cornell
Doktorand / Ph. D. Candidate
Statsvetenskapliga institutionen / Department of Political Science
Göteborgs universitet / University of Gothenburg
Box 711
SE 405 30 Göteborg
Sweden
Tel: +46 (0)31- 786 6145
E-mail: agnes.cornell(a)pol.gu.se<applewebdata://52D8C634-DC21-473F-BCB0-BC4A2D788243/owa/UrlBlockedError.aspx>
Dear All,
I am trying to overimpute a variable and get the error:
/var doesn't exist in the amelia output. It either didn't get imputed
or is out of the range of columns.
/The variable exists, and has been imputed. The compare.density also
works for that variable.
How many columns are allowed? the dataset is very large with about
16'000 observations.
Thank you for your help.
Best,
Philippe