|
1 | | -#' @section comparison argument functions: |
2 | | -#' |
3 | | -#' The following transformations can be applied by supplying one of the shortcut strings to the |
4 | | -#' `comparison` argument. |
5 | | - |
6 | | -#' `hi` is a vector of adjusted predictions for the "high" side of the |
7 | | -#' contrast. `lo` is a vector of adjusted predictions for the "low" side of the |
8 | | -#' contrast. `y` is a vector of adjusted predictions for the original data. `x` |
9 | | -#' is the predictor in the original data. `eps` is the step size to use to |
10 | | -#' compute derivatives and elasticities. |
| 1 | +#' @section Comparison functions: |
| 2 | +#' |
| 3 | +#' Each of the quantities computed by `comparisons()` can be defined as a function of these quantities: |
| 4 | +#' |
| 5 | +#' - `hi`: vector of predictions for the "high" side of the contrast. |
| 6 | +#' - `lo`: vector of predictions for the "low" side of the contrast. |
| 7 | +#' - `y`: predictions for the original data. |
| 8 | +#' - `x`: focal predictor in the original data. |
| 9 | +#' - `w`: weights |
| 10 | +#' |
| 11 | +#' For example, the "lift" of a binary predictor is a popular quantity of |
| 12 | +#' interest, defined as the difference between predictions when the focal |
| 13 | +#' predictor \eqn{X = 1}, and predictions when the focal predictor is |
| 14 | +#' \eqn{X = 0}, normalized by the starting point. Or: |
| 15 | +#' |
| 16 | +#' \eqn{\frac{\hat{Y}_{X=1} - \hat{Y}_{X=0}}{\hat{Y}_{X=0}}} |
| 17 | +#' |
| 18 | +#' When, the argument is set to `comparison="lift"`, `marginaleffects` will compute the quantity using this function: |
| 19 | +#' |
| 20 | +#' `function(hi, lo) { (hi - lo) / lo }` |
| 21 | +#' |
| 22 | +#' Users can supply custom functions to the `comparison` argument, or use one of the many shortcuts available for common quantities of interest: |
11 | 23 | #' |
12 | 24 | #' ```{r, echo = FALSE, results = "asis"} |
13 | 25 | #' k <- marginaleffects:::comparison_function_dict |
|
0 commit comments