From 9ab9430f3df150b0d9b96b28b17408e23b7c41aa Mon Sep 17 00:00:00 2001 From: Vincent Arel-Bundock Date: Sat, 16 Sep 2023 08:22:04 -0400 Subject: [PATCH] docs --- book/articles/reference/comparisons.qmd | 41 +++++++++--------- book/articles/reference/datagrid.qmd | 22 +++++----- book/articles/reference/hypotheses.qmd | 44 ++++++++++++++------ book/articles/reference/inferences.qmd | 16 +++---- book/articles/reference/marginal_means.qmd | 32 +++++++------- book/articles/reference/plot_comparisons.qmd | 33 ++++++++------- book/articles/reference/plot_predictions.qmd | 28 ++++++------- book/articles/reference/plot_slopes.qmd | 31 +++++++------- book/articles/reference/posterior_draws.qmd | 4 +- book/articles/reference/predictions.qmd | 35 +++++++++------- book/articles/reference/slopes.qmd | 35 +++++++++------- 11 files changed, 178 insertions(+), 143 deletions(-) diff --git a/book/articles/reference/comparisons.qmd b/book/articles/reference/comparisons.qmd index 34173128d..820eb1624 100644 --- a/book/articles/reference/comparisons.qmd +++ b/book/articles/reference/comparisons.qmd @@ -83,11 +83,11 @@ avg_comparisons( ## Arguments - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +
model
model

Model object

newdata
newdata

Grid of predictor values at which we evaluate the comparisons.

@@ -139,7 +139,7 @@ avg_comparisons(
variables
variables

Focal variables

@@ -242,7 +242,7 @@ avg_comparisons(
comparison
comparison

How should pairs of predictions be compared? Difference, ratio, odds ratio, or user-defined functions.

@@ -270,7 +270,7 @@ avg_comparisons(
type
type

string indicates the type (scale) of the predictions used to compute contrasts or slopes. This can differ based on the model @@ -279,7 +279,7 @@ or "zero". When an unsupported string is entered, the model-specific l acceptable values is returned in an error message. When type is NULL, the first entry in the error message is used by default.

vcov
vcov

Type of uncertainty estimates to report (e.g., for robust standard errors). Acceptable values:

@@ -319,7 +319,7 @@ first entry in the error message is used by default.

by
by

Aggregate unit-level estimates (aka, marginalize, average over). Valid inputs:

@@ -339,17 +339,20 @@ first entry in the error message is used by default.

  • See examples below.

    +
  • +
  • For more complex aggregations, you can use the FUN argument of the hypotheses() function. See that function's documentation and the Hypothesis Test vignettes on the marginaleffects website. +

  • conf_level
    conf_level

    numeric value between 0 and 1. Confidence level to use to build a confidence interval.

    transform
    transform

    string or function. Transformation applied to unit-level estimates and confidence intervals just before the function returns results. Functions must accept a vector and return a vector of the same length. Support string shortcuts: "exp", "ln"

    cross
    cross
      @@ -360,7 +363,7 @@ first entry in the error message is used by default.

    wts
    wts

    string or numeric: weights to use when computing average contrasts or slopes. These weights only affect the averaging in ⁠avg_*()⁠ or with the by argument, and not the unit-level estimates themselves. Internally, estimates and weights are passed to the weighted.mean() function.

    @@ -373,7 +376,7 @@ first entry in the error message is used by default.

    hypothesis
    hypothesis

    specify a hypothesis test or custom contrast using a numeric value, vector, or matrix, a string, or a string formula.

    @@ -434,19 +437,19 @@ first entry in the error message is used by default.

    equivalence
    equivalence

    Numeric vector of length 2: bounds used for the two-one-sided test (TOST) of equivalence, and for the non-inferiority and non-superiority tests. See Details section below.

    p_adjust
    p_adjust

    Adjust p-values for multiple comparisons: "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", or "fdr". See stats::p.adjust

    df
    df

    Degrees of freedom used to compute p values and confidence intervals. A single numeric value between 1 and Inf. When df is Inf, the normal distribution is used. When df is finite, the t distribution is used. See insight::get_df for a convenient function to extract degrees of freedom. Ex: slopes(model, df = insight::get_df(model))

    eps
    eps

    NULL or numeric value which determines the step size to use when calculating numerical derivatives: (f(x+eps)-f(x))/eps. When eps is @@ -455,7 +458,7 @@ the maximum and minimum values of the variable with respect to which we are taking the derivative. Changing eps may be necessary to avoid numerical problems in certain models.

    numderiv
    numderiv

    string or list of strings indicating the method to use to for the numeric differentiation used in to compute delta method standard errors.

    @@ -474,7 +477,7 @@ numerical problems in certain models.

    ...
    ...

    Additional arguments are passed to the predict() method supplied by the modeling package.These arguments are particularly useful @@ -939,7 +942,7 @@ comparisons( # Second, we use that SD as the treatment size in the `variables` argument library(dplyr) mod <- lm(mpg ~ hp + factor(cyl), mtcars) -tmp <- mtcars %>% +tmp <- mtcars %>% group_by(cyl) %>% mutate(hp_sd = sd(hp)) avg_comparisons(mod, variables = list(hp = tmp$hp_sd), by = "cyl") diff --git a/book/articles/reference/datagrid.qmd b/book/articles/reference/datagrid.qmd index 55b449e5f..ea67e9920 100644 --- a/book/articles/reference/datagrid.qmd +++ b/book/articles/reference/datagrid.qmd @@ -40,7 +40,7 @@ datagridcf(..., model = NULL, newdata = NULL) ## Arguments - + - + - + - + - + - + - + - + - + - + - +
    ...
    ...

    named arguments with vectors of values or functions for user-specified variables.

    @@ -54,43 +54,43 @@ datagridcf(..., model = NULL, newdata = NULL)

    model
    model

    Model object

    newdata
    newdata

    data.frame (one and only one of the model and newdata arguments can be used.)

    by
    by

    character vector with grouping variables within which ⁠FUN_*⁠ functions are applied to create "sub-grids" with unspecified variables.

    FUN_character
    FUN_character

    the function to be applied to character variables.

    FUN_factor
    FUN_factor

    the function to be applied to factor variables.

    FUN_logical
    FUN_logical

    the function to be applied to logical variables.

    FUN_numeric
    FUN_numeric

    the function to be applied to numeric variables.

    FUN_integer
    FUN_integer

    the function to be applied to integer variables.

    FUN_other
    FUN_other

    the function to be applied to other variable types.

    grid_type
    grid_type

    character

    diff --git a/book/articles/reference/hypotheses.qmd b/book/articles/reference/hypotheses.qmd index 6104074d5..5091728fb 100644 --- a/book/articles/reference/hypotheses.qmd +++ b/book/articles/reference/hypotheses.qmd @@ -47,11 +47,11 @@ package website, or scroll down this page for a full list of vignettes: ## Arguments - + - + - + - + - + - + - + - + - + - + - +
    model
    model

    Model object or object generated by the comparisons(), slopes(), predictions(), or marginal_means() functions.

    hypothesis
    hypothesis

    specify a hypothesis test or custom contrast using a numeric value, vector, or matrix, a string, or a string formula.

    @@ -112,7 +112,7 @@ package website, or scroll down this page for a full list of vignettes:

    vcov
    vcov

    Type of uncertainty estimates to report (e.g., for robust standard errors). Acceptable values:

    @@ -152,19 +152,19 @@ package website, or scroll down this page for a full list of vignettes:

    conf_level
    conf_level

    numeric value between 0 and 1. Confidence level to use to build a confidence interval.

    df
    df

    Degrees of freedom used to compute p values and confidence intervals. A single numeric value between 1 and Inf. When df is Inf, the normal distribution is used. When df is finite, the t distribution is used. See insight::get_df for a convenient function to extract degrees of freedom. Ex: slopes(model, df = insight::get_df(model))

    equivalence
    equivalence

    Numeric vector of length 2: bounds used for the two-one-sided test (TOST) of equivalence, and for the non-inferiority and non-superiority tests. See Details section below.

    joint
    joint

    Joint test of statistical significance. The null hypothesis value can be set using the hypothesis argument.

    @@ -186,11 +186,11 @@ package website, or scroll down this page for a full list of vignettes:

    joint_test
    joint_test

    A character string specifying the type of test, either "f" or "chisq". The null hypothesis is set by the hypothesis argument, with default null equal to 0 for all parameters.

    FUN
    FUN

    NULL or function.

    @@ -199,11 +199,11 @@ package website, or scroll down this page for a full list of vignettes:
  • NULL (default): hypothesis test on a model's coefficients, or on the quantities estimated by one of the marginaleffects package functions.

  • -
  • Function which accepts a model object and returns a numeric vector or a data.frame with two columns called term and estimate. This argument can be useful when users want to conduct a hypothesis test on an arbitrary function of quantities held in a model object. +

  • Function which accepts a model object and returns a numeric vector or a data.frame with two columns called term and estimate. This argument can be useful when users want to conduct a hypothesis test on an arbitrary function of quantities held in a model object. See examples below.

  • numderiv
    numderiv

    string or list of strings indicating the method to use to for the numeric differentiation used in to compute delta method standard errors.

    @@ -222,7 +222,7 @@ package website, or scroll down this page for a full list of vignettes:

    ...
    ...

    Additional arguments are passed to the predict() method supplied by the modeling package.These arguments are particularly useful @@ -352,6 +352,26 @@ f <- function(x) predict(x, type = "response", newdata = mtcars) p <- hypotheses(mod, FUN = f) head(p) +# Complex aggregation +# Step 1: Collapse predicted probabilities by outcome level, for each individual +# Step 2: Take the mean of the collapsed probabilities by group and `cyl` +library(dplyr) +library(MASS) +library(dplyr) + +dat <- transform(mtcars, gear = factor(gear)) +mod <- polr(gear ~ factor(cyl) + hp, dat) + +aggregation_fun <- function(model) { + predictions(model, vcov = FALSE) |> + mutate(group = ifelse(group %in% c("3", "4"), "3 & 4", "5")) |> + summarize(estimate = sum(estimate), .by = c("rowid", "cyl", "group")) |> + summarize(estimate = mean(estimate), .by = c("cyl", "group")) |> + rename(term = cyl) +} + +hypotheses(mod, FUN = aggregation_fun) + # Equivalence, non-inferiority, and non-superiority tests mod <- lm(mpg ~ hp + factor(gear), data = mtcars) p <- predictions(mod, newdata = "median") diff --git a/book/articles/reference/inferences.qmd b/book/articles/reference/inferences.qmd index db160489f..9e6c8642b 100644 --- a/book/articles/reference/inferences.qmd +++ b/book/articles/reference/inferences.qmd @@ -28,11 +28,11 @@ ## Arguments - + - + - + - + - + - + - + - +
    x
    x

    Object produced by one of the core marginaleffects functions.

    method
    method

    String

    @@ -63,11 +63,11 @@

    R
    R

    Number of resamples, simulations, or cross-validation folds.

    conf_type
    conf_type

    String: type of bootstrap interval to construct.

    @@ -86,15 +86,15 @@

    conformal_test
    conformal_test

    Data frame of test data for conformal prediction.

    conformal_calibration
    conformal_calibration

    Data frame of calibration data for split conformal prediction (⁠method="conformal_split⁠).

    conformal_score
    conformal_score

    String. Warning: The type argument in predictions() must generate predictions which are on the same scale as the outcome variable. Typically, this means that type must be "response" or "probs".

    @@ -107,7 +107,7 @@

    ...
    ...
      diff --git a/book/articles/reference/marginal_means.qmd b/book/articles/reference/marginal_means.qmd index 05f3654e1..9f27ff15f 100644 --- a/book/articles/reference/marginal_means.qmd +++ b/book/articles/reference/marginal_means.qmd @@ -45,11 +45,11 @@ package website, or scroll down this page for a full list of vignettes: ## Arguments - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +
      model
      model

      Model object

      variables
      variables

      Focal variables

      @@ -62,7 +62,7 @@ package website, or scroll down this page for a full list of vignettes:

      newdata
      newdata

      Grid of predictor values over which we marginalize.

      @@ -81,7 +81,7 @@ package website, or scroll down this page for a full list of vignettes:

      vcov
      vcov

      Type of uncertainty estimates to report (e.g., for robust standard errors). Acceptable values:

      @@ -121,11 +121,11 @@ package website, or scroll down this page for a full list of vignettes:

      conf_level
      conf_level

      numeric value between 0 and 1. Confidence level to use to build a confidence interval.

      type
      type

      string indicates the type (scale) of the predictions used to compute marginal effects or contrasts. This can differ based on the model @@ -134,11 +134,11 @@ or "zero". When an unsupported string is entered, the model-specific l acceptable values is returned in an error message. When type is NULL, the first entry in the error message is used by default.

      transform
      transform

      A function applied to unit-level adjusted predictions and confidence intervals just before the function returns results. For bayesian models, this function is applied to individual draws from the posterior distribution, before computing summaries.

      cross
      cross

      TRUE or FALSE

      @@ -151,7 +151,7 @@ first entry in the error message is used by default.

      hypothesis
      hypothesis

      specify a hypothesis test or custom contrast using a numeric value, vector, or matrix, a string, or a string formula.

      @@ -212,19 +212,19 @@ first entry in the error message is used by default.

      equivalence
      equivalence

      Numeric vector of length 2: bounds used for the two-one-sided test (TOST) of equivalence, and for the non-inferiority and non-superiority tests. See Details section below.

      p_adjust
      p_adjust

      Adjust p-values for multiple comparisons: "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", or "fdr". See stats::p.adjust

      df
      df

      Degrees of freedom used to compute p values and confidence intervals. A single numeric value between 1 and Inf. When df is Inf, the normal distribution is used. When df is finite, the t distribution is used. See insight::get_df for a convenient function to extract degrees of freedom. Ex: slopes(model, df = insight::get_df(model))

      wts
      wts

      character value. Weights to use in the averaging.

      @@ -240,11 +240,11 @@ first entry in the error message is used by default.

      by
      by

      Collapse marginal means into categories. Data frame with a by column of group labels, and merging columns shared by newdata or the data frame produced by calling the same function without the by argument.

      numderiv
      numderiv

      string or list of strings indicating the method to use to for the numeric differentiation used in to compute delta method standard errors.

      @@ -263,7 +263,7 @@ first entry in the error message is used by default.

      ...
      ...

      Additional arguments are passed to the predict() method supplied by the modeling package.These arguments are particularly useful diff --git a/book/articles/reference/plot_comparisons.qmd b/book/articles/reference/plot_comparisons.qmd index 22cc8631e..16e289a98 100644 --- a/book/articles/reference/plot_comparisons.qmd +++ b/book/articles/reference/plot_comparisons.qmd @@ -49,15 +49,15 @@ See the "Plots" vignette and website for tutorials and information on ## Arguments - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +
      model
      model

      Model object

      variables
      variables

      Name of the variable whose contrast we want to plot on the y-axis.

      condition
      condition

      Conditional slopes

      @@ -88,7 +88,7 @@ See the "Plots" vignette and website for tutorials and information on

      by
      by

      Aggregate unit-level estimates (aka, marginalize, average over). Valid inputs:

      @@ -108,13 +108,16 @@ See the "Plots" vignette and website for tutorials and information on
    • See examples below.

      +
    • +
    • For more complex aggregations, you can use the FUN argument of the hypotheses() function. See that function's documentation and the Hypothesis Test vignettes on the marginaleffects website. +

    • newdata
      newdata

      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 comparisons() function.

      type
      type

      string indicates the type (scale) of the predictions used to compute contrasts or slopes. This can differ based on the model @@ -123,7 +126,7 @@ or "zero". When an unsupported string is entered, the model-specific l acceptable values is returned in an error message. When type is NULL, the first entry in the error message is used by default.

      vcov
      vcov

      Type of uncertainty estimates to report (e.g., for robust standard errors). Acceptable values:

      @@ -163,11 +166,11 @@ first entry in the error message is used by default.

      conf_level
      conf_level

      numeric value between 0 and 1. Confidence level to use to build a confidence interval.

      wts
      wts

      string or numeric: weights to use when computing average contrasts or slopes. These weights only affect the averaging in ⁠avg_*()⁠ or with the by argument, and not the unit-level estimates themselves. Internally, estimates and weights are passed to the weighted.mean() function.

      @@ -180,7 +183,7 @@ first entry in the error message is used by default.

      comparison
      comparison

      How should pairs of predictions be compared? Difference, ratio, odds ratio, or user-defined functions.

      @@ -208,23 +211,23 @@ first entry in the error message is used by default.

      transform
      transform

      string or function. Transformation applied to unit-level estimates and confidence intervals just before the function returns results. Functions must accept a vector and return a vector of the same length. Support string shortcuts: "exp", "ln"

      rug
      rug

      TRUE displays tick marks on the axes to mark the distribution of raw data.

      gray
      gray

      FALSE grayscale or color plot

      draw
      draw

      TRUE returns a ggplot2 plot. FALSE returns a data.frame of the underlying data.

      ...
      ...

      Additional arguments are passed to the predict() method supplied by the modeling package.These arguments are particularly useful diff --git a/book/articles/reference/plot_predictions.qmd b/book/articles/reference/plot_predictions.qmd index e7e473b4d..8b7bf2fe6 100644 --- a/book/articles/reference/plot_predictions.qmd +++ b/book/articles/reference/plot_predictions.qmd @@ -49,11 +49,11 @@ Plot Conditional or Marginal Predictions ## Arguments - + - + - + - + - + - + - + - + - + - + - + - + - + - +
      model
      model

      Model object

      condition
      condition

      Conditional predictions

      @@ -84,7 +84,7 @@ Plot Conditional or Marginal Predictions

      by
      by

      Marginal predictions

      @@ -97,11 +97,11 @@ Plot Conditional or Marginal Predictions

      newdata
      newdata

      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.

      type
      type

      string indicates the type (scale) of the predictions used to compute contrasts or slopes. This can differ based on the model @@ -110,7 +110,7 @@ or "zero". When an unsupported string is entered, the model-specific l acceptable values is returned in an error message. When type is NULL, the first entry in the error message is used by default.

      vcov
      vcov

      Type of uncertainty estimates to report (e.g., for robust standard errors). Acceptable values:

      @@ -150,11 +150,11 @@ first entry in the error message is used by default.

      conf_level
      conf_level

      numeric value between 0 and 1. Confidence level to use to build a confidence interval.

      wts
      wts

      string or numeric: weights to use when computing average contrasts or slopes. These weights only affect the averaging in ⁠avg_*()⁠ or with the by argument, and not the unit-level estimates themselves. Internally, estimates and weights are passed to the weighted.mean() function.

      @@ -167,27 +167,27 @@ first entry in the error message is used by default.

      transform
      transform

      A function applied to unit-level adjusted predictions and confidence intervals just before the function returns results. For bayesian models, this function is applied to individual draws from the posterior distribution, before computing summaries.

      points
      points

      Number between 0 and 1 which controls the transparency of raw data points. 0 (default) does not display any points.

      rug
      rug

      TRUE displays tick marks on the axes to mark the distribution of raw data.

      gray
      gray

      FALSE grayscale or color plot

      draw
      draw

      TRUE returns a ggplot2 plot. FALSE returns a data.frame of the underlying data.

      ...
      ...

      Additional arguments are passed to the predict() method supplied by the modeling package.These arguments are particularly useful diff --git a/book/articles/reference/plot_slopes.qmd b/book/articles/reference/plot_slopes.qmd index 36a83e911..e2968a367 100644 --- a/book/articles/reference/plot_slopes.qmd +++ b/book/articles/reference/plot_slopes.qmd @@ -48,15 +48,15 @@ See the "Plots" vignette and website for tutorials and information on ## Arguments - + - + - + - + - + - + - + - + - + - + - + - + - + - +
      model
      model

      Model object

      variables
      variables

      Name of the variable whose marginal effect (slope) we want to plot on the y-axis.

      condition
      condition

      Conditional slopes

      @@ -87,7 +87,7 @@ See the "Plots" vignette and website for tutorials and information on

      by
      by

      Aggregate unit-level estimates (aka, marginalize, average over). Valid inputs:

      @@ -107,13 +107,16 @@ See the "Plots" vignette and website for tutorials and information on
    • See examples below.

      +
    • +
    • For more complex aggregations, you can use the FUN argument of the hypotheses() function. See that function's documentation and the Hypothesis Test vignettes on the marginaleffects website. +

    • newdata
      newdata

      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 slopes() function.

      type
      type

      string indicates the type (scale) of the predictions used to compute contrasts or slopes. This can differ based on the model @@ -122,7 +125,7 @@ or "zero". When an unsupported string is entered, the model-specific l acceptable values is returned in an error message. When type is NULL, the first entry in the error message is used by default.

      vcov
      vcov

      Type of uncertainty estimates to report (e.g., for robust standard errors). Acceptable values:

      @@ -162,11 +165,11 @@ first entry in the error message is used by default.

      conf_level
      conf_level

      numeric value between 0 and 1. Confidence level to use to build a confidence interval.

      wts
      wts

      string or numeric: weights to use when computing average contrasts or slopes. These weights only affect the averaging in ⁠avg_*()⁠ or with the by argument, and not the unit-level estimates themselves. Internally, estimates and weights are passed to the weighted.mean() function.

      @@ -179,7 +182,7 @@ first entry in the error message is used by default.

      slope
      slope

      string indicates the type of slope or (semi-)elasticity to compute:

      @@ -201,19 +204,19 @@ first entry in the error message is used by default.

      rug
      rug

      TRUE displays tick marks on the axes to mark the distribution of raw data.

      gray
      gray

      FALSE grayscale or color plot

      draw
      draw

      TRUE returns a ggplot2 plot. FALSE returns a data.frame of the underlying data.

      ...
      ...

      Additional arguments are passed to the predict() method supplied by the modeling package.These arguments are particularly useful diff --git a/book/articles/reference/posterior_draws.qmd b/book/articles/reference/posterior_draws.qmd index b385d84c4..c10ecbbfb 100644 --- a/book/articles/reference/posterior_draws.qmd +++ b/book/articles/reference/posterior_draws.qmd @@ -18,11 +18,11 @@ Extract Posterior Draws or Bootstrap Resamples from marginaleffects ## Arguments - + - +
      x
      x

      An object produced by a marginaleffects package function, such as predictions(), avg_slopes(), hypotheses(), etc.

      shape
      shape

      string indicating the shape of the output format:

      diff --git a/book/articles/reference/predictions.qmd b/book/articles/reference/predictions.qmd index f9e1559ed..623b190f5 100644 --- a/book/articles/reference/predictions.qmd +++ b/book/articles/reference/predictions.qmd @@ -75,11 +75,11 @@ avg_predictions( ## Arguments - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +
      model
      model

      Model object

      newdata
      newdata

      Grid of predictor values at which we evaluate predictions.

      @@ -125,7 +125,7 @@ avg_predictions(
      variables
      variables

      Counterfactual variables.

      @@ -192,7 +192,7 @@ avg_predictions(
      vcov
      vcov

      Type of uncertainty estimates to report (e.g., for robust standard errors). Acceptable values:

      @@ -232,11 +232,11 @@ avg_predictions(

      conf_level
      conf_level

      numeric value between 0 and 1. Confidence level to use to build a confidence interval.

      type
      type

      string indicates the type (scale) of the predictions used to compute contrasts or slopes. This can differ based on the model @@ -245,7 +245,7 @@ or "zero". When an unsupported string is entered, the model-specific l acceptable values is returned in an error message. When type is NULL, the first entry in the error message is used by default.

      by
      by

      Aggregate unit-level estimates (aka, marginalize, average over). Valid inputs:

      @@ -265,9 +265,12 @@ first entry in the error message is used by default.

    • See examples below.

      +
    • +
    • For more complex aggregations, you can use the FUN argument of the hypotheses() function. See that function's documentation and the Hypothesis Test vignettes on the marginaleffects website. +

    • byfun
      byfun

      A function such as mean() or sum() used to aggregate estimates within the subgroups defined by the by argument. NULL uses the @@ -276,7 +279,7 @@ value. This is sometimes used to take the sum or mean of predicted probabilities across outcome or predictor levels. See examples section.

      wts
      wts

      string or numeric: weights to use when computing average contrasts or slopes. These weights only affect the averaging in ⁠avg_*()⁠ or with the by argument, and not the unit-level estimates themselves. Internally, estimates and weights are passed to the weighted.mean() function.

      @@ -289,11 +292,11 @@ levels. See examples section.

      transform
      transform

      A function applied to unit-level adjusted predictions and confidence intervals just before the function returns results. For bayesian models, this function is applied to individual draws from the posterior distribution, before computing summaries.

      hypothesis
      hypothesis

      specify a hypothesis test or custom contrast using a numeric value, vector, or matrix, a string, or a string formula.

      @@ -354,19 +357,19 @@ levels. See examples section.

      equivalence
      equivalence

      Numeric vector of length 2: bounds used for the two-one-sided test (TOST) of equivalence, and for the non-inferiority and non-superiority tests. See Details section below.

      p_adjust
      p_adjust

      Adjust p-values for multiple comparisons: "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", or "fdr". See stats::p.adjust

      df
      df

      Degrees of freedom used to compute p values and confidence intervals. A single numeric value between 1 and Inf. When df is Inf, the normal distribution is used. When df is finite, the t distribution is used. See insight::get_df for a convenient function to extract degrees of freedom. Ex: slopes(model, df = insight::get_df(model))

      numderiv
      numderiv

      string or list of strings indicating the method to use to for the numeric differentiation used in to compute delta method standard errors.

      @@ -385,7 +388,7 @@ levels. See examples section.

      ...
      ...

      Additional arguments are passed to the predict() method supplied by the modeling package.These arguments are particularly useful diff --git a/book/articles/reference/slopes.qmd b/book/articles/reference/slopes.qmd index e4c3b68cb..5f1f9fb1a 100644 --- a/book/articles/reference/slopes.qmd +++ b/book/articles/reference/slopes.qmd @@ -75,11 +75,11 @@ avg_slopes( ## Arguments - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +
      model
      model

      Model object

      newdata
      newdata

      Grid of predictor values at which we evaluate the slopes.

      @@ -125,7 +125,7 @@ avg_slopes(
      variables
      variables

      Focal variables

      @@ -138,7 +138,7 @@ avg_slopes(

      type
      type

      string indicates the type (scale) of the predictions used to compute contrasts or slopes. This can differ based on the model @@ -147,7 +147,7 @@ or "zero". When an unsupported string is entered, the model-specific l acceptable values is returned in an error message. When type is NULL, the first entry in the error message is used by default.

      by
      by

      Aggregate unit-level estimates (aka, marginalize, average over). Valid inputs:

      @@ -167,9 +167,12 @@ first entry in the error message is used by default.

    • See examples below.

      +
    • +
    • For more complex aggregations, you can use the FUN argument of the hypotheses() function. See that function's documentation and the Hypothesis Test vignettes on the marginaleffects website. +

    • vcov
      vcov

      Type of uncertainty estimates to report (e.g., for robust standard errors). Acceptable values:

      @@ -209,11 +212,11 @@ first entry in the error message is used by default.

      conf_level
      conf_level

      numeric value between 0 and 1. Confidence level to use to build a confidence interval.

      slope
      slope

      string indicates the type of slope or (semi-)elasticity to compute:

      @@ -235,7 +238,7 @@ first entry in the error message is used by default.

      wts
      wts

      string or numeric: weights to use when computing average contrasts or slopes. These weights only affect the averaging in ⁠avg_*()⁠ or with the by argument, and not the unit-level estimates themselves. Internally, estimates and weights are passed to the weighted.mean() function.

      @@ -248,7 +251,7 @@ first entry in the error message is used by default.

      hypothesis
      hypothesis

      specify a hypothesis test or custom contrast using a numeric value, vector, or matrix, a string, or a string formula.

      @@ -309,19 +312,19 @@ first entry in the error message is used by default.

      equivalence
      equivalence

      Numeric vector of length 2: bounds used for the two-one-sided test (TOST) of equivalence, and for the non-inferiority and non-superiority tests. See Details section below.

      p_adjust
      p_adjust

      Adjust p-values for multiple comparisons: "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", or "fdr". See stats::p.adjust

      df
      df

      Degrees of freedom used to compute p values and confidence intervals. A single numeric value between 1 and Inf. When df is Inf, the normal distribution is used. When df is finite, the t distribution is used. See insight::get_df for a convenient function to extract degrees of freedom. Ex: slopes(model, df = insight::get_df(model))

      eps
      eps

      NULL or numeric value which determines the step size to use when calculating numerical derivatives: (f(x+eps)-f(x))/eps. When eps is @@ -330,7 +333,7 @@ the maximum and minimum values of the variable with respect to which we are taking the derivative. Changing eps may be necessary to avoid numerical problems in certain models.

      numderiv
      numderiv

      string or list of strings indicating the method to use to for the numeric differentiation used in to compute delta method standard errors.

      @@ -349,7 +352,7 @@ numerical problems in certain models.

      ...
      ...

      Additional arguments are passed to the predict() method supplied by the modeling package.These arguments are particularly useful