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,
It doesn't seem like "robust=TRUE" is working for linear regression (ls). The standard errors are coming out exactly the same as with "robust=FALSE".
I am on R 3.0.0 and Zelig 4.1-3 (and have tried on Linux and Windows).
Has anyone else had this problem?
Here's a reproducible example:
## "Robust" estimation not working
require(Zelig)
df <- data.frame(y=c(rnorm(n=100, mean=0, sd=1), rnorm(n=100, mean=10, sd=10)),
x=c(rep(1, 100), rep(2,100)))
z.robustT <- zelig(y ~ x, data=df, model="ls", robust=TRUE)
z.robustF <- zelig(y ~ x, data=df, model="ls", robust=FALSE)
# Standard errors are the same:
summary(z.robustT)
summary(z.robustF)
## Alternative
require(sandwich)
require(lmtest)
lm.robustF <- lm(y ~ x, data=df)
summary(lm.robustF) #matches z.robustF
vcovMat <- vcovHC(lm.robustF)
lm.robustT <- coeftest(lm.robustF, vcov.=vcovMat)
lm.robustT #same coef, different se
##########
Rod
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="width:100%;">
<tr>
<td align="left" style="text-align:justify;"><font face="arial,sans-serif" size="1" color="#999999"><span style="font-size:11px;">This communication is intended for the addressee only. It is confidential. If you have received this communication in error, please notify us immediately and destroy the original message. You may not copy or disseminate this communication without the permission of the University. Only authorised signatories are competent to enter into agreements on behalf of the University and recipients are thus advised that the content of this message may not be legally binding on the University and may contain the personal views and opinions of the author, which are not necessarily the views and opinions of The University of the Witwatersrand, Johannesburg. All agreements between the University and outsiders are subject to South African Law unless the University agrees in writing to the contrary. </span></font></td>
</tr>
</table
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
In following the recent threads, it appears the MI functionality is an area
of active development in Zelig.
Currently, I'm trying to figure out is how to extract a *combined*
variance-covariance matrix from an analysis using MI datasets, for
post-estimation purposes. Is this possible? The generic extractor vcov()
doesn't seem to work in this particular case.
Appreciate any suggestions,
- David
David Huh, PhD
Postdoctoral Fellow
Center for the Study of Health and Risk Behaviors (CSHRB)
Psychiatry and Behavioral Sciences | University of Washington
1100 NE 45th Street, Suite 300
Seattle, WA 98105
website: <http://staff.washington.edu/dhuh>
http://staff.washington.edu/dhuh
<mailto:dhuh@uw.edu> dhuh(a)uw.edu | tel: 206.616.1997 | cell: 206.552.9848 |
fax: 206.616.1705
Rogerio and James,
The solution is a pretty nifty one. Creating (and then deleting) an object in the global environment does, indeed, solve the problem. I hadn't been introduced to "<<-", so I was looking for a solution that would make Zelig search the local environment.
Now, while I the developers side of the issue, as a user I cannot see how this could become a permanent feature of Zelig commands, especially given that other R functions do not behave this same way. The way I dealt with the issue was simply to switch to glm(), and either hand-code or use erer's maBina() for quantities of interest.
cz
On Jun 1, 2013, at 12:00 PM, zelig-request(a)lists.gking.harvard.edu wrote:
> Send Zelig mailing list submissions to
> zelig(a)lists.gking.harvard.edu
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.gking.harvard.edu/mailman/listinfo/zelig
> or, via email, send a message with subject or body 'help' to
> zelig-request(a)lists.gking.harvard.edu
>
> You can reach the person managing the list at
> zelig-owner(a)lists.gking.harvard.edu
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Zelig digest..."
>
>
> Today's Topics:
>
> 1. Re: can't invoke data object inside a function (Rog?rio Barbosa)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 1 Jun 2013 03:23:53 -0300
> From: Rog?rio Barbosa <antrologos(a)gmail.com>
> To: "Honaker, James" <jhonaker(a)iq.harvard.edu>,
> "zelig(a)lists.gking.harvard.edu" <zelig(a)lists.gking.harvard.edu>
> Subject: Re: [zelig] can't invoke data object inside a function
> Message-ID:
> <CAM+NV=1Z6rcbnXvDD-zy1U4EMHVRF=WvRrZqWF_edSHUdC1WTA(a)mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> By the way, I tried my old do.call solution and in fact it didn't worked. I
> think the problem is that "zelig" always points to the global environment
> (and there is no way to specify a customized env). Using do.call arguments
> wouldn't change the fact that "lcl.data" just exists inside the function.
>
> It seems "setx" doesn't have this issue.
>
> but I'm just guessing...
> Em 01/06/2013 03:13, "Rog?rio Barbosa" <antrologos(a)gmail.com> escreveu:
>
>> Hi Cesar and James,
>>
>> I've came up with a simple idea that worked this problem out, at least for
>> Cesar's purpose -- I think...
>>
>> As Zelig cannot have access to objects created inside a function, one way
>> to deal with it is (1) to use the function for creating the desired data
>> frame in the global environment and then use; (2) then you call this object
>> from Zelig; (3) finally you can delete it, if you want -- and in the end it
>> is like it never existed in the globalenv.
>>
>> Here it is an example:
>>
>> ###
>>
>> rm(list=ls())
>>
>> #require(Zelig)
>>
>> data(mexico)
>>
>> my.function <- function(the.data){
>>
>> lcl.data <<- subset(the.data,select=c(1,2)) #creating a temporary
>> object in the global environment
>>
>> zelig.reg <- zelig(lcl.data[,1]~
>> lcl.data[,2],data=lcl.data,model="ls") #running zelig using that object
>>
>> rm(lcl.data, envir=.GlobalEnv) #removing it...
>>
>> return(zelig.reg)
>>
>> }
>>
>> my.function(mexico)
>>
>> It worked fine for me. Is it what you wanted?
>>
>> Best,
>> Rogerio J. Barbosa
>> On Sat, Jun 1, 2013 at 12:25 AM, Honaker, James <jhonaker(a)iq.harvard.edu>wrote:
>>
>>> Cesar,
>>>
>>> This is the same issue with environment dependence as in this thread
>>> earlier this month:
>>> https://lists.gking.harvard.edu/pipermail/zelig/2013-May/001189.html
>>>
>>> In the slightly long run, the solution is that we will move from S4 to
>>> Reference Classes (R5) over the summer. In the meantime, two solutions
>>> were suggested in that thread. I can not get Rog?rio's do.call() solution
>>> to work with the main zelig() function as I'm probably not creating the
>>> argument list quite right, (the thread was about the setx() function, but
>>> same underlying issue), but finding the dataset by scope does work, even if
>>> unsatisfying.
>>>
>>> Let me know if you work out a better solution for the present.
>>>
>>> Best,
>>> James
>>>
>>> --
>>> James Honaker, Senior Research Scientist
>>> //// Institute for Quantitative Social Science, Harvard University
>>> ------------------------------
>>> *From:* zelig-bounces(a)lists.gking.harvard.edu [
>>> zelig-bounces(a)lists.gking.harvard.edu] on behalf of Cesar Zucco [
>>> cesar.zucco(a)gmail.com]
>>> *Sent:* Wednesday, May 15, 2013 3:28 PM
>>> *To:* zelig(a)lists.gking.harvard.edu
>>> *Subject:* [zelig] can't invoke data object inside a function
>>>
>>> Hello list,
>>>
>>> Is there any known issue using Zelig (4.1-3) commands inside a
>>> function and invoking data.frame that is only defined inside that
>>> function? This worked in the previous versions of Zelig, and works with
>>> non-zelig commands. Here's a barebones example:
>>>
>>> my.function <- function(the.data){
>>> lcl.data <- subset(the.data,select=c(dv,iv))
>>> reg <- lm(dv~ iv,data=lcl.data) #this works fine
>>> zelig.reg <- zelig(dv~ iv,data=lcl.data,model="ls") #this gives error
>>> }
>>>
>>> The lm regression works, but no zelig model seems to be able to use the
>>> lcl.data. I get the same error message triggered by invoking a data.frame
>>> that does not exist:
>>>
>>> Error in multi.dataset(lcl.data) : object 'lcl.data' not found
>>>
>>> cz
>>>
>>> Cesar Zucco Jr.
>>> Assistant Professor
>>> Political Science Department
>>> Rutgers, The State University of New Jersey
>>> http://fas-polisci.rutgers.edu/zucco/
>>>
>>>
>>>
>>>
>>>
>>> -
>>> --
>>> 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
>>>
>>> To unsubscribe from this list or get other information:
>>>
>>> https://lists.gking.harvard.edu/mailman/listinfo/zelig
>>>
>>
>>
>
Good Morning,
Am struggling to use Zelig to generate heteroskedasticity-consistent standard errors using the 2SLS model function. Any quick remedies? Code that I am presently using:
fml <- list(mu1 = Y ~ X + as.factor(Q) +A + B + C, mu2 = X ~ Z + as.factor(Q) +A + B + C, “inst” = ~ Z + as.factor(Q) +A + B + C)
z.out<-zelig(formula=fml, model="twosls", data=x)
summary(z.out).
Thanks very much in advance for any hints!
Very best,
Andrew
Hello list,
Is there any known issue using Zelig (4.1-3) commands inside a function and invoking data.frame that is only defined inside that function? This worked in the previous versions of Zelig, and works with non-zelig commands. Here's a barebones example:
my.function <- function(the.data){
lcl.data <- subset(the.data,select=c(dv,iv))
reg <- lm(dv~ iv,data=lcl.data) #this works fine
zelig.reg <- zelig(dv~ iv,data=lcl.data,model="ls") #this gives error
}
The lm regression works, but no zelig model seems to be able to use the lcl.data. I get the same error message triggered by invoking a data.frame that does not exist:
Error in multi.dataset(lcl.data) : object 'lcl.data' not found
cz
Cesar Zucco Jr.
Assistant Professor
Political Science Department
Rutgers, The State University of New Jersey
http://fas-polisci.rutgers.edu/zucco/