easystats / easystats/performance
Issues with check_model() for Stan models
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 1.2k
- Forks
- 109
- Avg merge
- 6h 34m
- Merged PRs (30d)
- 8
Description
I'm not exactly what the thinking is behind the current behavior of check_model() for Stan models. It calls the internal function performance:::.check_assumptions_stan(). This returns a data frame with columns Group (Prior or Posterior), y (parameter), x (value), and id (posterior draw).
I'm not exactly sure what sort of plot this is intended to be used for (perhaps a scatterplot matrix for the various parameters across posterior draws?). Could someone elaborate? @strengejacke @mattansb? Nevertheless, it is really different from the results for lm/glm models, where a list with the various diagnostic data frames is returned. This produces several problems:
-
see::plot.see_check_model()fails forcheck_model(stan_model)objects- This function expects to find the names of plots in a list (QQ, VIF, etc.). It errors when given the single data frame from
performance:::.check_assumptions_stan().
- This function expects to find the names of plots in a list (QQ, VIF, etc.). It errors when given the single data frame from
-
There is no way for users to generate the typical regression model diagnositic plots, such as fitted-residual plots, qq plots, etc.
-
The current
performance:::.check_assumptions_stan()function fails often forbrmsfitmodels- If
sample_priors = "no"(default), it stops. It could instead return a data frame with just the posterior. - If improper priors are used (default), the reshaping fails. It should be robust to the non-sampled priors.
- If
This leads to 2 big questions:
-
What should
check_model()do for Stan models?- My preference would be for it to return the same sort of plots as for lm/glm objects.
- Could you describe what sort of plot was intended with the current output? Could we implement that as a different function (similar to
pp_check())?
-
What should we do in the mean time?
- My suggestion would be to internally call
bayestestR::convert_bayesian_as_frequentist(), then callcheck_model()on that. I think this would be an okay stopgap until we implement the individual plots for stan objects.
- My suggestion would be to internally call
Thoughts?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading check_model() and performance:::.check_assumptions_stan(), then inspect see::plot.see_check_model() to understand the incompatible data shape. Review the described lm/glm behavior and brmsfit failure cases before proposing the intended Stan diagnostics. Done requires an agreed design and compatible behavior for Stan models, including the stated prior-sampling cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- analytics
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100