There's a mismatch between betas, variable names, and covariates when there's a fixed effect.
When there is a fixed effect, the function constructs a model matrix, taking the first level of dataset[, fixed_fx] as the intercept. So the first level needs to be removed when renaming the MCMC samples, otherwise it throws an error.
Also, the way the model matrix is constructed, it can only deal with a single fixed variable:
covs <- model.matrix(~factor(dataset[, fixed_fx]))
So the apply(data.frame(dataset[, fixed_fx], 2, function(x) sort(unique(x))) when renaming the MCMC samples can be simplified.
So I'd say that part
colnames(cres)[grepl("betas", colnames(cres))] <-
c("Intercept", unlist(apply(data.frame(dataset[, fixed_fx]), 2, function(x) sort(unique(x)))), cont_cov)
should be replaced with
colnames(cres)[grepl("betas", colnames(cres))] <-
c("Intercept", sort(unique(dataset[, fixed_fx]))[-1], cont_cov)
I'll try to submit a pull request
There's a mismatch between betas, variable names, and covariates when there's a fixed effect.
When there is a fixed effect, the function constructs a model matrix, taking the first level of
dataset[, fixed_fx]as the intercept. So the first level needs to be removed when renaming the MCMC samples, otherwise it throws an error.Also, the way the model matrix is constructed, it can only deal with a single fixed variable:
So the
apply(data.frame(dataset[, fixed_fx], 2, function(x) sort(unique(x)))when renaming the MCMC samples can be simplified.So I'd say that part
should be replaced with
I'll try to submit a pull request