Dear Zeligists,
I am trying to use Zelig to estimate mixed-effects logit models and am
encountering an error message that I can't understand. Apparently, Zelig
isn't "seeing" my data set, but other modeling commands in R are seeing it
fine. I'm sure I'm overlooking something obvious and apologize in advance
for wasting your time, but I would really appreciate it if you could help me
fix the problem.
Here is the workspace image in text form from the session. As you can see, R
is seeing the data and estimating a GLM with no trouble. But when I use
Zelig, I get the 'undefined columns selected' message. I saw a few threads
in the listserv archives that covered the same message, but none of them
seemed to apply to a case where the data set was already a data frame
recognized by R.
Thanks in advance,
Jay
R version 2.10.1 (2009-12-14)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
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.
# Analysis of Democratic Survival
# Merge 21, All Non-OECD Democratic Episodes
# Jay Ulfelder (SAIC)
# July 2010
# Load requisite packages
library(foreign)
library(Zelig)
Loading required package: MASS
Loading required package: boot
##
## Zelig (Version 3.4-8, built: 2010-01-20)
## 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.
##
# Load and attach data from current directory
demdat <- read.dta("RGJ All Non-OECD M21 Analysis File.dta")
dim(demdat)
[1] 1447 78
save(demdat, file="demdat.RData")
rm(demdat)
load("demdat.RData")
attach(demdat)
table(rgjtaut1)
rgjtaut1
0 1
1390 57
table(first)
first
0 1
867 580
rgjdurdl <- log(rgjdurd)
xxxcimrl <- log(xxxcimr)
base <- glm(rgjtaut1 ~ rgjdurdl + xxxcimrl + rgjaltp + first + postcw +
fhsciv,
+ data = demdat, family=binomial)
summary(base)
Call:
glm(formula = rgjtaut1 ~ rgjdurdl + xxxcimrl + rgjaltp + first +
postcw + fhsciv, family = binomial, data = demdat)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.2745 -0.2895 -0.2070 -0.1343 3.0262
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -7.1637 0.9179 -7.804 5.98e-15 ***
rgjdurdl 0.3788 0.1997 1.897 0.0578 .
xxxcimrl 0.4293 0.2257 1.902 0.0572 .
rgjaltp 0.8690 0.4082 2.129 0.0333 *
first 0.2230 0.3001 0.743 0.4573
postcw -0.4540 0.3524 -1.288 0.1976
fhsciv 0.8635 0.1516 5.695 1.24e-08 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 464.75 on 1410 degrees of freedom
Residual deviance: 396.83 on 1404 degrees of freedom
(36 observations deleted due to missingness)
AIC: 410.83
Number of Fisher Scoring iterations: 7
# Adding random Intercepts for countries
basez <- zelig(y ~ rgjdurdl + xxxcimrl + rgjaltp + first + postcw + fhsciv
+
tag(1 | sftgcode),
+ data = demdat, model="logit.mixed")
Loading required package: Matrix
Loading required package: lattice
Attaching package: 'lattice'
The following object(s) are masked from package:boot :
melanoma
Attaching package: 'Matrix'
The following object(s) are masked from package:base :
det
Attaching package: 'lme4'
The following object(s) are masked from package:stats :
AIC
Error in `[.data.frame`(d, , all.vars(as.expression(formula))) :
undefined columns selected
--
Jay Ulfelder, Ph.D.
Research Director
Political Instability Task Force
Science Applications International Corp. (SAIC)
jay_ulfelder(a)stanfordalumni.org
(301) 588-8478 [home office]
(301) 580-8736 [mobile]