Random-effect scale formula syntax
Source:R/random-effect-scale-formulas.R
random_effect_scale_formulas.Rdsd(group) ~ predictors and its siblings are formula-only syntax for
modelling random-effect standard deviations. They are captured by
drm_formula() or bf() and are not evaluated as ordinary R calls. In
particular, sd(group) ~ predictors does not replace stats::sd().
Details
The currently documented syntax is:
sd(group) ~ predictorsfor univariate Gaussian location random-effect scale models;sd1(group) ~ predictorsandsd2(group) ~ predictorsfor bivariate Gaussian location random-effect scale models targetingmu1andmu2;sd_phylo(species) ~ predictorsfor univariate Gaussian phylogenetic location random-effect scale models;sd_phylo1(species) ~ predictorsandsd_phylo2(species) ~ predictorsfor bivariate Gaussian phylogenetic location random-effect scale models targetingmu1andmu2.
These formulas model the standard deviation of a latent random-effect block.
They are distinct from residual scale formulas such as sigma ~ predictors
and from latent correlation formulas such as corpair(). Non-Gaussian
random-effect scale formulas, spatial direct-SD formulas, and explicit
coefficient-specific targets such as
sd(group, dpar = "mu", coef = "slope") ~ predictors remain planned.
Examples
bf(y ~ x + (1 | id), sigma ~ z, sd(id) ~ habitat)
#> <drm_formula>
#> y ~ x + (1 | id)
#> sigma ~ z
#> sd(id) ~ habitat
bf(
mu1 = y1 ~ x + (1 | p | id),
mu2 = y2 ~ x + (1 | p | id),
sd1(id) ~ habitat,
sd2(id) ~ habitat,
rho12 = ~ x
)
#> <drm_formula>
#> mu1 = y1 ~ x + (1 | p | id)
#> mu2 = y2 ~ x + (1 | p | id)
#> sd1(id) ~ habitat
#> sd2(id) ~ habitat
#> rho12 = ~x
bf(
y ~ x + phylo(1 | species, tree = tree),
sd_phylo(species) ~ ecology
)
#> <drm_formula>
#> y ~ x + phylo(1 | species, tree = tree)
#> sd_phylo(species) ~ ecology