apm_mod {apm} | R Documentation |
Generate models used to fit outcomes
Description
apm_mod()
generates a list of models characterized by a basic model formulas and other options (e.g., lags, families, etc.) that are supplied to apm_pre()
. These values are completely crossed to create a grid of model specifications, and multiple sets of model specifications can be combined using c()
(see Examples).
Usage
apm_mod(
formula_list,
family = "gaussian",
lag = 0L,
diff_k = 0L,
log = FALSE,
time_trend = 0L,
fixef = FALSE,
identiy_only_log = TRUE
)
Arguments
formula_list |
a list of model formulas with the outcome on the left side and predictions (or just an intercept) on the right side. |
family |
a list of family specifications; see |
lag |
a vector of integers indicating the desired outcome lags to be used as predictors. For example, a |
diff_k |
a vector of integers indicating the desired outcome lag to be used a an offset For example, a |
log |
a logical vector indicating whether the outcome should be log-transformed. Default is |
time_trend |
a vector of integers indicating the desired powers to be included in a time trend. For example, a |
fixef |
a logical vector indicating whether unit fixed effects should be included as predictors. Default is |
identiy_only_log |
|
Value
An apm_models
object, which is a list containing the full cross (less any omitted combinations) of the model features specified in the arguments, with each combination a list. These have a print()
method and can be combined using c()
. Each model is named automatically, but these can be set manually using names()
as well. Models can be removed by setting their value to NULL
; see Examples.
See Also
Examples
data("ptpdata")
# Combination of 8 models: 1 baseline formulas,
# 2 families, 2 lags, 2 time trends
models1 <- apm_mod(crude_rate ~ 1,
family = list("gaussian", "quasipoisson"),
time_trend = 0:1,
lag = 0:1, fixef = TRUE)
models1
# Add a single other model with a square time trend
models2 <- apm_mod(crude_rate ~ 1,
family = "gaussian",
time_trend = 2,
fixef = FALSE)
models2
(models <- c(models1, models2))
# Remove a model
models[[4]] <- NULL
models