glimmer | R Documentation |
Converts a glm
or glmer
model formula into a formula list of the kind used by map
and map2stan
glimmer( formula , data , family=gaussian , prefix=c("b_","v_") ,
default_prior="dnorm(0,10)" , ... )
formula |
A formula of the sort used by |
data |
A data frame or list containing the data |
family |
Name of family, as in |
prefix |
Text prefixes for fixed and varying effects parameters |
default_prior |
Text of default prior for regression parameters |
... |
Additional parameters to pass to |
This function parses and converts a glmer
-style mixed model formula into a list of formulas appropriate for map2stan
input. Interactions are pre-multiplied, and factors are automatically converted into a series of dummy variables. In the absence of varying effects in the input formula, the resulting formula list will also be suitable for map
input in most cases.
The function glmer
is provided by package lme4
, but it is not required for glimmer
to work.
Returns an invisible list with two slots:
f |
list of formulas, suitable for passing to |
d |
list of data, suitable for passing to |
Richard McElreath
map2stan
## Not run:
library(rethinking)
data(UCBadmit)
# varying intercepts
f3 <- cbind(admit,reject) ~ (1|dept) + applicant.gender
m3 <- glimmer( f3 , UCBadmit , binomial )
m3s <- map2stan( m3$f , data=m3$d )
# varying intercepts and slopes
f4 <- cbind(admit,reject) ~ (1+applicant.gender|dept) + applicant.gender
m4 <- glimmer( f4 , UCBadmit , binomial )
m4s <- map2stan( m4$f , data=m4$d )
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.