Good morning,
I am using Zelig to run an relogit model in R (version 2.13.1), but I am running into an
error for which I have not found a solution in your archives. Please find below the R
syntax
library(Zelig)
library(foreign)
mhd <-
read.dta("E:/7390/Paper/Data/MH8JCR05.dta")
# When I run glm and MCMClogit models, I am able to estimate my models, so I know R is
reading the data:
MHR <- glm(mhd$onset ~ mhd$L_PC_PRODUCTION,
family=binomial(link="logit"))
summary(MHR)
Call:
glm(formula = mhd$onset ~ mhd$L_PC_PRODUCTION, family = binomial(link =
"logit"))
Deviance Residuals:
Min 1Q Median 3Q Max
-0.1864 -0.1862 -0.1862 -0.1848 3.0293
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -4.0458 0.1123 -36.016 <2e-16 ***
mhd$L_PC_PRODUCTION -3.3181 2.5385 -1.307 0.191
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05
'.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 869.16 on 5236 degrees of freedom
Residual deviance: 864.88 on 5235 degrees of freedom
(32 observations deleted due to missingness)
AIC: 868.88
Number of Fisher Scoring iterations: 9
FIprior <- function(beta, location, scale){
+
sum(dcauchy(beta, location, scale, log=TRUE))
+ }
MH1 <- MCMClogit(mhd$onset ~ mhd$L_PC_PRODUCTION,
data = mhd, burnin = 500,
+ mcmc = 1000,user.prior.density =
FIprior, logfun = TRUE,
+ seed = 1234, location = 0, scale = 2.5)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The Metropolis acceptance rate was 0.41133
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
summary(MH1)
Iterations = 501:1500
Thinning interval = 1
Number of chains = 1
Sample size per chain = 1000
1. Empirical mean and standard deviation for each variable,
plus standard error of the mean:
Mean SD Naive SE Time-series SE
(Intercept) -4.026 0.1116 0.003528 0.01203
mhd$L_PC_PRODUCTION -2.993 2.1950 0.069413 0.24653
2. Quantiles for each variable:
2.5% 25% 50% 75% 97.5%
(Intercept) -4.236 -4.100 -4.020 -3.943 -3.8330
mhd$L_PC_PRODUCTION -8.746 -3.903 -2.334 -1.469 -0.2813
However, when I run the Zelig relogit model, I get the error below -
MH1 <- zelig(mhd$onset ~ mhd$L_PC_PRODUCTION, data
= mhd, model = "relogit",
+ tau = 88/5269, case.control =
"weighting", robust = TRUE)
Error in `[.data.frame`(d, , all.vars(as.expression(formula))) :
undefined columns selected
Could you please help with resolving this error?
Thank you,
Alero