specify_hypothesis: (EXPERIMENTAL) Complex aggregation and test functions for the...

View source: R/hypothesis_helper.R

specify_hypothesisR Documentation

(EXPERIMENTAL) Complex aggregation and test functions for the hypothesis argument


Warning: This function is experimental. It may be renamed, the user interface may change, or the functionality may migrate to arguments in other marginaleffects functions.

This function creates aggregation and test functions for use with the hypothesis argument in marginaleffects functions like predictions(), slopes(), and comparisons(). The benefit of this function is that it handles a lot of the "boilerplate" code such as label creation and transformations by subgroups.


  hypothesis = "reference",
  label = NULL,
  label_columns = NULL,
  by = c("term", "group", "contrast")



String or Function. Compute a test statistic.

  • String: "reference" or "sequential"

  • Function: Accepts a single argument named estimate and returns a numeric vector.


Function. Accepts a vector of row labels and combines them to create hypothesis labels.


Character vector. Column names to use for hypothesis labels. Default is c("group", "term", "rowid", attr(x, "variables_datagrid"), attr(x, "by")).


Character vector. Variable names which indicate subgroups in which the hypothesis function should be applied.


specify_hypothesis() is a "function factory", which means that executing it will return a function suitable for use in the hypothesis argument of a marginaleffects function.

marginaleffects documentation built on May 29, 2024, 4:03 a.m.