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/
Hello,
I am trying to run a multilevel probit model using Zelig, but keep receiving
the following error message: " in .deparseTag(TT.vars[[vind]]) : wrong use
of tag function!!"
A simplified version of the model I am trying to run is:
z.out <- zelig(formula= list(mu=investment.binary ~ edlevel +
tag(1 + edlevel, gamma | country),
gamma = ~ tag(GDPpc06.full| country)), data=data2006.mod1,
model="probit.mixed")
What I would like to do is allow the intercept and the edlevel variable
listed within the first tag() to vary by country as a function of the
GDPpc06.full variable, all of which are included in the same dataframe. I
followed the syntax here - http://cran.r-project.org/web/packages/Zelig
/vignettes/probit.mixed.pdf - but I think that I am incorrectly specifying
the gamma part of the syntax, which may be causing the error.
I *am* able to get the model to run when I allow the intercept and edlevel
variable to vary using the following syntax:
z.out <- zelig(investment.binary ~ edlevel +
+ tag(1 + edlevel | country),
data=data2006.mod1, model="probit.mixed")
However, this syntax does not allow me to specify that the intercept and
edlevel variable should vary as a function of GDPpc06.full, as in the first
model specified above. I have tried including multiple tags at the
non-group level of the model specification - i.e. one for the intercept and
one for the edlevel variable - but this does not seem to work either.
Do you have any suggestions for how to fix the syntax?
Sincerely,
Jason
--
Jason I. McMann
PhD Student | Department of Politics
Princeton University | jmcmann(a)princeton.edu
Hi Audrey,
Ah, sorry, I read your example too quickly. The imputations from amelia()
now follow the new Zelig requirements for named lists, but this example does
not. Here's a updated example that should work:
z.out <- zelig(as.factor(ipip) ~ wage1992 + prtyid + ideol,
+ model = "ologit",
+ data = mi(imp1=immi1, imp2=immi2, imp3=immi3, imp4=immi4, imp5=immi5))
Thus, you simply need to add names to each item of the mi() list. I'm not
sure if the mi() class should require names, but this code should work
either way.
Cheers,
matt.
2011/8/21 Audrey Sacks <sacks(a)u.washington.edu>
> Dear Matt,
>
> Thanks for your response. The same error still shows up after I install
> the newer version of Amelia as you suggest below.
>
> Here's my sessioninfo and codes
>
> Thanks,
> Audrey
>
>
> R version 2.13.1 (2011-07-08)
> Copyright (C) 2011 The R Foundation for Statistical Computing
> ISBN 3-900051-07-0
>
> Platform: i386-pc-mingw32/i386 (32-bit)
>
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type 'license()' or 'licence()' for distribution details.
>
> Natural language support but running in an English locale
>
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
>
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for an HTML browser interface to help.
> Type 'q()' to quit R.
>
>
> install.packages("Amelia", repos = "http://r.iq.harvard.edu", type =
>> "source")
>>
> Installing package(s) into ‘C:/Users/Audrey/Desktop/**
> Documents/R/win-library/2.13’
> (as ‘lib’ is unspecified)
> trying URL 'http://r.iq.harvard.edu/src/**contrib/Amelia_1.5-4.tar.gz<http://r.iq.harvard.edu/src/contrib/Amelia_1.5-4.tar.gz>
> '
> Content type 'application/x-gzip' length 1078553 bytes (1.0 Mb)
> opened URL
> downloaded 1.0 Mb
>
> * installing *source* package 'Amelia' ...
> ** R
> ** data
> ** inst
> ** preparing package for lazy loading
> ** help
> *** installing help indices
> ** building package indices ...
> ** testing if installed package can be loaded
> ## ## Amelia II: Multiple Imputation
> ## (Version 1.5-4, built: 2011-08-21)
>
> ## Copyright (C) 2005-2011 James Honaker, Gary King and Matthew Blackwell
> ## Refer to http://gking.harvard.edu/**amelia/<http://gking.harvard.edu/amelia/>for more information
> ##
>
> * DONE (Amelia)
>
> The downloaded packages are in
> ‘C:\Users\Audrey\AppData\**Local\Temp\RtmpRzvM0Y\**
> downloaded_packages’
>
>
>> library(Zelig)
>>
> Loading required package: MASS
> Loading required package: boot
> Loading required package: MNP
> MNP: R Package for Fitting the Multinomial Probit Model
> Version: 2.6-2
> ## ## Zelig (Version 3.5-1, built: 2011-03-25)
> ## Please refer to http://gking.harvard.edu/zelig for full
> ## documentation or help.zelig() for help with commands and
> ## models supported by Zelig.
> ##
>
> ## Zelig project citations:
> ## Kosuke Imai, Gary King, and Olivia Lau. (2009).
> ## ``Zelig: Everyone's Statistical Software,''
> ## http://gking.harvard.edu/zelig**.
> ## and
> ## Kosuke Imai, Gary King, and Olivia Lau. (2008).
> ## ``Toward A Common Framework for Statistical Analysis
> ## and Development,'' Journal of Computational and
> ## Graphical Statistics, Vol. 17, No. 4 (December)
> ## pp. 892-913.
>
> ## To cite individual Zelig models, please use the citation format printed
> with
> ## each model run and in the documentation.
> ##
> Warning message:
> '.readRDS' is deprecated.
> Use 'readRDS' instead.
> See help("Deprecated")
>
>> library(Amelia)
>>
> Loading required package: foreign
> ## ## Amelia II: Multiple Imputation
> ## (Version 1.5-4, built: 2011-08-21)
>
> ## Copyright (C) 2005-2011 James Honaker, Gary King and Matthew Blackwell
> ## Refer to http://gking.harvard.edu/**amelia/<http://gking.harvard.edu/amelia/>for more information
> ##
>
>> data(turnout)
>>
>> data(immi1, immi2, immi3, immi4, immi5)
>> z.out <- zelig(as.factor(ipip) ~ wage1992 + prtyid + ideol,
>>
> + model = "ologit",
> + data = mi(immi1, immi2, immi3, immi4, immi5))
> Error in attach(data) : all elements of a list must be named
>
>
>
>
Hi,
After updating to R 2.13.1 and updating Zelig to 3.5-1, the following error
appears when I try to use the mi() command in Zelig. I ran the exact same code
in R 2.8 and it worked fine.
Error in attach(data) : all elements of a list must be named
Any ideas? Complete code and SessionInfo is below:
Thank you,
Audrey
library(Zelig)
Loading required package: MASS
Loading required package: boot
Loading required package: MNP
MNP: R Package for Fitting the Multinomial Probit Model
Version: 2.6-2
##
## Zelig (Version 3.5-1, built: 2011-03-25)
## Please refer to http://gking.harvard.edu/zelig for full
## documentation or help.zelig() for help with commands and
## models supported by Zelig.
##
## Zelig project citations:
## Kosuke Imai, Gary King, and Olivia Lau. (2009).
## ``Zelig: Everyone's Statistical Software,''
## http://gking.harvard.edu/zelig.
## and
## Kosuke Imai, Gary King, and Olivia Lau. (2008).
## ``Toward A Common Framework for Statistical Analysis
## and Development,'' Journal of Computational and
## Graphical Statistics, Vol. 17, No. 4 (December)
## pp. 892-913.
## To cite individual Zelig models, please use the citation format printed
with
## each model run and in the documentation.
##
Warning message:
'.readRDS' is deprecated.
Use 'readRDS' instead.
See help("Deprecated")
> library(Amelia)
Loading required package: foreign
##
## Amelia II: Multiple Imputation
## (Version 1.2-18, built: 2010-11-04)
## Copyright (C) 2005-2011 James Honaker, Gary King and Matthew Blackwell
## Refer to http://gking.harvard.edu/amelia/ for more information
##
> sessionInfo()
R version 2.13.1 (2011-07-08)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Amelia_1.2-18 foreign_0.8-45 Zelig_3.5-1 MNP_2.6-2 boot_1.3-2
[6] MASS_7.3-14
> data(turnout)
> data(immi1, immi2, immi3, immi4, immi5)
> z.out <- zelig(as.factor(ipip) ~ wage1992 + prtyid + ideol,
+ model = "ologit",
+ data = mi(immi1, immi2, immi3, immi4, immi5))
Error in attach(data) : all elements of a list must be named
-
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/
Dear Everyone,
I have attempted to run some multinomial logit models with mixed
results with the Zelig package.
I very much baffled with the fact that what ran about two weeks ago on
the same computer, is not working any longer. Neither are course
examples that also ran on the computer. The only alteration that
happened was I downloaded R Studio, although was NOT using it to run my
models in the end.
I would appreciate if anyone has an idea what went wrong...!
Thank you and kind regards,
Zsofia Ignacz
Complete syntax:
baseyear <- zelig(as.factor(chair) ~ v5+v8+v67+fHU+fCZ+fEG+fw32+fw33,
model="mlogit", data=isjp2)
summary (baseyear)
hypHU91 <- setx(baseyear, v5=1, v8=50, v67=4, fHU=1, fCZ=0, fEG=0,
fw32=1, fw33=0)
hypCZ91 <- setx(baseyear, v5=1, v8=50, v67=4, fHU=0, fCZ=1, fEG=0,
fw32=0, fw33=0)
hypEG91 <- setx(baseyear, v5=1, v8=50, v67=4, fHU=0, fCZ=0, fEG=1,
fw32=0, fw33=0)
hypWG91 <- setx(baseyear, v5=1, v8=50, v67=4, fHU=0, fCZ=0, fEG=0,
fw32=0, fw33=0)
hypprobHU91 <- sim(baseyear, x=hypHU91 , num=1500)
###Error message: "Error in UseMethod("cov") : no applicable method for
'vcov' applied to an object of class "c('vglm', 'vlm', 'vlmsmall')"
--
Zsófia Ignácz
PhD Student
Berlin Graduate School of Social Sciences
European PhD for Social-economic and Social Statistics
Institut für Sozialwissenschaften
Humboldt Universität zu Berlin
Unter den Linden 6
D 10099 Berlin
Office: Luisenstrasse 56, Room 208, 10177 Berlin
zsofia.ignacz(a)sowi.hu-berlin.de
-
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/
Dear all,
I ran a poisson model on 5 multiply imputed datasets produced by amelia:
z.out <- zelig(months ~ netsize, model="poisson", data=a.out$imputations)
I can get the 95% CI of each imputation's coefficients using
confint(z.out[[n]]$coefficients), where n is the imputed dataset index.
What I want however is the 95% CI of the combined results.
Sorry, I couldn't find an answer in the documentation.
Lloyd
Hi everyone,
I am trying to simulate expected probabilities for a logistic model, but I
get a strange error message when running sim().
Since I am using a data frame from the 'car' package by J. Fox, the code can
be easily reproduced by everyone.
Here is the code I am running:
library(car)
library(Zelig)
data(Chile)
Chile$vote.d <- recode(Chile$vote, "'N'=0; 'Y'=1; else=NA")
model3.z <- zelig(vote.d ~ region + sex + population + age + education +
income + statusquo,
model="logit", data=Chile)
summary(model3.z)
x.out1 <- setx(model3.z, sex="M", education="PS")
summary(x.out1)
s.out1 <- sim(x.out1, x = x.out1)
The last command returns the following error message:
Error in UseMethod("vcov") :
no applicable method for 'vcov' applied to an object of class "data.frame"
I have tried to google this message, but I found only a few results, and
none of them was useful for understanding where the problem is. Note that,
until the last command, I do not get errors or warnings from any of the
previous functions. demo(logit) does not return any errors.
Thanks in advance for your help.
Mattia
--------------------------
(Mr.) Mattia Guidi
Ph.D Candidate
European University Institute
Department of Political and Social Sciences
Badia Fiesolana
Via dei Roccettini 9
I-50014 San Domenico di Fiesole (FI)
ITALY
Hi,
I'm trying to load my data into R.
This is the command I'm using:
FinalData2.data <- read.csv('FinalData2.csv')
attach(FinalData2.data)
this is the error I get:
FinalData2.data <- read.csv('FinalData2.csv')
Error in type.convert(data[[i]], as.is = as.is[i], dec = dec, na.strings =
character(0L)) :
invalid multibyte string at '<ff>'
> attach(FinalData2.data)
Error in attach(FinalData2.data) : object 'FinalData2.data' not found
My working directory is set as this:
setwd("/Users/Sera/Desktop/R Work")
I don't understand why I'm getting this error.
I also tried this, but I still get errors:
FinalData2.csv <- read.csv(Users/Sera/Desktop/R Work/FinalData2.csv)
Error: unexpected symbol in "FinalData2.csv <- read.csv(Users/Sera/Desktop/R
Work"
> + attach(FinalData2.data)
Error in attach(FinalData2.data) : object 'FinalData2.data' not found
Sorry to bug you guys.
Thanks for your help.
Sera
Hi,
I just downloaded R onto my Mac. I was able to successfully download Amelia,
but not successful with downloading Zelig.
I think I have to create a library. I followed the commands to create one,
but I keep getting errors.. I only want to run R commands.
here is the first error I got:
> install.packages("Zelig", repos="http://r.iq.harvard.edu/", type="source")
Installing package(s) into ‘/Users/Sera/Library/R/2.13/library’
(as ‘lib’ is unspecified)
Warning: dependency ‘MNP’ is not available
trying URL 'http://r.iq.harvard.edu/src/contrib/Zelig_3.5-1.tar.gz'
Content type 'application/x-gzip' length 14407206 bytes (13.7 Mb)
opened URL
==================================================
downloaded 13.7 Mb
ERROR: dependency ‘MNP’ is not available for package ‘Zelig’
* removing ‘/Users/Sera/Library/R/2.13/library/Zelig’
The downloaded packages are in
‘/private/var/folders/na/nal9eab8GYO6s7zuPcRYMk+++TI/-Tmp-/RtmpWFnWZW/downloaded_packages’
Warning message:
In install.packages("Zelig", repos = "http://r.iq.harvard.edu/", :
installation of package 'Zelig' had non-zero exit status
library(Zelig)
> library(Zelig)
Error in library(Zelig) : there is no package called 'Zelig'
Please help...
Thank you,
Sera
Dear all,
I have a general question on the simulation technique developed in Zelig,
and available for estimating first differences and expected values of the
dependent variable for different quantities of interest of the independent
variables. It is not completely clear to me to what extent simulation
techniques are more suitable for this purpose than the simple computation of
predicted values (or probabilities). I understand the *logical* difference
between algebraic computation of effects, and the simulation of them. But
expected and predicted values are practically the same for the same model,
although derived with different methods. My question, then, is: is it only a
question of *methodological elegance* or are there strong theoretical
reasons for which we should prefer simulations over the computation of
predicted values/probabilities? And, are there statistical models for which
only simulations can be meaningfully used?
Thanks a lot in advance for your answers.
Mattia
--------------------------
(Mr.) Mattia Guidi
Ph.D Candidate
European University Institute
Department of Political and Social Sciences
Badia Fiesolana
Via dei Roccettini 9
I-50014 San Domenico di Fiesole (FI)
ITALY