Description Usage Arguments Details Value References See Also Examples
Generalized linear modeling with spatial temporal aggregated predictors using prior distributions for the coefficients, intercept, spatial-temporal scales, and auxiliary parameters.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | stap_glm(formula, family = gaussian(), subject_data = NULL,
distance_data = NULL, time_data = NULL, subject_ID = NULL,
max_distance = NULL, max_time = NULL, weights, offset = NULL,
model = TRUE, y = TRUE, contrasts = NULL, ..., prior = normal(),
prior_intercept = normal(), prior_stap = normal(),
prior_theta = log_normal(location = 1L, scale = 1L),
prior_aux = exponential(), adapt_delta = NULL)
stap_lm(formula, family = gaussian(), subject_data = NULL,
distance_data = NULL, time_data = NULL, subject_ID = NULL,
max_distance = NULL, max_time = NULL, weights, offset = NULL,
model = TRUE, y = TRUE, contrasts = NULL, ..., prior = normal(),
prior_intercept = normal(), prior_stap = normal(),
prior_theta = log_normal(location = 1L, scale = 1L),
prior_aux = exponential(), adapt_delta = NULL)
|
formula |
Same as for | |||||||||||
family |
Same as | |||||||||||
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(s) to join on between subject_data and bef_data | |||||||||||
max_distance |
the inclusion distance; upper bound for all elements of dists_crs | |||||||||||
max_time |
inclusion time; upper bound for all elements of times_crs | |||||||||||
offset, weights |
Same as | |||||||||||
model |
logical denoting whether or not to return the fixed covariates model frame object in the fitted object | |||||||||||
y |
In | |||||||||||
contrasts |
Same as | |||||||||||
... |
Further arguments passed to the function in the rstap
to specify | |||||||||||
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—
Note: If | |||||||||||
prior_intercept |
The prior distribution for the intercept.
Note: The prior distribution for the intercept is set so it
applies to the value when all predictors are centered. If you prefer
to specify a prior on the intercept without the predictors being
auto-centered, then you have to omit the intercept from the
| |||||||||||
prior_stap |
prior for spatial-temporal aggregated predictors. Note that prior is set on the standardized latent covariates. | |||||||||||
prior_theta |
prior for the spatial-temporal aggregated predictors' scale. Can either be a single prior or a prior nested within a list of lists. | |||||||||||
prior_aux |
The prior distribution for the "auxiliary" parameter (if
applicable). The "auxiliary" parameter refers to a different parameter
depending on the
| |||||||||||
adapt_delta |
See the adapt_delta help page for details. |
The stap_glm
function is similar in syntax to
stan_glm
except instead of performing full bayesian
inference for a generalized linear model stap_glm incorporates spatial-temporal covariates
A stapreg object is returned
for stap_glm
.
A stapfit object (or a slightly modified
stapfit object) is returned if stan_glm.fit
is called directly.
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
glm
.
The various vignettes for stap_glm
at
https://biostatistics4socialimpact.github.io/rstap/articles and the preprint article.
1 2 3 4 5 6 7 8 9 10 11 12 13 | fit_glm <- stap_glm(formula = y ~ sex + sap(Fast_Food),
subject_data = homog_subject_data[1:100,], # for speed of example only
distance_data = homog_distance_data,
family = gaussian(link = 'identity'),
subject_ID = 'subj_id',
prior = normal(location = 0, scale = 5, autoscale = FALSE),
prior_intercept = normal(location = 25, scale = 5, autoscale = FALSE),
prior_stap = normal(location = 0, scale = 3, autoscale = FALSE),
prior_theta = log_normal(location = 1, scale = 1),
prior_aux = cauchy(location = 0,scale = 5),
max_distance = max(homog_distance_data$Distance),
chains = 1, iter = 300, # for speed of example only
refresh = -1, verbose = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.