# interpret.slopes()

Compute conditional adjusted slopes.

Usage

[Source](https://github.com/bambinos/bambi/blob/main/bambi/interpret/effects.py#L877-L1000)

``` python
interpret.slopes(
    model,
    idata,
    wrt,
    conditional=None,
    average_by=None,
    eps=0.0001,
    slope="dydx",
    target="mean",
    use_hdi=True,
    prob=az.rcParams["stats.ci_prob"],
    transforms=None,
    sample_new_groups=None,
)
```

Slopes are computed using finite differences. The wrt variable is evaluated at \[x, x + eps\] and the slope is approximated as (f(x + eps) - f(x)) / eps.

## Parameters

`model: Model`  
The fitted Bambi model.

`idata: DataTree`  
DataTree object containing the posterior samples.

`wrt: str or dict`  
The predictor variable to compute the slope with respect to. Either a variable name (uses mean/mode as evaluation point) or a single-entry dict mapping variable name to a specific evaluation point.

`conditional: str, list[str], dict[str, ConditionalValues], or None = None`  
Variables to condition on for slopes.

`average_by: (str, list or None) = None`  
Variables to average slopes over.

`eps: float = 0.0001`  
Perturbation size for finite differencing. Default is 1e-4.

`slope: str or Callable[[DataArray, DataArray, DataArray], DataArray] = "dydx"`  
Slope function or string name. Built-in options: "dydx" (unit/unit), "eyex" (percent/percent), "eydx" (percent/unit), "dyex" (unit/percent). Default is "dydx". Custom functions should accept (derivative, x, y) DataArrays and return a DataArray.

`target: str = "mean"`  
Which quantity to extract. `"mean"` (default) for the posterior of the parent parameter (e.g. `"mu"`). Pass the response variable name (e.g. `"mpg"`) for posterior predictive samples. Pass a distributional component name (e.g. `"sigma"`) for the posterior of that component.

`use_hdi: bool = True`  
Whether to use highest density interval. Default is True.

`prob: float or list[float] or None = az.rcParams["stats.ci_prob"]`  
Probability or list of probabilities for credible intervals. Default is from arviz rcParams. When a list is provided, multiple nested intervals are computed. Pass None to omit credible intervals.

`transforms: dict or None = None`  
Dictionary of transformations to apply to predictions before differencing.

`sample_new_groups: bool or None = None`  
Deprecated and has no effect. Bambi automatically determines how to predict for new groups based on the type of group. Default is None.

## Returns

`Result`  
A named tuple with `.summary` (DataFrame of summary statistics) and `.draws` (DataTree of raw posterior draws).

## Raises

`ValueError`  
If any prob value is not between 0 and 1.

`TypeError`  
If slope is not a callable or valid string.
