vdorie / blme

Bayesian Linear Mixed Effect Models
41 stars 8 forks source link

Format for fixed effects prior in blme::bglmer() when more than one fixed effects #8

Closed Es-aqua closed 5 years ago

Es-aqua commented 5 years ago

Hi,

I would like to use a fixed effects prior in blme::bglmer() for one of my covariates showing complete separation, following the guidelines of a previous post: Binomial glmm with a categorical variable with full successes. However, in my case, there is an additional covariate, not showing complete separation. Below is an overview of my dataset. ID identifies each observed fish, haul identifies each sampled haul (on a fishing vessel, with several fish from the same haul), death is my response variable with 2 levels (mortality at asymptote, 0 for survival and 1 for dead), R1 and R2 are my covariates each with 2 levels (reflex for each fish, 0 when reflex present and 1 when reflex absent):

ID   haul death R1 R2
2704    9     1  1  1
2705   14     1  1  0
2715   13     1  1  1
2718   13     1  1  0
2719    8     1  1  0
2722    9     1  1  1
...

Let's say that R1 is the covariate with complete separation for which I would like to add a fixed effects prior. My model would therefore be as follow:

bglmer(death ~ R1 + (1|haul) + (1|ID), data=RAMP_Subset, family=binomial, fixef.prior = normal(cov = diag(9,2)))

Now let's say that my second covariate R2 does not show complete separation. The reference manual for the R package "blme" states that priors on the fixed effects are specified in a fashion similar to that of covariance priors, so I tried the following:

bglmer(death ~ R1 + R2 + (1|haul) + (1|ID), data=RAMP_Subset, family=binomial, fixef.prior = R1 ~ normal(cov = diag(9,2)))

However, my attempt received an error message:

Error in evaluateFixefPrior(fixefPrior, defnEnv, evalEnv) : unrecognized fixef distribution: '~'

I could not find any other example online, and would be very grateful for advice on proper formatting.

Thanks, Esther

vdorie commented 5 years ago

Hi Esther,

With the commit I just pushed you should be able to put a prior with infinite covariance on the effects you don't want to penalize, for example fixef.prior = normal(sd = c(3, 3, Inf)). With previous versions, I had only implemented that feature for t priors.