View source: R/add_zoi_formula.R
add_zoi_formula | R Documentation |
Given the structure of a formula to be fitted using a data set, the function adds multiple radii
for variables for which the zone of influence (ZOI) or scale of effect (SOE) is to be assessed
through a statistical model. The terms representing the ZOI/SOE variables should be identified
with a pattern (see argument pattern
).
It returns the complete formula with all variables and radii for the ZOI/SOE terms.
If predictor_table = TRUE
, it also returns a table with information
about each predictor (e.g. whether or not it is a ZOI variable, which radius and shape, to
what type of infrastructure it corresponds), to be used by some of the algorithms
in the penalized regression modeling.
add_zoi_formula(
f,
zoi_radius,
type = "",
pattern = "XXX",
cumulative = "",
separator = "_",
remove_term = "",
predictor_table = FALSE
)
f |
|
zoi_radius |
|
type |
|
pattern |
|
cumulative |
|
separator |
|
remove_term |
|
predictor_table |
|
The function searches for patterns in ZOI variables as stated in the formula
and replaces them by combinations of strings representing the type of ZOI
(nearest, cumulative), the shape (e.g. "exp", "linear"), and the multiple ZOI radii
to be assessed. The final name of the variables should match the names of the
columns in the data set.
A list with both the final formula
with all ZOI radii and shapes and
a table with the predictor information (if predictor_table = TRUE
).
# multiple radii
f <- case_ ~ strata(step_id_) + sl_*startpt_roadsXXX + sl_*startpt_cabinsXXX
add_zoi_formula(f, zoi_radius = c(1000, 2000, 3000), pattern = "XXX")
# multiple radii and shapes
f <- case_ ~ strata(step_id_) + sl_*startpt_roadsXXX + sl_*startpt_cabinsXXX
add_zoi_formula(f, zoi_radius = c(1000, 2000, 3000), type = "_exp_decay", pattern = "XXX")
add_zoi_formula(f, zoi_radius = c(1000, 2000, 3000), type = c("_exp_decay", "_threshold"), pattern = "XXX")
# predictor_table - adding only the nearest ZOI
f <- case_ ~ strata(step_id_) + land_use + sl_*startpt_roads_XXX + sl_*startpt_cabins_XXX
add_zoi_formula(f, zoi_radius = c(1000, 2000, 3000), type = c("exp_decay", "threshold"), pattern = "XXX",
predictor_table = TRUE, cumulative = "nearest")
# predictor_table 2 - adding both nearest and cumulative ZOI
f <- case_ ~ strata(step_id_) + sl_*startpt_roads_cumulative_XXX + sl_*startpt_cabins_nearest_XXX
add_zoi_formula(f, zoi_radius = c(1000, 2000, 3000), type = c("exp_decay", "threshold"), pattern = "XXX",
predictor_table = TRUE)
# predictor_table 3 - adding the nearest/cumulative metric within the type argument
f <- case_ ~ strata(step_id_) + sl_*startpt_roads_XXX + sl_*startpt_cabins_XXX
add_zoi_formula(f, zoi_radius = c(1000, 2000, 3000), type = c("nearest_exp_decay", "cumulative_exp_decay"), pattern = "XXX",
predictor_table = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.