The argument "weights" takes the name of the variable. So, you should try something like:
weights = "weights"
Best,
Kosuke
Department of Politics
Princeton University
http://imai.princeton.edu
On Sep 19, 2011, at 11:45 AM, Pingaul jb wrote:
> Dear professor,
> Thanks for your answer! I finally built on MatchIt to write quick functions to help in the matching with multiple imputation (equivalent to matchit, summary and match.data). I don't think they are very elegant but I send them to you anyway now that they are done (with a csv file with data as an example).
> More importantly, I get an error warning with a syntax adapted from Ho et al. (2011) with MatchIt to calculate ATT. The syntax with the article is with method=”nearest” with no replacement. I tried with replacement. Therefore, it seems I need to introduce weights when estimating the model on the controls. But when I apply the resulting model on the treated I get a problem with different variables length for the weights. To make sure the control group is well matched I think I must introduce the weights anyway but I’m unsure how to do it. Under is my syntax with the lalonde data.
> library(MatchIt)
> library(Zelig)
> data(lalonde)
> m.out0 <- matchit(treat ~ age + educ + black + hispan + nodegree + married + re74 + re75, method = "nearest",replace=T, data = lalonde)
> datacontrol= match.data(m.out0, "control")
> summary(m.out0)
> datatreat=match.data(m.out0, "treat")
> z.out1 <- zelig(re78 ~ age + educ + black + hispan + nodegree + married + re74 + re75, data = datacontrol,weights=datacontrol$weights, model = "ls")
> x.out1 <- setx(z.out1, data = datatreat, cond = TRUE)
> s.out1 <- sim(z.out1, x = x.out1)
>
>
> Best regards,
>
> Jean-Baptiste
>
> --- En date de : Jeu 15.9.11, Kosuke Imai <kimai(a)Princeton.EDU> a écrit :
>
> De: Kosuke Imai <kimai(a)Princeton.EDU>
> Objet: Re: MatchIt Zelig and multiple imputation
> À: "Pingaul jb" <pingaultjb(a)yahoo.fr>
> Cc: "matchit" <matchit(a)lists.gking.harvard.edu>, "zelig(a)lists.gking.harvard.edu" <zelig(a)lists.gking.harvard.edu>
> Date: Jeudi 15 septembre 2011, 5h03
>
> 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
> >
>
> <MatchItMI.txt><DataExample.csv>
--
MatchIt mailing list served by Harvard-MIT Data Center
List Address: matchit(a)lists.gking.harvard.edu
Subscribe/Unsubscribe: http://lists.gking.harvard.edu/?info=matchit
MatchIt Software and Documentation: http://gking.harvard.edu/matchit/
Browse/Search List Archive: http://lists.hmdc.harvard.edu/lists/matchit/
Hi!
How would I go about estimating ATE in R following full matching and
optimal matching in MatchIt? Would it be any different than the method
shown in the documentation for nearest neighbor matching?
Thanks!
Shane
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
>
--
MatchIt mailing list served by Harvard-MIT Data Center
List Address: matchit(a)lists.gking.harvard.edu
Subscribe/Unsubscribe: http://lists.gking.harvard.edu/?info=matchit
MatchIt Software and Documentation: http://gking.harvard.edu/matchit/
Browse/Search List Archive: http://lists.hmdc.harvard.edu/lists/matchit/
It's important to look at the outputs even if there is no error. ATE for the treated is given at the end of the summary. This is the estimated average treatment effect on the treated.
Kosuke
Department of Politics
Princeton University
http://imai.princeton.edu
On Sep 13, 2011, at 11:32 AM, Shane Phillips wrote:
> OK, you were exactly right (of course). I had a problem in my code earlier that made the dichotemous covariates perfectly matched. So I ran it and got the following output...
>
> Mean Values of Observed Data (n = 148)
> (Intercept) age gender lunch mapfall
> 1.00000000 91.06756757 0.50675676 0.29729730 175.77027027
> itbs iep cogat treat lunch:mapfall
> 162.26351351 0.09459459 163.52027027 1.00000000 49.91216216
> lunch:itbs mapfall:iep itbs:iep
> 46.22297297 15.13513514 13.60135135
>
> Pooled Expected Values: E(Y|X)
> mean sd 2.5% 97.5%
> 1.4692861 0.1847377 1.1149093 1.8384215
>
> Pooled Average Treatment Effect for the Treated: Y - EV
> mean sd 2.5% 97.5%
> -0.0005950249 0.0631441009 -0.1299407801 0.1250145250
>
>
> How do I interpret that?
>
> Thanks again!
>
> S
>
> On Tue, Sep 13, 2011 at 11:09 AM, Kosuke Imai <kimai(a)princeton.edu> wrote:
> Did you look at the balance? Perfectly matched covariates should not be included in the subsequent regression model.
>
> Kosuke
>
> Department of Politics
> Princeton University
> http://imai.princeton.edu
>
> On Sep 13, 2011, at 11:07 AM, Shane Phillips wrote:
>
> > Even if I don't include interaction terms (i.e., x1+x2+x3) it gives me the error, however, if I remove the binary variables it works fine.
> > Advice???
> > S
> >
> > On Tue, Sep 13, 2011 at 8:48 AM, Kosuke Imai <kimai(a)princeton.edu> wrote:
> > I don't think x1*(x2+x3) is a valid syntax (it may be but may not be accepted by Zelig). If you want interaction term, you need to do x1:x2 or x1*x2 if you want to also include main effects.
> >
> > Kosuke
> >
> >
> > Department of Politics
> > Princeton University
> > http://imai.princeton.edu
> >
> >
> > On Sep 9, 2011, at 10:56 AM, Shane Phillips wrote:
> >
> > > Hi!
> > >
> > > I am trying to calculate ATT for some data, and I am getting an error. Below is the relevant code, the error and the traceback...
> > >
> > > znn.out<-zelig(growthz~age+cogat+iep*(mapfall+itbs)+lunch*(mapfall+itbs)+treat, data=match.data(nearest), model="ls")
> > > nnx.out <- setx(znn.out, data = match.data(nearest,"treat"), cond = TRUE)
> > > snn.out <- sim(znn.out, x = nnx.out)
> > >
> > > Error in mvrnorm(num, mu = coef(object), Sigma = vcov(object)) :
> > > incompatible arguments
> > >
> > > >
> > > traceback()
> > >
> > > 6: stop("incompatible arguments")
> > > 5: mvrnorm(num, mu = coef(object), Sigma = vcov(object))
> > > 4: param.lm(object, num = num, bootstrap = bootstrap)
> > > 3: param(object, num = num, bootstrap = bootstrap)
> > > 2: sim.cond(znn.out, x = nnx.out)
> > > 1: sim(znn.out, x = nnx.out)
> > >
> > >
> > > Note: Age, cogat, mapfall, and itbs are continuous variables. Iep, lunch, and treat are binary.
> > >
> > > Please help!
> > >
> > > S
> > >
> > >
> >
> >
>
>
--
MatchIt mailing list served by Harvard-MIT Data Center
List Address: matchit(a)lists.gking.harvard.edu
Subscribe/Unsubscribe: http://lists.gking.harvard.edu/?info=matchit
MatchIt Software and Documentation: http://gking.harvard.edu/matchit/
Browse/Search List Archive: http://lists.hmdc.harvard.edu/lists/matchit/
Did you look at the balance? Perfectly matched covariates should not be included in the subsequent regression model.
Kosuke
Department of Politics
Princeton University
http://imai.princeton.edu
On Sep 13, 2011, at 11:07 AM, Shane Phillips wrote:
> Even if I don't include interaction terms (i.e., x1+x2+x3) it gives me the error, however, if I remove the binary variables it works fine.
> Advice???
> S
>
> On Tue, Sep 13, 2011 at 8:48 AM, Kosuke Imai <kimai(a)princeton.edu> wrote:
> I don't think x1*(x2+x3) is a valid syntax (it may be but may not be accepted by Zelig). If you want interaction term, you need to do x1:x2 or x1*x2 if you want to also include main effects.
>
> Kosuke
>
>
> Department of Politics
> Princeton University
> http://imai.princeton.edu
>
>
> On Sep 9, 2011, at 10:56 AM, Shane Phillips wrote:
>
> > Hi!
> >
> > I am trying to calculate ATT for some data, and I am getting an error. Below is the relevant code, the error and the traceback...
> >
> > znn.out<-zelig(growthz~age+cogat+iep*(mapfall+itbs)+lunch*(mapfall+itbs)+treat, data=match.data(nearest), model="ls")
> > nnx.out <- setx(znn.out, data = match.data(nearest,"treat"), cond = TRUE)
> > snn.out <- sim(znn.out, x = nnx.out)
> >
> > Error in mvrnorm(num, mu = coef(object), Sigma = vcov(object)) :
> > incompatible arguments
> >
> > >
> > traceback()
> >
> > 6: stop("incompatible arguments")
> > 5: mvrnorm(num, mu = coef(object), Sigma = vcov(object))
> > 4: param.lm(object, num = num, bootstrap = bootstrap)
> > 3: param(object, num = num, bootstrap = bootstrap)
> > 2: sim.cond(znn.out, x = nnx.out)
> > 1: sim(znn.out, x = nnx.out)
> >
> >
> > Note: Age, cogat, mapfall, and itbs are continuous variables. Iep, lunch, and treat are binary.
> >
> > Please help!
> >
> > S
> >
> >
>
>
--
MatchIt mailing list served by Harvard-MIT Data Center
List Address: matchit(a)lists.gking.harvard.edu
Subscribe/Unsubscribe: http://lists.gking.harvard.edu/?info=matchit
MatchIt Software and Documentation: http://gking.harvard.edu/matchit/
Browse/Search List Archive: http://lists.hmdc.harvard.edu/lists/matchit/
Hi!
I am trying to calculate ATT for some data, and I am getting an error.
Below is the relevant code, the error and the traceback...
znn.out<-zelig(growthz~age+cogat+iep*(mapfall+itbs)+lunch*(mapfall+itbs)+treat,
data=match.data(nearest), model="ls")
nnx.out <- setx(znn.out, data = match.data(nearest,"treat"), cond = TRUE)
snn.out <- sim(znn.out, x = nnx.out)
Error in mvrnorm(num, mu = coef(object), Sigma = vcov(object)) :
incompatible arguments> traceback()6: stop("incompatible arguments")
5: mvrnorm(num, mu = coef(object), Sigma = vcov(object))
4: param.lm(object, num = num, bootstrap = bootstrap)
3: param(object, num = num, bootstrap = bootstrap)
2: sim.cond(znn.out, x = nnx.out)
1: sim(znn.out, x = nnx.out)
Note: Age, cogat, mapfall, and itbs are continuous variables. Iep,
lunch, and treat are binary.
Please help!
S
Dear Matchitlist,
Many thanks for that incredible and useful software that solves
(almost) all my matching problems ...
I would like to know if it is possible to use something similar to the
"exact" option in nearest neighbor matching for all the others
matching algorithms..
That is, for example, apply a genetic algorithm but being able to
obtain matches that have absolutely the same values for, lets say,
their date of birth or any other string or numeric variable...
Many thanks in advance,
Best
--
MatchIt mailing list served by Harvard-MIT Data Center
List Address: matchit(a)lists.gking.harvard.edu
Subscribe/Unsubscribe: http://lists.gking.harvard.edu/?info=matchit
MatchIt Software and Documentation: http://gking.harvard.edu/matchit/
Browse/Search List Archive: http://lists.hmdc.harvard.edu/lists/matchit/