easystats / easystats/performance

check_collinearity does not work on a brms model with sampled priors

Open
#454 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug :bug:
Dominant language
R
Stars
1.2k
Forks
109
Avg merge
6h 34m
Merged PRs (30d)
8

Description

Hi there,

The check_collinearity function returns a vcov error after passing it a brms model obtained with argument sample_prior = "yes". I checked the help page on check_collinearity, and tested whether vcov works with that model (and it does). Here's a reproducible example:

require(performance)
require(brms)

data("epilepsy")
woprior <- brm(count~Trt*visit + zAge + zBase,
              family = "poisson",
              data = epilepsy,
              seed = 1) 
wiprior <- brm(count~Trt*visit + zAge + zBase,
           family = "poisson",
           sample_prior = "yes",
           data = epilepsy,
           seed = 1)

#check_collinearity throws a vcov error for the second model
check_collinearity(woprior)
check_collinearity(wiprior)

#but vcov works on both models
vcov(woprior)
vcov(wiprior)

The error is:

check_collinearity(wiprior)
Error in stats::vcov(x)[params, params, drop = FALSE] : 
  subscript out of bounds

The only prior being sampled here is the intercept (brms doesn't sample unspecified, improper coefficient priors).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reproducible brms example from the issue and compare check_collinearity(woprior) with check_collinearity(wiprior), using vcov output as the reference. Trace the check_collinearity entry point and identify why sampled prior parameters are included in the indexing; done means the sampled-prior model no longer raises a subscript-out-of-bounds error while the non-prior model still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.