substitution | R Documentation |
Estimate the difference in an outcome
when compositional parts are substituted for specific unit(s).
The substitution
output encapsulates
the substitution results for all compositional parts
present in the brmcoda
object.
substitution(
object,
delta,
basesub,
aorg = TRUE,
summary = TRUE,
ref = c("grandmean", "clustermean"),
level = c("between", "within", "aggregate"),
weight = c("equal", "proportional"),
scale = c("response", "linear"),
comparison = NULL,
cores = NULL,
...
)
object |
A fitted |
delta |
A integer, numeric value or vector indicating the amount of substituted change between compositional parts. |
basesub |
A base substitution.
Can be a |
aorg |
A logical value to obtain (a)verage prediction (o)ver the (r)eference (g)rid.
Should the estimate at each level of the reference grid ( |
summary |
A logical value to obtain summary statistics instead of the raw values. Default is |
ref |
Either a character value or vector or a dataset.
Can be |
level |
A character string or vector.
Should the estimate of multilevel models focus on the |
weight |
A character value specifying the weight to use in calculation of the reference composition.
If |
scale |
Either |
comparison |
internally used only. |
cores |
Number of cores to use when executing the chains in parallel,
we recommend setting the |
... |
currently ignored. |
A list containing the results of multilevel compositional substitution model. The first six lists contain the results of the substitution estimation for a compositional part.
Mean |
Posterior means. |
CI_low and CI_high |
95% credible intervals. |
Delta |
Amount substituted across compositional parts. |
From |
Compositional part that is substituted from. |
To |
Compositional parts that is substituted to. |
Level |
Level where changes in composition takes place. |
Reference |
Either |
if(requireNamespace("cmdstanr")){
cilr <- complr(data = mcompd, sbp = sbp,
parts = c("TST", "WAKE", "MVPA", "LPA", "SB"),
idvar = "ID", total = 1440)
# model with compositional predictor at between and within-person levels
fit1 <- brmcoda(complr = cilr,
formula = Stress ~ bilr1 + bilr2 + bilr3 + bilr4 +
wilr1 + wilr2 + wilr3 + wilr4 + (1 | ID),
chain = 1, iter = 500, backend = "cmdstanr")
# one to one reallocation at between and within-person levels
sub1 <- substitution(object = fit1, delta = 5, level = c("between"), summary = FALSE)
summary(sub1)
# one to all reallocation at between and within-person levels
sub2 <- substitution(object = fit1, delta = 5, level = c("between", "within"),
basesub = "one-to-all")
summary(sub2)
# model with compositional predictor at aggregate level of variance
fit2 <- brmcoda(complr = cilr,
formula = Stress ~ ilr1 + ilr2 + ilr3 + ilr4 + (1 | ID),
chain = 1, iter = 500, backend = "cmdstanr")
sub3 <- substitution(object = fit2, delta = 5, level = c("aggregate"))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.