Description Usage Arguments Details Value References See Also Examples

Bayesian inference for stap-glms with group-specific coefficients that have unknown covariance matrices with flexible priors.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
stap_glmer(formula, family = gaussian(), subject_data = NULL,
distance_data = NULL, time_data = NULL, subject_ID = NULL,
group_ID = NULL, max_distance = NULL, max_time = NULL, weights,
offset, contrasts = NULL, ..., prior = normal(),
prior_intercept = normal(), prior_stap = normal(),
prior_theta = log_normal(location = 1L, scale = 1L),
prior_aux = exponential(), prior_covariance = decov(),
adapt_delta = NULL)
stap_lmer(formula, subject_data = NULL, distance_data = NULL,
time_data = NULL, subject_ID = NULL, group_ID = NULL,
max_distance = NULL, max_time = NULL, weights, offset,
contrasts = NULL, ..., prior = normal(),
prior_intercept = normal(), prior_stap = normal(),
prior_theta = log_normal(location = 1L, scale = 1L),
prior_aux = exponential(), prior_covariance = decov(),
adapt_delta = NULL)
``` |

`formula` |
Same as for | |||||||||||

`family` |
Same as for | |||||||||||

`subject_data` |
a data.frame that contains data specific to the subject or subjects on whom the outcome is measured. Must contain one column that has the subject_ID on which to join the distance and time_data | |||||||||||

`distance_data` |
a (minimum) three column data.frame that contains (1) an id_key (2) The sap/tap/stap features and (3) the distances between subject with a given id and the built environment feature in column (2), the distance column must be the only column of type "double" and the sap/tap/stap features must be specified in the dataframe exactly as they are in the formula. | |||||||||||

`time_data` |
same as distance_data except with time that the subject has been exposed to the built environment feature, instead of distance | |||||||||||

`subject_ID` |
name of column to join on between subject_data and bef_data | |||||||||||

`group_ID` |
name of column to join on between | |||||||||||

`max_distance` |
the upper bound on any and all distances included in the model | |||||||||||

`max_time` |
the upper bound on any and all times included in the model | |||||||||||

`weights, offset` |
Same as | |||||||||||

`contrasts` |
Same as | |||||||||||

`...` |
For | |||||||||||

`prior` |
The prior distribution for the regression coefficients.
See the priors help page for details on the families and
how to specify the arguments for all of the functions in the table above.
To omit a prior —i.e., to use a flat (improper) uniform prior—
| |||||||||||

`prior_intercept` |
The prior distribution for the intercept.
| |||||||||||

`prior_theta, prior_stap` |
priors for the spatial scale and spatial effect parameters, respectively | |||||||||||

`prior_aux` |
The prior distribution for the "auxiliary" parameter (if
applicable). The "auxiliary" parameter refers to a different parameter
depending on the
| |||||||||||

`prior_covariance` |
Cannot be | |||||||||||

`adapt_delta` |
See the adapt_delta help page for details. |

The `stap_glmer`

function is similar in syntax to
`glmer`

but rather than performing (restricted) maximum
likelihood estimation of generalized linear models, Bayesian estimation is
performed via MCMC. The Bayesian model adds priors on the
regression coefficients (in the same way as `stap_glm`

) and
priors on the terms of a decomposition of the covariance matrices of the
group-specific parameters. See `priors`

for more information
about the priors.

The `stap_lmer`

function is equivalent to `stap_glmer`

with
`family = gaussian(link = "identity")`

.

A stapreg object is returned
for `stap_glmer, stap_lmer`

.

Gelman, A. and Hill, J. (2007). *Data Analysis Using
Regression and Multilevel/Hierarchical Models.* Cambridge University Press,
Cambridge, UK.

Muth, C., Oravecz, Z., and Gabry, J. (2018)
User-friendly Bayesian regression modeling: A tutorial with rstanarm and shinystan.
*The Quantitative Methods for Psychology*. 14(2), 99–119.
https://www.tqmp.org/RegularArticles/vol14-2/p099/p099.pdf

`stapreg-methods`

and
`glmer`

.

The Longituinal Vignette for `stap_glmer`

and the preprint article available through arXiv.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ```
## Not run:
## subset to only include id, class name and distance variables
distdata <- homog_longitudinal_bef_data[,c("subj_ID","measure_ID","class","dist")]
timedata <- homog_longitudinal_bef_data[,c("subj_ID","measure_ID","class","time")]
## distance or time column must be numeric
timedata$time <- as.numeric(timedata$time)
fit <- stap_glmer(y_bern ~ centered_income + sex + centered_age + stap(Coffee_Shop) + (1|subj_ID),
family = binomial(link='logit'),
subject_data = homog_longitudinal_subject_data,
distance_data = distdata,
time_data = timedata,
subject_ID = 'subj_ID',
group_ID = 'measure_ID',
prior_intercept = normal(location = 25, scale = 4, autoscale = F),
prior = normal(location = 0, scale = 4, autoscale=F),
prior_stap = normal(location = 0, scale = 4),
prior_theta = list(Coffee_Shop = list(spatial = log_normal(location = 1,
scale = 1),
temporal = log_normal(location = 1,
scale = 1))),
max_distance = 3, max_time = 50,
chains = 4, refresh = -1, verbose = FALSE,
iter = 1E3, cores = 1)
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.