I am trying to estimate a Bayesian logistic model with with a weakly informative Cauchy prior with location=0 and scale=2.5 (Gelman et al, 2008). I am using MCMClogit
in the MCMCpack
package:
df = read.csv("http://dl.dropbox.com/u/1791181/MCMC.csv")#Read in data
library(MCMCpack)
logpriorfun <- function(beta, location, scale){
sum(dcauchy(beta, location, scale, log=T))
} #From the MCMCpack documentation
mcmc.logit = MCMClogit(SECONDARY.LEVEL ~ AGE + SEX + as.factor(DISTRICT),
tune=.25,
user.prior.density=logpriorfun, location=0, scale=2.5, log=T,
mcmc=10000,
data=df)
But I keep getting the error message below:
Error in MCMClogit(SECONDARY.LEVEL ~ AGE + SEX + as.factor(DISTRICT), :
REAL() can only be applied to a 'numeric', not a 'NULL'
I can't see any obvious problem with either the code or the data. The code runs fine if I take out the prior option. I would appreciate any pointers.