This function allows to evaluate how a change in an explanatory variables impacts the response variable in a CoDa regression model. The changes are calculated based from the approximate formal presented in Dargel and Thomas-Agnan (2024). Changes in the response variables are provided as data.frame and the underlying changes in the explanatory variable are given as attributes.
Usage
VariationTable(
object,
Xvar,
Xdir,
obs = 1,
inc_size = 0.1,
inc_rate = NULL,
Ytotal = 1,
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
when character this should be one of the components of X, in which case the direction is the corresponding vertex of the simplex
when numeric this argument is coerced to a unit vector in the simplex
(when Xvar refers to a scalar variable this argument is ignored)
- 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
- inc_rate
a numeric that can be used as a parameterization of the step size
- Ytotal
a numeric indicating the total of Y
- normalize_Xdir
a logical, if
TRUE
the directionXdir
scaled to have an Aitchison norm of 1, allowing to interpretinc_size
as the Aitchison distance
References
Dargel, Lukas and Christine Thomas-Agnan, “Pairwise share ratio interpretations of compositional regression models”, Computational Statistics & Data Analysis 195 (2024), p. 107945
Examples
# XY-compositional model
res <- lmCoDa(
ilr(cbind(left, right, extreme_right)) ~
ilr(cbind(Educ_BeforeHighschool, Educ_Highschool, Educ_Higher)),
data = head(election, 20))
# Focus on changes in the education composition
educ_comp <- "cbind(Educ_BeforeHighschool, Educ_Highschool, Educ_Higher)"
# ... changes towards a summit towards a summit (higher share of people with lower education)
VariationTable(res, educ_comp, Xdir = "Educ_BeforeHighschool")
#> left right extreme_right
#> Initial parts 0.3395614 0.4066297 0.2538089
#> New parts 0.2519498 0.4203111 0.3277390
#> Elasticity -2.5801405 0.3364601 2.9128277
#> Variation in % -25.8014049 3.3646008 29.1282765
#> Variation in % points -8.7611620 1.3681465 7.3930155
# ... same changes using a compositional vector as direction
VariationTable(res, educ_comp, Xdir = c(.5,.25,.25))
#> left right extreme_right
#> Initial parts 0.3395614 0.4066297 0.2538089
#> New parts 0.2519498 0.4203111 0.3277390
#> Elasticity -2.5801405 0.3364601 2.9128277
#> Variation in % -25.8014049 3.3646008 29.1282765
#> Variation in % points -8.7611620 1.3681465 7.3930155
# ... changes in a more general direction and for a different observation
VariationTable(res, educ_comp, Xdir = c(.35,.45,.10), obs = 2)
#> left right extreme_right
#> Initial parts 0.3375668 0.4066003 0.2558329
#> New parts 0.3906038 0.3999548 0.2094415
#> Elasticity 1.5711531 -0.1634408 -1.8133484
#> Variation in % 15.7115308 -1.6344077 -18.1334837
#> Variation in % points 5.3036919 -0.6645506 -4.6391412