glm module and multinomial logistic models

2012-12-02
2012-12-03
  • Jack Tanner

    Jack Tanner - 2012-12-02

    My multinomial logistic model is written something like this.

    1) How can I check if this model makes use of the efficient samplers in the glm module?

    2) If it does not, is there a way to rewrite this model in JAGS to takes advantage of the glm module?

    # K is number of categories
    # o is index of observations
    # exp.eta is the exponentiated linear component of a GLM
    # pr is the probability of the observation generating a response in category k
    # y is the observed response
    for (k in 1:K) {
      exp.eta[o,k] <- exp(inprod(X[o,],beta))
      pr[o,k] <- exp.eta[o,k] / sum(exp.eta[o,1:K])
    }
    y[o] ~ dcat(pr[o,1:K])
    
     
  • Martyn Plummer

    Martyn Plummer - 2012-12-03

    Well this is annoying. I just typed out a long and detailed reply but the forum software just deleted it. Sorry, but this means you get the short version.

    See The BUGS book, section 7.2.4 "Multinomial and Poisson regression equivalence". Create a matrix of indicator variables z where z[o,k] is 1 if y[o] == k and 0 otherwise. Model z[o,k] as independent Poisson variables with a stratum-specific intercept alpha[o] in the linear predictor that has a diffuse normal prior.

     
  • Martyn Plummer

    Martyn Plummer - 2012-12-03

    Also, note that your original model creates a flat likelihood because exp.eta[o,k] is the same for k in 1...K. You want the right-hand side to depend on k.

    exp.eta[o,k] <- exp(inprod(X[o,],beta[k,]))
    

    and you need to impose an identifiability constraint like beta[1,p] <- 0 for p in 1:P.

     
    Last edit: Martyn Plummer 2012-12-03
  • Martyn Plummer

    Martyn Plummer - 2012-12-03

    Finally, use list.samplers() in the rjags package to see what samplers you are using.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks