glimmer: glm/glmer formulas to map/map2stan formulas

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Converts a glm or glmer model formula into a formula list of the kind used by map and map2stan

Usage

1
2
glimmer( formula , data , family=gaussian , prefix=c("b_","v_") , 
    default_prior="dnorm(0,10)" , ... )

Arguments

formula

A formula of the sort used by glm or glmer

data

A data frame or list containing the data

family

Name of family, as in glm/glmer. Recognizes gaussian, binomial, and poisson with arbitrary links

prefix

Text prefixes for fixed and varying effects parameters

default_prior

Text of default prior for regression parameters

...

Additional parameters to pass to map2stan

Details

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.

Value

Returns an invisible list with two slots:

f

list of formulas, suitable for passing to map2stan

d

list of data, suitable for passing to map2stan

Author(s)

Richard McElreath

See Also

map2stan

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## 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)

joepowers16/rethinking documentation built on June 2, 2019, 6:52 p.m.