Compute share ratio elasticities for CoDa models
Source:R/ShareRatioElasticities.R
ShareRatioElasticities.Rd
In CoDa models with compositional dependent variable (Y) share ratio elasticities (SRE) allow to interpret the influence of compositional explanatory variables (X). The interpretation is analogous to usual elasticities:
When the share ratio of X increases by 1% the share ratio of Y increases by SRE%
The main difference to usual elasticities that, since X is compositional the change of X musts be specified in terms of a direction in the simplex.
Arguments
- object
an object of class "lmCoDa"
- Xvar
a character indicating the name of the explanatory variable that changes
- Xdir
a numeric vector, a single character, or
NULL
:if numeric
Xdir
is taken as a fixed direction in the simplexif character
Xdir
is interpreted as one summit of the X composition and converted to the fixed direction towards this summitif
NULL
the share ratio elasticities are computed for variable directions corresponding the example in Dargel and Thomas-Agnan (2024 Lukas Dargel & Christine Thomas-Agnan (2024) The link between multiplicative competitive interaction models and compositional data regression with a total, Journal of Applied Statistics, DOI: 10.1080/02664763.2024.2329923 )
Details
More details on this interpretation can be found in Dargel and Thomas-Agnan (2024) and in the accompanying vignette.
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)"
## case 1
## changes towards the summit "Educ_Higher" as (fixed) direction
SRE1 <- ShareRatioElasticities(res, Xvar = educ_comp, Xdir = "Educ_Higher")
SRE1[1,]
#> Yj Yl Xj Xl SRE
#> 1 right left Educ_Highschool Educ_BeforeHighschool Inf
# Result: SRE=Inf
# cannot be interpreted because, for this direction,
# the relative change in the share ratio of X (Highschool / BeforeHighschool) is zero
SRE1[7,]
#> Yj Yl Xj Xl SRE
#> 7 right left Educ_Higher Educ_BeforeHighschool 0.9161426
# Result: SRE=0.9
# when the ratio of X (Higher / BeforeHighschool) increases by 1%
# the ratio of Y (right / left) increases by about 0.9%
## case 2
## numeric vector as (fixed) direction
SRE2 <- ShareRatioElasticities(res, Xvar = educ_comp, Xdir = exp(c(0,0,1)))
identical(SRE1,SRE2) # exp(c(0,0,1)) is the direction that points to the third summit
#> [1] TRUE
## case 3
## variable directions with Xdir = NULL
## In this case the direction depends components used for the share ratio of X
## In particular the component of X in the numerator grows
## by the same rate as the denominator decreases
SRE3 <- ShareRatioElasticities(res, Xvar = educ_comp, Xdir = NULL)
SRE3[1,]
#> Yj Yl Xj Xl SRE
#> 1 right left Educ_Highschool Educ_BeforeHighschool -2.839466
# Result: SRE=-2.8
# when the ratio of X (Highschool / BeforeHighschool) increases by 1%
# the ratio of Y (right / left) decreases by about -2.8%