Unfortunately, I don't think we have an automated procedure for everything. You would have to multiply impute the data, do matching on each imputed data set, and then combine it in zelig() using mi() function. But this does not require any programming. You can simply run the same matching procedure on each data set via matchit() and then feed the resulting multiple matched data sets into zelig().
Good luck,
Kosuke
Department of Politics
Princeton University
http://imai.princeton.edu
On Sep 13, 2011, at 6:02 PM, Pingaul jb wrote:
> Dear Professor,
> I’m a post-doctoral student at Montreal University. I’m actually in Columbia, working and propensity scores with a colleague and using MatchIt and Zelig. First, congratulations for your packages that are very flexible.
>
> My question is about multiple imputation and propensity scores with these softwares. From what I understand, combining both approaches would include:
>
> 1/ Doing multiple imputation and testing which variables to include.
>
> 2/ Propensity score analysis on each imputed data set and pooling the overall balance to check if it is ok (or on each data set?).
>
> 3/ Calculation of the quantities of interest for each data set
>
> 4/ Pooling the quantities across data sets.
>
> I would like to know if there is a written syntax to perform the MatchIt analysis for all of the imputed data set without having to do it manually and check the overall balance. Also, in theory, the number of individuals retained after propensity score matching and the weights can be different for each imputed data set. So that we have to perform the final analysis on each one and then pool the data with a specific procedure to take into account the eventual varying Ns? I normally use Mice package for multiple imputation but it seems that Zelig handle Amelia. My colleague seems to do be able to do all that in stata, but I’m not sure how to make all the three R packages work together.
>
> I would be very happy if you could indicate to me a reference or a place where I can find the syntax to do that (I’ve been using R for some times so I can use packages easily but I have no programming skills).
>
>
> Best Regards!
>
>
>
> Jean-Baptiste
>
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options: http://lists.gking.harvard.edu/?info=zelig
Zelig program information: http://gking.harvard.edu/zelig/
Hi there,
I am encountering this error when using sim after logit.mixed or
probit.mixed:
Error in qifunction(obj, x = x, x1 = x1, y = y, param = param, num = num)
> : could not find function "setup.x.matrix"
This is with "ZeligMixed".
If I use ZeligMultilevel I get:
Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x),
> :
> attempt to set an attribute on NULL
Toy example:
d <- expand.grid(y=rbinom(10,1,.33),x=rnorm(10,1),t=1:4)
z.out <- zelig(y~x+tag(1|t),data=d,model="logit.mixed")
sim(z.out)
thanks,
Yph
Hello - I was happy to find the Zelig package as I had been looking for
code for implementing a generalized linear mixed model. I'm having some
issues obtaining predicted probabilities from my rather simple logit.mixed
regression. I am using logit.mixed with avoidance behavior as the binomial
response variable, height as the predictor (ranging from 150 to 1500m), and
year as a random effect (there are 3 years). The model runs fine, but I
encounter an error starting with x.out. I've looked at the package
documentation to try to solve the error, and have been unsuccessful. I'd
like to produce one figure showing with the predicted probability on the
y-axis and height on the x-axis. I'd like to show the regression line with
the 95% CI for the predicted probabilities. I've been successful at coding
this analysis and figure for a fixed effects logistic regression, but not
so much for the mixed effects logistic regression.
Thank you
library(Zelig)
library(ZeligMultilevel)
avd$year <- factor(avd$year)
z.out <- zelig(avoid ~ height + tag(1|year), data = avd, model =
"logit.mixed")
summary(z.out)
x.out <-setx(z.out, fn = NULL)
s.out <- sim(z.out, x = x.out)
summary(s.out)
Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x), :
'data' must be of a vector type> summary(s.out)Error in summary(s.out) :
error in evaluating the argument 'object' in selecting a method for
function 'summary': Error: object 's.out' not found
--
Karl Kosciuch
kosciuch(a)gmail.com
Hi Matt,
I saw this on the lists as a problem in January but I don't know whether a
fix was found.
The error is replicated using the sleepstudy data included in lme4.
z.out<-zelig(Reaction ~ Days + tag(Days|Subject), data=sleepstudy,
model="ls.mixed")
x.out<-setx(z.out, Days=4.4)
s.out<-sim(z.out, x=x.out)
Fails with:
Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x),
:
attempt to set an attribute on NULL
Best wishes,
Ewen
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 all,
I am trying to install Zelig version 4.1-4, which is in development. I followed the instructions on http://projects.iq.harvard.edu/zelig/install to install releases that are in development. Here is what's happening in my R Console:
version 2.15.3 (2013-03-01) -- "Security Blanket"
Copyright (C) 2013 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-w64-mingw32/x64 (64-bit)
> install.packages("devtools")
Installing package(s) into ‘C:/Users/One/Documents/R/win-library/2.15’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://cran.cnr.Berkeley.edu/bin/windows/contrib/2.15/devtools_1.1.zip'
Content type 'application/zip' length 259993 bytes (253 Kb)
opened URL
downloaded 253 Kb
package ‘devtools’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\One\AppData\Local\Temp\RtmpGsZCno\downloaded_packages
> library(devtools)
WARNING: Rtools is required to build R packages, but the version of Rtools previously installed in c:/Rtools has been deleted.
Please download and install Rtools 3.0 from http://cran.r-project.org/bin/windows/Rtools/ and then run find_rtools().
To address this error, I copied and pasted the code found here into my R console:
https://github.com/hadley/devtools/blob/master/R/rtools.r
Although I was able to get R to properly find rtools, I encountered additional problems:
> library(devtools)
> find_rtools()
[1] TRUE
> install_github("IQSS", "Zelig")
Installing github repo(s) IQSS/master from Zelig
Installing IQSS.zip from https://github.com/Zelig/IQSS/archive/master.zip
Error: client error: (406) Not Acceptable
Does anyone know what the next steps should be to install Zelig 4.1-4? Thanks.
Hi,
I am using the Zelig package since my dataset is imputed. Somehow while using the function on linux (using R 2.15.2) with Zelig (version 4.1-3) I am facing the error:
Error in UseMethod("multi.dataset") :
no applicable method for 'multi.dataset' applied to an object of class "function"
Calls: zelig -> eval -> eval -> multi.dataset
Execution halted
But the same example works with the older version of Zelig package (3.5.5) while installing the native packages on an older machine. Due to this limitation I am not able to execute the package on Redhat. It would be great if you could advise me on an alternative or if you could provide me the Zelig tar file (version 3.5.5).
Thanks in advance,
Anubhav
Hi there, I just now upgraded to R 3.0.0, running Zelig 4.1-3, on a Mac OS 10.8.3.
Some code I had written before is no longer working, and the reason seems to be that Zelig objects can no longer be manipulated with fitted() or fitted.values(), as before.
More specifically:
> my.model <- zelig(dv~iv1+iv2, data=my,data,model="ls",cite=F)
> fitted(my.model)
NULL
> fitted.values(my.model)
NULL
> predict(im.basic3)
Error in min(y) : invalid 'type' (list) of argument
Is this a bug, is this me, or was this done in purpose?
Cesar Zucco
Dustin,
In general, the summary provided often does not resemble the expectation of a summary() and this needs to be reformatted, although the summary.gee() might be contributing in this case, as Patrick points out. I'll move this up the priority list.
As for the second problem, there are are some intertwined and longstanding issues that have been noted on the list with treatment of missing data, and those should finally be resolved in the next couple days.
James
--
James Honaker, Senior Research Scientist
//// Institute for Quantitative Social Science, Harvard University
-----Original message-----
From: Patrick Lam <plam(a)fas.harvard.edu>
To: "Tingley, Dustin" <dtingley(a)gov.harvard.edu>
Cc: "zelig(a)lists.gking.harvard.edu" <zelig(a)lists.gking.harvard.edu>
Sent: Wed, Apr 24, 2013 23:23:50 GMT+00:00
Subject: Re: [zelig] summary error
i believe the huge matrix is the working correlation matrix, which the gee package now chooses to output in summary, so it doesn't seem strictly like a zelig issue. although the zelig version does display an extra long call function in the output, which may need to be fixed.
On Wed, Apr 24, 2013 at 6:44 PM, dustin tingley <dtingley(a)gov.harvard.edu<mailto:dtingley@gov.harvard.edu>> wrote:
Hi-
when I run summary on this model output, I just get this giant set of matrices rather than the summary of the model.
r3<-zelig(wrongright3~mean.firstatt , model="probit.gee", robust=TRUE, id="student", corstr = "exchangeable", data=m)
Further, the sim function still appears to not support case wise deletion of missing data...it just throws an error that doesn't tell you that that is what the problem is.
Dustin
Dustin Tingley
Government Department
Harvard University
http://scholar.harvard.edu/dtingley
Director, Program on Experience Based Learning in the Social Sciences
http://projects.iq.harvard.edu/peblss/
Contribute to the Research Reservoir: http://projects.iq.harvard.edu/undergradscholars/pages/research-resources
-
--
Zelig Mailing List, served by HUIT
Send messages: zelig(a)lists.gking.harvard.edu<mailto: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(a)lists.gking.harvard.edu<mailto:Zelig@lists.gking.harvard.edu>
To unsubscribe from this list or get other information:
https://lists.gking.harvard.edu/mailman/listinfo/zelig
--
Patrick Lam
Department of Government and Institute for Quantitative Social Science, Harvard University
http://www.patricklam.org
Hi-
when I run summary on this model output, I just get this giant set of
matrices rather than the summary of the model.
r3<-zelig(wrongright3~mean.firstatt , model="probit.gee", robust=TRUE,
id="student", corstr = "exchangeable", data=m)
Further, the sim function still appears to not support case wise deletion
of missing data...it just throws an error that doesn't tell you that that
is what the problem is.
Dustin
Dustin Tingley
Government Department
Harvard University
http://scholar.harvard.edu/dtingley
Director, Program on Experience Based Learning in the Social Sciences
http://projects.iq.harvard.edu/peblss/
Contribute to the Research Reservoir:
http://projects.iq.harvard.edu/undergradscholars/pages/research-resources