Description Usage Arguments Value Examples
greta.glmer
creates the linear predictor $eta$ required
for fitting generalized linear mixed models. The linear predictor has the
form:
η = X β + Z γ,
where X is the fixed effects design matrix, β the fixed effects, Z the random effects design matrix and γ the random effects.
1 2 |
formula |
an |
data |
the data set containing the variables described in
|
prior_intercept |
a p(β) ∝ const. The intercept prior needs to have dimension 1. |
prior_coefficients |
a p(β_i) ~ N(0, σ), and p(σ) ~ Half-Cauchy(0, ∞). The coefficients prior need to have the same dimensionalty as the number of columns of your fixed effects design matrix (without the intercept). |
prior_random_effects |
a p(γ) ~ N(0, τ), and p(τ) ~ Inv-Wishart If |
Returns a list of class greta.glmer
with the following
elements:
predictor |
the linear predictor η |
X |
the fixed effects design matrix |
x.eta |
the linear predictor Xβ |
coef |
the prior for the coefficients β |
Z |
the random effects design matrix |
z.eta |
the linear predictor Zγ |
gamma |
the prior for the random effects γ |
Ztlist |
a list of random effect terms used for initializing γ |
grp.vars |
the variables used for grouping |
call |
the function call used |
formula |
the formula used |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # create a random intercept model
greta.glmer(Sepal.Length ~ Sepal.Width + (1 | Species), iris)
# creates a random slope model
greta.glmer(Sepal.Length ~ Sepal.Width + (Sepal.Width | Species), iris)
# creates a random slope model with multiple random effect terms
greta.glmer(Sepal.Length ~ Sepal.Width + (Sepal.Width | Species) + (Petal.Width | Species),
iris)
# creates a random slope model with strong regularizing prior
greta.glmer(Sepal.Length ~ Sepal.Width + (Sepal.Width | Species),
iris,
prior_random_effects = greta::normal(0, 1, dim=6))
# creates a random slope model with flat coefficient prior
greta.glmer(Sepal.Length ~ Sepal.Width + (Sepal.Width | Species),
iris,
prior_coefficients = greta::variable(dim=1))
# creates a random slope model with normal intercept prior
greta.glmer(Sepal.Length ~ Sepal.Width + (Sepal.Width | Species),
iris,
prior_intercept = greta::normal(0, 1))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.