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
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/
I see now Zelig 4.20 is in beta. Does it handle results based on multiply
imputed data correctly? That is, does it output the combined results (as in
Zelig 3) instead of a set of individual results (as in early version of
Zelig 4)?
Best,
Shige
Hi Matt, (cc Zelig List)
After a long time, I'm writing to you again... concerning to the same
issue. Just recalling: I needed to use weights in a mlogit model. By the
time Zelig's multinomial function was that one from "Multinomial" package.
I was trying to implement mlogit function from VGAM (vglm) into Zelig
through zelig2. But my dead line was close... so I gave up trying to figure
out how to do that at that time.
It seems now Zelig uses exactly the function from VGAM. And vglm allows
weights. So I runned two mlogit models. See below:
###########################################
library(Zelig)
library(ZeligChoice)
z.out1 = zelig(as.factor(vote88)~pristr + othcok, model="mlogit",
data=mexico)
z.out2 = zelig(as.factor(vote88)~pristr + othcok, model="mlogit",
weights=~age,data=mexico) #age is being used as weights just for the sake
of example
summary(z.out1)
summary(z.out2)
###########################################
The results of the two model are exactly the same. In other words, the
weights are not working. Am I getting something wrong?
thanks for you attention and help,
best regards,
----
Rogério Jerônimo Barbosa
Sociology PhD Student at USP - São Paulo, Brazil
Researcher at Center for Metropolitan Studies (Cem/Cebrap)
On Mon, Sep 17, 2012 at 4:21 PM, Matt Owen <mowen(a)iq.harvard.edu> wrote:
> Can you give a particular example of what you are trying to accomplish?
>
> I ran the following (as a test) with no issue:
>
> library(Zelig)
> data(mexico)
> zelig(as.factor(vote88) ~ pristr + othcok + othsocok, model = "mlogit",
> weights = 1:10, data = mexico[1:10, ])
>
> On Sep 17, 2012, at 11:25 AM, Rogério Barbosa wrote:
>
> Hey Matt,
>
> Is it possible to use Zelig2 to implement vglm, as I was trying to do? If
> yes, how can it be done?
>
> Best,
> R.
>
> On Mon, Sep 17, 2012 at 12:03 PM, Matt Owen <mowen(a)iq.harvard.edu> wrote:
>
>> Zelig's "mlogit" currently does not support the weights parameter. This
>> has been added as a feature request here:
>> https://github.com/zeligdev/ZeligMultinomial/issues/1
>>
>>
>> On Sep 17, 2012, at 10:54 AM, Rogério Barbosa wrote:
>>
>> Hi,
>>
>> I'm trying to run a weighted multinomial logistic -- but "mlogit" family
>> doesn't allow weights... I tryed to implement an external function from
>> VGAM package not multinomial() -- which seems to be the Zelig's built-in;
>> but vglm() ] using Zelig2... But I'm couldn't make it work.
>>
>> Is there any other way to use weights in a mlogit?
>>
>> thanks,
>> Rogério J. Barbosa
>> Researcher at Centre for Metropolitan Studies/Cebrap
>> São Paulo - Brazil -
>> --
>> 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
>>
>>
>>
>
>
Hello,
I've been trying to use de model Ei.RxC of the zelig model, but it gives me an error:
> data(Weimar)
> z.out <- zelig(cbind(Nazi, Government, Communists, FarRight, Other) ~ shareunemployed + shareblue + sharewhite + shareself + sharedomestic, model = "ei.RxC", data = Weimar)
** The model "ei.RxC" is not available with the currently loaded packages,
** and is not an official Zelig package.
** The model's name may be a typo.
Error in get(zelig2, mode = "function") :
object 'zelig2ei.RxC' of mode 'function' was not found
I've recently upgraded the R program to the 3.0.1 version and I installed the latest Zelig package (Version: 4.1-3)
Could you tell me why this is happening?
Is it posible that this model is not in the new upgrade?
Thank you!
Anna
I have just installed Zelig and made my way through the tutorial up to
demo(vertci) which is not included in the list of installed Zelig demos:
Demos in package ‘Zelig’:
Zelig.HelloWorld Step-by-step demo on creating Zelig packages
exp Exponential regression and simulation
factor.bayes MCMC factor analysis
gamma Gamma regression and simulation
gamma.gee GEE gamma regression
gamma.survey Survey-Weighted Poisson Regression for Positive
Continuous Dependent Variables
logit Logit regression and simulation
logit.bayes MCMC logistic regression model and simulation
logit.gee GEE logistic regression
logit.survey Survey-Weighted Logistic Regression for
Dichotomous Dependent Variables
lognorm Lognormal regression and simulation
ls Least Squares regression and simulation
mi Multiply imputed regressions and simulations
mlogit.bayes MCMC multinomial regression model and
simulation
negbinom Negative Binomial regression and simulation
normal Normal (Gaussian) regression and simulation
normal.bayes MCMC regression model and simulation
normal.gee GEE normal regression
normal.survey Survey-Weighted Normal Regression for
Continuous Dependent Variables
oprobit.bayes MCMC ordered probit regression model and
simulation
poisson Poisson regression and simulation
poisson.bayes MCMC poisson regression model and simulation
poisson.gee GEE poisson regression
poisson.survey Survey-Weighted Poisson Regression for
Event-count Dependent Variables
probit Probit regression and simulation
probit.bayes MCMC probit regression model and simulation
probit.gee GEE probit regression
probit.survey Survey-Weighted Probit Regression for
Dichotomous Dependent Variables
relogit Rare events logit regression and simulation
twosls Two Stage Least Squares
Demos in package ‘zoo’:
zoo-overplot Plot time series in black with certain regions
in red.
How can I obtain demo(vertci)?
tnx, thomas
Thomas Brown, PhD
Assistant Professor of Criminal Justice & Sociology
Virginia Wesleyan College
1584 Wesleyan Drive
Norfolk, VA 23502
tel. 757-233-8780
email: tbrown(a)vwc.edu
Dear All,
Zelig 4 no longer seems to handle predict() and fitted() as it used to, and as other R packages do.
In short, given a zelig output object (say "zelig.reg"), it seems that it is necessary to invoke predict and/fitted on zelig.reg$result or zelig.reg[[1]] , and not on zelig.reg. And the behavior of functions is not consistent across different models, at least not across "ls" and "logit". A self contained example follows below.
1 - Can the default method for these functions be changed to behave as before (i.e. to accept predict(zelig.reg) and fitted(zelig.reg)?
2 - Can the behavior of predict() and fitted() be made consistent across models?
#I'm running:
#R version 3.0.0 (2013-04-03)
#Platform: x86_64-apple-darwin10.8.0 (64-bit)
#Running Zelig_4.1-3
data(npk, package="MASS") #load data
### Extracting fitted and predicted values from linear and logit regressions *not* using Zelig, all this works well:
lm.reg <- lm(yield~N+P+K, data=npk)
predict(lm.reg)
fitted(lm.reg)
logit.reg <- glm(N~yield+P, data=npk, family=binomial(link="logit"))
predict(logit.reg)
fitted(logit.reg)
### Extracting fitted and predcited values from linear and logit regressions using Zelig
lm.zelig <- zelig(yield~N+P+K, data=npk,model="ls",cite=F)
predict(lm.zelig) # does not work
predict(lm.zelig[[1]]) #this "sort"of works, but spits back only 10 observations
predict(lm.zelig$result) #this does not work in "ls", but does work below in "logit"
predict(lm.zelig$result,newdata=lm.zelig$data) #this seems to work, but is not convenient...
fitted(lm.zelig) # does not work, but in the linear case does not matter
fitted(lm.zelig$result,newdata=lm.zelig$data) #this seems to work, but is not convenient...
logit.zelig <- zelig(N~yield+P, data=npk, model="logit",cite=F)
predict(logit.zelig) # does not work
predict(logit.zelig$result) #this works, but is inconvenient
predict(logit.zelig$result,newdata=logit.zelig$data)
fitted(logit.zelig$result) #this seems to work in "logit", but does not work in "lm"
Thank you,
cz
Cesar Zucco Jr.
Assistant Professor
Political Science Department
Rutgers, The State University of New Jersey
http://fas-polisci.rutgers.edu/zucco/
Hi Ista,
I tried to use R --vanilla but unfortunately it didn't work either.
Here's the output:
> summary(z.out)
Error in is.null(subset) : 'subset' is missing
> class(z.out)
[1] "ls" "ls-mi" "MI"
> getAnywhere(summary.MI)
A single object matching ‘summary.MI’ was found
It was found in the following places
registered S3 method for summary from namespace Zelig
namespace:Zelig
with value
function (object, subset, ...)
{
if (length(object) == 0)
stop("Invalid input for \"subset\"")
else if (length(object) == 1)
return(summary(object[[1]]))
getcoef <- function(x) {
obj <- x$result
if (!isS4(obj))
coef(obj)
else if ("coef3" %in% slotNames(obj))
obj@coef3
else obj@coef
}
res <- list()
subset <- if (is.null(subset))
1:length(object)
else c(subset)
for (k in subset) res[[k]] <- summary(object[[k]])
ans <- list()
ans$zelig <- object[[1]]$name
ans$call <- object[[1]]$call
ans$all <- res
coef1 <- se1 <- NULL
for (k in subset) {
}
}
<environment: namespace:Zelig>
Moreover, when I type 'summary(z.out,subset=1:length(z.out))' nothing
happens. It does not show any output.
I will re-install R and the those packages as well.
Once again, thanks for your help,
Danilo Freire