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/
Good morning
If I run
<<<
susan.lsmixed.out <- zelig(formula = unprot_vag_sex ~ married + age + TREATMENT.ARM*time + highest_grade + income + tag(1|id),
data = susanMI.out$imputations, model = "ls.mixed")
summary(susan.lsmixed.out)
>>>>
I get an error
Error in x$coef : $ operator is invalid for atomic vectors
Searching the archives, I see that others have had similar problems. Is there a workaround?
summary(susan.lsmixed.out[[1]])
works fine; should I then average across the five imputed data sets?
thanks!
Peter
Peter L. Flom, PhD
Statistical Consultant
Website: http://www DOT statisticalanalysisconsulting DOT com/
Writing; http://www.associatedcontent.com/user/582880/peter_flom.html
Twitter: @peterflom
-
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/
I'm trying to find a way to
have country clusters in a relogit analysis.
I have country-year data
and the countries are grouped
by a numeric id variable "cid".
I've tried including a list
of options for robust such that my model is:
M1 <- zelig(violence ~ dem_age,
model = "relogit", tau = 88/5480,
data = data,
robust = list(
method =
"vcovHAC",
order.by = ~data$cid,
adjust = TRUE
))
However why I run "summary(M1)" I get an error:
Error in meatHAC
(x, order.by = order.by, prewhite = prewhite, weights = weights, :
subscript out of bounds
Any thoughts on what is going on?
ReLogit for zelig would be really useful if it could incorporate clusters.
Thanks
Christopher
Hi zelig folks,
I'm trying to run a set of probit regressions with robust standard errors,
but I repeatedly get the following error message:
Error in glm.control(robust = TRUE) : unused argument(s) (robust = TRUE)
I can't figure out what the problem is. The sandwich package is loaded. An
example of the code I am using is below.
Many thanks,
Shar
z.out <- zelig(binary_iv ~ age + educ + income_new + gender_new + white +
black + hispanic + union_member + dem + rep + indep + tv_foreign + ecknow +
import_mfg, model="probit", robust = TRUE, data = data)
Try converting the variable into a factor before using it in the formula and see if the problem goes away.
Best,
Kosuke
Department of Politics
Princeton University
http://imai.princeton.edu
On Jan 30, 2012, at 10:06 PM, Andrew Boutton wrote:
> Hi Professor Imai,
>
> I'm having a problem with the Zelig package that I was hoping you might be able to help with. I'm running a logit model on panel data with country fixed-effects (using as.factor(ccode) for the fixed effects). Everything works fine until I do "setx()"; when I do that, I get the following error message: "Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels". The R code is below.
>
> When I run the model without "as.factor(ccode)", everything works fine, so I think it has something to do with that. James Honaker suggested that I try installing the latest version of Zelig (3.5.3), but even after doing that, I still have the same problem. Do you have any idea what I can do to fix this? Thanks very much, I appreciate your help.
>
> Best,
>
> Andrew Boutton
>
> > z.out <- zelig(fail4 ~ ln_totaidpct_1 + rivalXtotaidpc + rivalryt_1 + ln_gdpt_1 + democt_1 + numgroups + ter + rc + t + t2 + t3 + as.factor(ccode), model = "logit", +data = data)
> > ln_totaidpct_1.range<--8:8
> >xc.range<- setx(z.out, ln_totaidpct_1=ln_totaidpct_1.range, rivalXtotpc=ln_totaidpct_1.range, rivalryt_1=1)
> Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels
>
> --
> Andrew Boutton
> Graduate Assistant
> Peace Science Society International
> Department of Political Science
> The Pennsylvania State University
> 207 Pond Laboratory
> University Park, PA 16802
> atb171(a)psu.edu
Hi,
I posted on Pastebin.com a demo code to show a problem with sim(). The title on Pastebin is "Problem with sim() when using polynomial time in Zelig".
When I use Zelig with polynomial time in the random effect part (ls.mixed model), the following message appears:
Error in .local(object, ...) : Code not written yet
There is no problem if I drop the polynomial time from the random part.
Thanks
François Maurice
Hi Francois,
It worked!
Thank you, thank you, thank you!
Kenji
On Sat, Jan 21, 2012 at 5:04 PM, Francois Maurice <
maurice.francois(a)ymail.com> wrote:
> Hi Kenji,
>
> There is a problem with the followint option in MatchIt :
>
> discard = "hull.control"
>
> If you run MatchIt without this option, there is no more problem. Maybe
> it's a bug or maybe you have to specify something ! I don't know. I think
> that a developer can be more helpful.
>
> François Maurice, B. Sc., A. Stat.
> Candidat à la maîtrise
> Département de sociologie
> Université de Montréal
> *De :* Kenji Adachi <kenji.adachi.2010(a)gmail.com>
> *À :* Francois Maurice <maurice.francois(a)ymail.com>
> *Cc :* "zelig(a)lists.gking.harvard.edu" <zelig(a)lists.gking.harvard.edu>
> *Envoyé le :* Mercredi 18 Janvier 2012 10h11
> *Objet :* Re: Re : [zelig] sim() command error with MatchIt
>
> Hi Francois and all,
>
> Thanks for your prompt reply.
> I tried "hisp" instead of "hispan", then I got another error: "Error in
> eval(expr, envir, enclos) : object 'hisp' not found."
>
> So, I think "hispan" should be okay because I copied everything from the
> manual.
> I still need your and other Zelig users' help. Please help!
>
> Thanks.
> Kenji
>
>
>
> On Wed, Jan 18, 2012 at 8:39 AM, Francois Maurice <
> maurice.francois(a)ymail.com> wrote:
>
> Hi,
>
> Look at the lalonde dataset. I think that a variable in the zelig()
> formula is not written correctly. If I remembered well "hispan" is written
> "hisp" in the dataset.
>
> À bientôt,
>
> François Maurice, B. Sc., A. Stat.
> Candidat à la maîtrise
> Département de sociologie
> Université de Montréal
> *De :* Kenji Adachi <kenji.adachi.2010(a)gmail.com>
> *À :* zelig(a)lists.gking.harvard.edu
> *Envoyé le :* Mercredi 18 Janvier 2012 1h20
> *Objet :* [zelig] sim() command error with MatchIt
>
> Dear all,
>
> I am interested in using MatchIt for my research. (I am relatively new to
> R, too.) To make myself familiar with the command, I've tried some samples
> provided in the manual. I believe I followed the steps as explained, but I
> always get the same error message. What I did was as follows:
>
> > library(MatchIt)
> > data(lalonde)
> > m.out <- matchit(treat ~ age + educ + black + hispan + nodegree +
>
> married + re74 + re75, method = "nearest", discard
> = "hull.control", data = lalonde)
>
> > library(Zelig)
>
> > z.out <- zelig(re78 ~ treat + age + educ + black + hispan + nodegree +
>
> married + re74 + re75, data = match.data(m.out),
> model = "ls")
>
> > x.out <- setx(z.out, treat=0)
> > x1.out <- setx(z.out, treat=1)
>
> > s.out <- sim(z.out, x = x.out, x1 = x1.out)
>
> Error in mvrnorm(num, mu = coef(object), Sigma = vcov(object)) :
> incompatible arguments
>
>
> I am using R version 2.14.1. I also updated Zelig and MatchIt for the
> latest version.
> I have completely no idea what I did wrong. I would greatly appreciate it
> if you would tell me what to do.
>
> Best Regards,
> Kenji Adachi
>
> -
> --
> Zelig Mailing List, served by HUIT
> Send messages: zelig(a)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
> https://lists.gking.harvard.edu/mailman/listinfo/zelig
>
>
>
>
>
Unfortunately the current version does not allow for a different link function.
Kosuke Imai
Princeton University
http://imai.princeton.edu
Sent from my iPhone
On Jan 21, 2012, at 5:00 PM, segun ogundimu <segun300l(a)yahoo.com> wrote:
> Dear sir,
>
> Your work on the Zelig package is higly appreciated. It has helped me alot. I'm trying to fit a bivariate probit model using zelig. I'm aware that I can using rhobit transformation on the 3rd coefficient from the fitted model. Please, how can I switch the link function to the identity link directly at the modelling stage just like the one in vglm function (family = binom2.rho(lrho = "identity").
>
> Thank you for your time.
>
> Kind regards
> Segun
Dear all,
I am interested in using MatchIt for my research. (I am relatively new to
R, too.) To make myself familiar with the command, I've tried some samples
provided in the manual. I believe I followed the steps as explained, but I
always get the same error message. What I did was as follows:
> library(MatchIt)
> data(lalonde)
> m.out <- matchit(treat ~ age + educ + black + hispan + nodegree +
married + re74 + re75, method = "nearest", discard
= "hull.control", data = lalonde)
> library(Zelig)
> z.out <- zelig(re78 ~ treat + age + educ + black + hispan + nodegree +
married + re74 + re75, data = match.data(m.out),
model = "ls")
> x.out <- setx(z.out, treat=0)
> x1.out <- setx(z.out, treat=1)
> s.out <- sim(z.out, x = x.out, x1 = x1.out)
Error in mvrnorm(num, mu = coef(object), Sigma = vcov(object)) :
incompatible arguments
I am using R version 2.14.1. I also updated Zelig and MatchIt for the
latest version.
I have completely no idea what I did wrong. I would greatly appreciate it
if you would tell me what to do.
Best Regards,
Kenji Adachi
Hi,
The sim() fonction gives me the following message :
Error in .local(object, ...) : Code not written yet
The sim() object is not produce but the zelig() object is produce.
I'm trying to evaluate a causal effect in a longitudinal study with a mixed model after matching with MatchIt(). Here's the code :
z.nearest <- zelig(outcome ~ treat + T + T2 + T3 + tag(1 + T + T2 | ID.factor), data=matched.nearest.long, model="ls.mixed")
x.nearest.0 <- setx(z.nearest, fn=NULL, treat=0)
x.nearest.1 <- setx(z.nearest, fn=NULL, treat=1)
s.nearest <- sim(z.nearest, x=x.nearest.0, x1=x.nearest.1)
I'm using polynomial time with a random part. There is no problem when the random part is only made of one term like this:
z.nearest <- zelig(outcome ~ treat + T + T2 + T3 + tag(T | ID.factor), data=matched.nearest.long, model="ls.mixed")
I posted a problem this last summer about polynomial time, but at that time the problem was within Zelig itself. Zelig was not able to cope with polynomial time, but that problem seems resolved. Maybe the problem with sim() has a link with that one.
Thanks,
Françcois Maurice