Hi Ista, 

Thanks for pointing this out, we'll take a look and try to fix the problem. The next release should fix this and a few other issues with ameliabind. 

Cheers,
matt.

~~~~~~~~~~~
Matthew Blackwell
Assistant Professor of Political Science
University of Rochester
url: http://www.mattblackwell.org


On Thu, Mar 28, 2013 at 8:27 AM, Ista Zahn <istazahn@gmail.com> wrote:
Hi all,

Just a quick followup on this--the problem starts because ameliabind
returns an imputations list with duplicate names, and this appears to
confuse zelig. Here is a demonstration that this is in fact the
problem:

require(Amelia)
library(Zelig)

data(freetrade)

a.out1 <-amelia(freetrade, m = 1, ts = "year", cs = "country")
a.out2 <-amelia(freetrade, m = 1, ts = "year", cs = "country")
a.out3 <-ameliabind(a.out1, a.out2) # combine the amelia runs

## the line below gives incorrect results
summary(zelig(tariff ~ polity + pop + gdp.pc, data =
a.out3$imputations, model = "ls", cite = FALSE))

## rename imputations list
names(a.out3$imputations) <- c("imp1", "imp2")
## the line below gives correct results
summary(zelig(tariff ~ polity + pop + gdp.pc, data =
a.out3$imputations, model = "ls", cite = FALSE))

So clearly correctly averages the results when the imputations list
has different names, and fails to do so when the names are duplicated.
I guess in R it is not illegal to have a list with duplicate names,
but it seems like a bad idea. So I suggest that this be considered a
bug in Amelia rather than in Zelig. ameliabind should return an
imputations list with unique names.

Best,
Ista

On Wed, Mar 27, 2013 at 11:55 PM, Honaker, James
<jhonaker@iq.harvard.edu> wrote:
> Hi One,
>
> I am one of the Amelia authors, but I am also currently working on improving
> the latest release of Zelig.  Zelig has had recent issues with multiply
> imputed data and I am currently working on addressing these systemically.
> There should be a new version of Zelig released next week that I can certify
> for multiply imputed data.  I am sorry for the delay and hope you can be
> patient for this pause.  If you would like me to use your dataset as part of
> my battery of tests and diagnostics as I am working towards this, please
> send it to me off list, and I will check that it works correctly (and delete
> it when the development cycle is completed), otherwise, I will be certain to
> simulate an example like you constructed.
>
> Feel free to contact me on or off list with any questions,
>
> James.
>
>
> --
> James Honaker, Senior Research Scientist
> //// Institute for Quantitative Social Science, Harvard University
> ________________________________
> From: amelia-bounces@lists.gking.harvard.edu
> [amelia-bounces@lists.gking.harvard.edu] on behalf of One Hwang
> [one@healingzoom.com]
> Sent: Wednesday, March 27, 2013 10:21 PM
> To: zelig@lists.gking.harvard.edu
> Cc: amelia@lists.gking.harvard.edu
> Subject: [amelia] ameliabind and zelig
>
> 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.
>
>
>
>
> -
> --
> Zelig Mailing List, served by HUIT
> Send messages: zelig@lists.gking.harvard.edu
> [un]subscribe Options: http://lists.gking.harvard.edu/mailman/listinfo/zelig
> Zelig program information: http://gking.harvard.edu/zelig/
> Zelig mailing list
> Zelig@lists.gking.harvard.edu
>
> To unsubscribe from this list or get other information:
>
> https://lists.gking.harvard.edu/mailman/listinfo/zelig
--
Amelia mailing list served by HUIT
[Un]Subscribe/View Archive: http://lists.gking.harvard.edu/?info=amelia
More info about Amelia: http://gking.harvard.edu/amelia
Amelia mailing list
Amelia@lists.gking.harvard.edu

To unsubscribe from this list or get other information:

https://lists.gking.harvard.edu/mailman/listinfo/amelia