interpret.slopes
interpret.slopes(
model,
idata,
wrt,
conditional=None,
average_by=None,
eps=0.0001,
slope='dydx',
use_hdi=True,
prob=None,
transforms=None,
sample_new_groups=False,
)Compute Conditional Adjusted Slopes
Parameters
model :bambi.Model-
The model for which we want to plot the predictions.
idata :arviz.InferenceData-
The InferenceData object that contains the samples from the posterior distribution of the model.
wrt : (str, dict)-
The slope of the regression with respect to (wrt) this predictor will be computed.
conditional : (str, list, dict) = None-
The covariates we would like to condition on. If dict, keys are the covariate names and values are the values to condition on.
average_by : str | list | bool | None = None-
The covariates we would like to average by. The passed covariate(s) will marginalize over the other covariates in the model. If True, it averages over all covariates in the model to obtain the average estimate. Defaults to
None. eps : float = 0.0001-
To compute the slope, ‘wrt’ is evaluated at wrt +/- ‘eps’. The rate of change is then computed as the difference between the two values divided by ‘eps’. Defaults to 1e-4.
slope : str = 'dydx'-
The type of slope to compute. Defaults to ‘dydx’. ‘dydx’ represents a unit increase in ‘wrt’ is associated with an n-unit change in the response. ‘eyex’ represents a percentage increase in ‘wrt’ is associated with an n-percent change in the response. ‘eydx’ represents a unit increase in ‘wrt’ is associated with an n-percent change in the response. ‘dyex’ represents a percent change in ‘wrt’ is associated with a unit increase in the response.
use_hdi : bool = True-
Whether to compute the highest density interval (defaults to True) or the quantiles.
prob : float = None-
The probability for the credibility intervals. Must be between 0 and 1. Defaults to 0.94. Changing the global variable
az.rcParams["stats.ci_prob"]affects this default. transforms : dict = None-
Transformations that are applied to each of the variables being plotted. The keys are the name of the variables, and the values are functions to be applied. Defaults to
None. sample_new_groups : bool = False-
If the model contains group-level effects, and data is passed for unseen groups, whether to sample from the new groups. Defaults to
False.
Returns
:pd.DataFrame-
A dataframe with the comparison values, highest density interval,
wrtname, contrast value, and conditional values.
Raises
: ValueError-
If length of
wrtis greater than 1. IfconditionalisNoneandwrtis passed more than 2 values. IfconditionalisNoneand defaultwrthas more than 2 unique values. Ifconditionalis a list and the length is greater than 3. Ifslopeis not ‘dydx’, ‘dyex’, ‘eyex’, or ‘eydx’. Ifprobis not > 0 and < 1.