arviz_plots.plot_lm

Contents

arviz_plots.plot_lm#

arviz_plots.plot_lm(dt, x=None, y=None, y_obs=None, plot_dim=None, smooth=True, filter_vars=None, group='posterior_predictive', coords=None, sample_dims=None, ci_kind=None, ci_prob=None, point_estimate=None, plot_collection=None, backend=None, labeller=None, aes_by_visuals=None, visuals=None, stats=None, **pc_kwargs)[source]#

Posterior predictive and mean plots for regression-like data.

Parameters:
dtxarray.DataTree

Input data

xstr optional

Independent variable. If None, use the first variable in group. Data will be taken from the constant_data group unless the group argument is “predictions” in which case it is taken from the predictions_constant_data group.

ystr optional

Response variable or linear term. If None, use the first variable in observed_data group.

y_obsstr or xarray.DataArray, optional

Observed response variable. If None, use y.

plot_dimstr, optional

Dimension to be represented as the x axis. Defaults to the first dimension in the data for x. It should be present in the data for y too.

smoothbool, default True

If True, apply a Savitzky-Golay filter to smooth the lines.

filter_vars: {None, “like”, “regex”}, default None

If None (default), interpret var_names as the real variables names. If “like”, interpret var_names as substrings of the real variables names. If “regex”, interpret var_names as regular expressions on the real variables names. It is used for any of y, x, y_pred, and x_pred if they are strings or lists of strings.

groupstr, default “posterior_predictive”

Group to use for plotting.

coordsmapping, optional

Coordinates to use for plotting.

sample_dimsiterable, optional

Dimensions to reduce unless mapped to an aesthetic. Defaults to rcParams["data.sample_dims"]

ci_kind{“hdi”, “eti”}, optional

Which credible interval to use. Defaults to rcParams["stats.ci_kind"]

ci_probfloat or array_like of floats, optional

Indicates the probabilities that should be contained within the plotted credible intervals. Defaults to rcParams["stats.ci_prob"]

point_estimate{“mean”, “median”,”mode”}, optional

Which point_estimate to use for the line. Defaults to rcParams["stats.point_estimate"]

plot_collectionPlotCollection, optional
backend{“matplotlib”, “bokeh”}, optional
labellerlabeller, optional
aes_by_visualsmapping, optional

Mapping of visuals to aesthetics that should use their mapping in plot_collection when plotted. Valid keys are the same as for visuals. By default, there are no aesthetic mappings at all

visualsmapping of {strmapping or bool}, optional

Valid keys are:

  • pe_line-> passed to line_xy.

    Represents the mean, median, or mode of the predictions, E(y|x), or of the linear predictor, E(η|x).

  • ci_band -> passed to fill_between_y.

    Represents a credible interval for E(y|x) or E(η|x).

  • ci_bounds -> passed to line_xy. Defaults to False

    Represents the upper and lower bounds of a credible interval for E(y|x) or E(η|x). This is similar to ci_band, but uses lines for the boundaries instead of a filled area.

  • ci_line_y -> passed to ci_line_y. Defaults to False

    This is intended for categorical x values or discrete variables with few unique values of x for which ci_band or ci_bounds do not work well.

  • observed_scatter -> passed to scatter_xy.

    Represents the observed data points.

  • xlabel -> passed to labelled_x.

  • ylabel -> passed to labelled_y.

statsmapping, optional

Valid keys are:

  • credible_interval -> passed to eti or hdi

  • point_estimate -> passed to mean, median or mode

**pc_kwargs

Passed to arviz_plots.PlotCollection.wrap

Returns:
PlotMatrix