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, xlabeller=None, ylabeller=None, aes_by_visuals=None, visuals=None, stats=None, **pc_kwargs)[source]#
Posterior predictive and mean plots for regression-like data.
- Parameters:
- dt
xarray.DataTree Input data
- x
stror sequence ofstr, 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.
The plots and visuals in the generated
PlotCollectionobject will use x for naming.- y
stror sequence ofstr, optional Response variable or linear term. If None, use the first variable in observed_data group.
- y_obs
strorxarray.DataArray, optional Observed response variable. If None, use y.
- plot_dim
str, 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.
- group
str, 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_prob
floator array_like offloat, 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_collection
PlotCollection, optional - backend{“matplotlib”, “bokeh”}, optional
- xlabeller, ylabeller
labeller, optional Labeller for the x and y axes. Will use the make_label_vert method of the labeller. By default, xlabeller is a
BaseLabellerand ylabeller is aMapLabellerthat maps values of x to their respective y value given the first ones are used to name things in thePlotCollection.- aes_by_visualsmapping, optional
Mapping of visuals to aesthetics that should use their mapping in
plot_collectionwhen plotted. Valid keys are the same as forvisuals.By default, the color is mapped to the variable which is active for the “ci_band” visual. If ci_prob is not a scalar a mapping from prob->alpha is also added which is active for “ci_band” and “ci_vlines” visuals.
- visualsmapping of {
strmapping or bool}, optional Valid keys are:
pe_line-> passed to
line_xy.Line that represent 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.Filled area that represents a credible interval for E(y|x) or E(η|x).
ci_bounds -> passed to
line_xy. Defaults to FalseLines that represent 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_vlines -> passed to
ci_line_y. Defaults to FalseThis 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. Represents the same information as these two visuals but as multiple vertical lines, similar to
plot_ppc_intervalobserved_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. Affects all 3 visual elements related to the credible intervals
pe_line -> passed to mean, median or mode
smooth -> passed to
scipy.signal.savgol_filter. It also takes an extran_pointskey to control the number of points in the interpolation grid that is passed to the smoothing filter. Affects the 4 visual elements related to credible intervals or point estimates.
- **pc_kwargs
Passed to
arviz_plots.PlotCollection.wrap
- dt
- Returns: