Hi all,
I have been working on implementing the polya-gamma logistic regression sampler for (possibly) multinomial observations. I am using the stick-breaking representation the multinomial distribution as discussed
in this paper:
The polya-gamma part of the sampler seems to work fine, but I am getting the following (rather uninformative) error message about the regression coefficient sampler when I try to compile the MCMC:
> ## Build and compile MCMC
> mcmc <- buildMCMC(mcmcConf)
> cmcmc <- compileNimble(mcmc, project = model, showCompilerOutput = TRUE)
Compiling
[Note] This may take a minute.
[Note] On some systems there may be some compiler warnings that can be safely ignored.
Error in exists(as.character(varOrNodeExpr), x, inherits = FALSE) :
first argument has length > 1
The sampler appears to work with uncompiled using the uncompiled MCMC.
I have attached my code here, which contains four different files:
- conjugate_logit_model.R - the main R file to compile the model and MCMC
- polyaGammaRNG.R - the R file to sample from the polya-gamma distribution
- pg_logit_conjugate_samplers.R - the R file that contains the samplers for the multinomial logistic regression model
- pg_logit_helper_funs.R - contains helper functions (e.g., computation of probabilities based on stick-breaking probabilities)
The first file contains a reproducible example using a real data set. The only thing that needs to be changed is the directory at the beginning of the script.
Thanks in advance!
Best,
Ethan