unm_glm {unmconf} | R Documentation |
Fitting Multi-Staged Bayesian Regression Model with Unmeasured Confounders
Description
unm_glm()
fits a multi-staged Bayesian regression model that accounts for
unmeasured confounders. Users can input model information into unm_glm()
in
a similar manner as they would for the standard stats::glm()
function,
providing arguments like formula
, family
, and data
. Results are stored
as MCMC iterations.
Usage
unm_glm(
form1,
form2 = NULL,
form3 = NULL,
family1 = binomial(),
family2 = NULL,
family3 = NULL,
data,
n.iter = 2000,
n.adapt = 1000,
thin = 1,
n.chains = 4,
filename = tempfile(fileext = ".jags"),
quiet = getOption("unm_quiet"),
progress.bar = getOption("unm_progress.bar"),
code_only = FALSE,
priors,
response_nuisance_priors,
response_params_to_track,
confounder1_nuisance_priors,
confounder1_params_to_track,
confounder2_nuisance_priors,
confounder2_params_to_track,
...
)
jags_code(mod)
## S3 method for class 'unm_int'
print(x, digits = 3, ..., print_call = getOption("unm_print_call"))
## S3 method for class 'unm_int'
coef(object, ...)
Arguments
form1 |
The formula specification for the response model (stage I) |
form2 |
The formula specification for the first unmeasured confounder model (stage II) |
form3 |
The formula specification for the second unmeasured confounder model (stage III) |
family1 , family2 , family3 |
The family object, communicating the types of
models to be used for response ( |
data |
The dataset containing all variables (this function currently only supports a single dataset containing internally validated data) |
n.iter |
|
n.adapt |
|
thin |
|
n.chains |
|
filename |
File name where to store jags code |
quiet |
The |
progress.bar |
The |
code_only |
Should only the code be created? |
priors |
Custom priors to use on regression coefficients, see examples. |
response_nuisance_priors , confounder1_nuisance_priors , confounder2_nuisance_priors |
JAGS code for the nuisance priors on parameters in a JAGS model (see examples) |
response_params_to_track , confounder1_params_to_track , confounder2_params_to_track |
Additional parameters to track when nuisance parameter priors are used (see examples) |
... |
Additional arguments to pass into |
mod |
The output of |
x |
Object to be printed |
digits |
Number of digits to round to; defaults to 3 |
print_call |
Should the call be printed? Defaults to |
object |
Model object for which the coefficients are desired |
Value
(Invisibly) The output of rjags::coda.samples()
, an object of class
mcmc.list
, along with attributes code
containing the jags code used and
file
containing the filename of the jags code.
See Also
Examples
# ~~ One Unmeasured Confounder Examples (II-Stage Model) ~~
# normal response, normal confounder model with internally validated data
(df <- runm(20, response = "norm"))
(unm_mod <- unm_glm(
y ~ x + z1 + z2 + z3 + u1, family1 = gaussian(),
u1 ~ x + z1 + z2 + z3, family2 = gaussian(),
data = df
))
(unm_mod <- unm_glm(
y ~ ., family1 = gaussian(),
u1 ~ . - y, family2 = gaussian(),
data = df
))
glm(y ~ x + z1 + z2 + z3, data = df)
coef(unm_mod)
jags_code(unm_mod)
unm_glm(
y ~ .,
u1 ~ . - y,
family1 = gaussian(),
family2 = gaussian(),
data = df, code_only = TRUE
)