[R] MCMClogit: Cannot calculate marginal likelihood with improper prior

ba0728 haleybeck at att.net
Mon Jul 29 03:00:24 CEST 2013

I'm an undergrad who is new to MCMCpack and I haven't been able to find an
answer to my problem online yet: I'm attempting to run MCMClogit with a
Cauchy proper prior but I'm getting the warning "Cannot calculate marginal
likelihood with improper prior" (my purposes require the marginal likelihood
calculation so I understand that I need to use a proper prior).

I'm trying to simulate the "user-defined independent Cauchy prior with
additional args" as specified in the MCMCpack User Manual (p. 76, April 2013
version). My input data has been standardized  (mean = 0, sd = 0.5 for
non-binary variables, and binary variables with mean of 0 and difference of
1 between upper and lower ends) according to the Gelman 2008 paper on
logistic regression

When I run the example data set (birthwt) from the User Manual, the
logpriorfun works correctly allowing the marginal likelihood to be
generated. However, when I try running my data with the logprior fun, I get
a warning that the prior is improper. Here is the code I am running:

*logpriorfun = function(beta, location,scale){
  sum(dcauchy(beta, location, scale, log = TRUE))

*> MCMC.2= MCMClogit(DEAD ~ YEARS + MALE + x1 + x2 + x3+ x4 +x5 + x6 + x7 +
x8 + x9, tune= 0.65,burnin =500, mcmc=5000, data = dat, marginal.likelihood
= "Laplace", user.prior.density=logpriorfun, logfun=TRUE, location = 0,

The Metropolis acceptance rate was 0.27418
Warning message:
In MCMClogit(DEAD ~ YEARS + MALE + x1 + x2 + x3 +  :
  Cannot calculate marginal likelihood with improper prior*

Any advice on how to fix my arguments so it is a proper prior and will allow
me to generate a marginal likelihood using the Laplace approximation? Or how
should I be coding a Cauchy proper prior? I'm having problems defining the

Thanks, B.

View this message in context: http://r.789695.n4.nabble.com/MCMClogit-Cannot-calculate-marginal-likelihood-with-improper-prior-tp4672561.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list