VariationScenario {CoDaImpact} | R Documentation |
Scenarios for variation in CoDa regressions models
Description
Scenarios of this type are illustrated in Dargel and Thomas-Agnan (2024). They allow to evaluate how the response variable (Y) in a CoDa model would evolve under a hypothetical scenario for linear changes in one explanatory variable (X). When the changing explanatory variable is compositional the term "linear" is understood with respect to the geometry of the simplex.
Usage
VariationScenario(
object,
Xvar,
Xdir,
obs = 1,
inc_size = 0.1,
n_steps = 100,
add_opposite = TRUE,
normalize_Xdir = TRUE
)
Arguments
object |
an object of class "lmCoDa" |
Xvar |
a character indicating the name of the explanatory variable that changes |
Xdir |
either character or numeric, to indicate the direction in which Xvar should change
|
obs |
a numeric indicating the observation used for the scenario |
inc_size |
a numeric indicating the distance between each point in the scenario of X |
n_steps |
a numeric indicating the number of points in the scenario |
add_opposite |
a logical, if |
normalize_Xdir |
a logical, if |
Details
The linear scenario for X is computed with seq()
in the scalar case and with CoDa_seq()
in the compositional case.
The corresponding changes in Y are computed with the prediction formula, where we exploit the fact that only in one variable is changing.
Value
a data.frame containing the scenario of X and the corresponding predicted values of Y
Author(s)
Lukas Dargel
References
Dargel, Lukas and Christine Thomas-Agnan, “Pairwise share ratio interpretations of compositional regression models”, Computational Statistics & Data Analysis 195 (2024), p. 107945
Examples
# ---- model with scalar response ----
res <- lmCoDa(YIELD ~ PRECIPITATION + ilr(TEMPERATURES), data = head(rice_yields,20))
VariationScenario(res, Xvar = "TEMPERATURES", Xdir = "MEDIUM", n_steps = 5)
VariationScenario(res, Xvar = "PRECIPITATION", n_steps = 5)
# ---- model with compositional response ----
res <- lmCoDa(ilr(cbind(left, right, extreme_right)) ~
ilr(cbind(Age_1839, Age_4064)) +
ilr(cbind(Educ_BeforeHighschool, Educ_Highschool, Educ_Higher)) +
log(unemp_rate),
data = head(election))
VariationScenario(res, Xvar ="cbind(Age_1839,Age_4064)",Xdir = "Age_1839", n_steps = 5)
VariationScenario(res, "log(unemp_rate)", n_steps = 5)