Skip to content

add plot_lm #317

@OriolAbril

Description

@OriolAbril

Add a simplified version of plot_lm in current ArviZ. I think to start we could limit ourselves to something with 3 elements only: CI band, mean line and observation scatter. For example the plot from this section https://bambinos.github.io/bambi/notebooks/distributional_models.html#constant-alpha (adding link in addition to copy of the image so you have code to generate data like that to test the function, it might not match all the assumptions below though but it has the data and reorganizing it should be easier than generating it I think):

Image

We need to access potentially 4 different data elements:

  • observations for target variable. It should be in idata.observed_data
  • observations for independent variable. It should be in idata.constant_data in general, but I think we could try allowing string/list (access from constant data) or dataarray/dataset to use directly.
  • predictions/posterior predictive. I think as default we can get the same variables there are in observed_data group from the posterior_predictive group. I would restrict this to string/list only. But we might want to allow posterior_predictive/y/predictions/y to allow indicating which groups holds the data we want to plot. We'd then compute the point estimate and credible interval according to rcParams
    • open question: cc @aloctavodia do we want to integrate smoothing here? or support smoothing only if done manually and then pre-computed summaries are provided via stats dict?
  • independent variable data for ci/mean. I think this should be optional and default to the observations for independent variable, but it should be possible to change. One automatic change in default could be when using data from predictions group, get data with same same as independent variable observations but from predictions_constant_data instead. And like the observation analog, it should also allow dataarray/dataset.

I would start allowing to generate only one plot in the figure. After that we can discuss how to incorporate faceting/mappings to that for multiple outcomes, multiple covariates, both at the same time?

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions