plot_slopes
plot_slopes
Functions
Name | Description |
---|---|
plot_slopes | Plot slopes on the y-axis against values of one or more predictors (x-axis, colors/shapes, and facets). |
plot_slopes
plot_slopes.plot_slopes(
model,=None,
condition=None,
variables=None,
newdata='dydx',
slope=True,
vcov=0.95,
conf_level=False,
by=None,
wts=True,
draw=0.0001,
eps=None,
eps_vcov )
Plot slopes on the y-axis against values of one or more predictors (x-axis, colors/shapes, and facets).
The by
argument is used to plot marginal slopes, that is, slopes made on the original data, but averaged by subgroups. This is analogous to using the by
argument in the slopes()
function.
The condition
argument is used to plot conditional slopes, that is, slopes made on a user-specified grid. This is analogous to using the newdata
argument and datagrid()
function in a slopes()
call.
All unspecified variables are held at their mean or mode. This includes grouping variables in mixed-effects models, so analysts who fit such models may want to specify the groups of interest using the variables
argument, or supply model-specific arguments to compute population-level estimates. See details below.
See the “Plots” vignette and website for tutorials and information on how to customize plots: - https://marginaleffects.com/articles/plot.html - https://marginaleffects.com
Parameters
Name | Type | Description | Default |
---|---|---|---|
model | object | Model object. | required |
variables | (str, list, dictionary) | Name of the variable whose marginal effect (slope) we want to plot on the y-axis. Refer to the comparisons() documentation. |
None |
condition | (str, list, dictionary) | Max length : 4. 1: x-axis. 2: color. 3: facet (wrap if no fourth variable, otherwise cols of grid). 4: facet (rows of grid). list : Names of the predictors to display Numeric variables in position 1 is summarized by 100 numbers Numeric variables in positions 2 and 3 are summarized by Tukey’s five numbers dictionary : Keys correspond to predictors. Values are numeric vectors. - Series of lists of the same type as the original variable. - Numeric variables: - Series or list of numeric values. - String: “minmax”, “threenum”, “fivenum”. | None |
by | (bool, str, list) | Max length : 3. 1: x-axis. 2: color. 3: facets. Names of the categorical predictors to marginalize across. | False |
newdata | dataframe | When newdata is NULL, the grid is determined by the condition argument. When newdata is not NULL, the argument behaves in the same way as in the predictions() function. | None |
wts | None |
||
draw | True returns a matplotlib plot. False returns a dataframe of the underlying data. | True |