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.
Dear Amelia mailing list,
I have some code that runs in Amelia 1.6.1 (with R 2.15.0) without any
problems. When I run that same code in Amelia 1.7.1 (with R 3.0.0), a
few imputations might finish without any error messages, but many
finish with the message "The resulting variance matrix was not
invertible. Please check your data for highly collinear variables".
I understand that this suggests that there may be a problem with the
data, but I don't understand why there would be a problem in version
1.7.1 but not in 1.6.1.
Also, when I'm using Amelia 1.7.1 in R 3.0.0, R will sometimes crash
during the imputation process. I'm running R in emacs in Windows, and
I'll sometimes get a pop-up window saying "R for Windows terminal
front-end has stopped working", with the following message appearing
in emacs:
"error: chol(): failed to converge
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
terminate called after throwing an instance of 'std::runtime_error'
what():
Process R exited abnormally with code 3 at Fri Apr 05 15:04:58 2013"
Amelia 1.7.1 worked without any problems when I tried it on some small
made-up data, but not on my real data. I understand that it's almost
impossible to diagnose problems without a reproducible example, but I
was wondering whether others have had similar problems.
Thanks for any comments you can give.
Mark Seeto