construction_helpers {cardx} | R Documentation |
Construction Helpers
Description
These functions help construct calls to various types of models.
Usage
construct_model(data, ...)
## S3 method for class 'data.frame'
construct_model(
data,
formula,
method,
method.args = list(),
package = "base",
env = caller_env(),
...
)
## S3 method for class 'survey.design'
construct_model(
data,
formula,
method,
method.args = list(),
package = "survey",
env = caller_env(),
...
)
reformulate2(
termlabels,
response = NULL,
intercept = TRUE,
pattern_term = "[ \n\r]",
pattern_response = "[ \n\r]",
env = parent.frame()
)
bt(x, pattern = "[ \n\r]")
bt_strip(x)
Arguments
data |
|
... |
These dots are for future extensions and must be empty. |
formula |
( |
method |
( |
method.args |
(named Note that this list may contain non-standard evaluation components.
If you are wrapping this function in other functions, the argument
must be passed in a way that does not evaluate the list, e.g.
using rlang's embrace operator |
package |
( |
env |
The environment in which to evaluate |
termlabels |
character vector giving the right-hand side of a model formula. Cannot be zero-length. |
response |
character string, symbol or call giving the left-hand
side of a model formula, or |
intercept |
logical: should the formula have an intercept? |
pattern_term , pattern_response |
passed to |
x |
( |
pattern |
( |
Details
-
construct_model()
: Builds models of the formmethod(data = data, formula = formula, method.args!!!)
. If thepackage
argument is specified, that package is temporarily attached when the model is evaluated. -
reformulate2()
: This is a copy ofreformulate()
except that variable names that contain a space are wrapped in backticks. -
bt()
: Adds backticks to a character vector. -
bt_strip()
: Removes backticks from a string if it begins and ends with a backtick.
Value
depends on the calling function
Examples
construct_model(
data = mtcars,
formula = am ~ mpg + (1 | vs),
method = "glmer",
method.args = list(family = binomial),
package = "lme4"
) |>
broom.mixed::tidy()
construct_model(
data = mtcars |> dplyr::rename(`M P G` = mpg),
formula = reformulate2(c("M P G", "cyl"), response = "hp"),
method = "lm"
) |>
ard_regression() |>
dplyr::filter(stat_name %in% c("term", "estimate", "p.value"))