qgcomp.emm.noboot {qgcompint} | R Documentation |
EMM for Quantile g-computation for continuous, binary, and count outcomes under linearity/additivity
Description
This function fits a quantile g-computation model, allowing effect measure modification by a binary or continuous covariate. This allows testing of statistical interaction as well as estimation of stratum specific effects.
Usage
qgcomp.emm.noboot(
f,
data,
expnms = NULL,
emmvar = NULL,
q = 4,
breaks = NULL,
id = NULL,
weights,
alpha = 0.05,
bayes = FALSE,
errcheck = TRUE,
...
)
Arguments
f |
R style formula |
data |
data frame |
expnms |
character vector of exposures of interest |
emmvar |
(character) name of effect measure modifier in dataset (if categorical, must be coded as a factor variable) |
q |
NULL or number of quantiles used to create quantile indicator variables representing the exposure variables. If NULL, then gcomp proceeds with un-transformed version of exposures in the input datasets (useful if data are already transformed, or for performing standard g-computation) |
breaks |
(optional) NULL, or a list of (equal length) numeric vectors that characterize the minimum value of each category for which to break up the variables named in expnms. This is an alternative to using 'q' to define cutpoints. |
id |
(optional) NULL, or variable name indexing individual units of observation (only needed if analyzing data with multiple observations per id/cluster). Note that qgcomp.noboot will not produce cluster-appropriate standard errors (this parameter is essentially ignored in qgcomp.noboot). Qgcomp.boot can be used for this, which will use bootstrap sampling of clusters/individuals to estimate cluster-appropriate standard errors via bootstrapping. |
weights |
"case weights" - passed to the "weight" argument of
|
alpha |
alpha level for confidence limit calculation |
bayes |
use underlying Bayesian model ( |
errcheck |
(logical, default=TRUE) include some basic error checking. Slightly faster if set to false (but be sure you understand risks) |
... |
arguments to glm (e.g. family) |
Value
a qgcompfit object, which contains information about the effect measure of interest (psi) and associated variance (var.psi), as well as information on the model fit (fit) and information on the weights/standardized coefficients in the positive (pos.weights) and negative (neg.weights) directions.
See Also
Examples
set.seed(50)
# linear model, binary modifier
dat <- data.frame(y=runif(50), x1=runif(50), x2=runif(50),
z=rbinom(50,1,0.5), r=rbinom(50,1,0.5))
(qfit <- qgcomp.emm.noboot(f=y ~ z + x1 + x2, emmvar="z",
expnms = c('x1', 'x2'), data=dat, q=2, family=gaussian()))
# logistic model, continuous modifier
dat2 <- data.frame(y=rbinom(50, 1,0.5), x1=runif(50), x2=runif(50),
z=runif(50), r=rbinom(50,1,0.5))
(qfit2 <- qgcomp.emm.noboot(f=y ~ z + x1 + x2, emmvar="z",
expnms = c('x1', 'x2'), data=dat2, q=2, family=binomial()))
# get weights and stratum specific effects at specific value of Z
# (note that when Z=0, the effect is equal to psi1)
qgcompint::getstratweights(qfit2,emmval=0)
qgcompint::getstrateffects(qfit2,emmval=0)
qgcompint::getstratweights(qfit2,emmval=0.5)
qgcompint::getstrateffects(qfit2,emmval=0.5)
# linear model, categorical modifier
dat3 <- data.frame(y=runif(50), x1=runif(50), x2=runif(50),
z=as.factor(sample(0:2, 50,replace=TRUE)), r=rbinom(50,1,0.5))
(qfit3 <- qgcomp.emm.noboot(f=y ~ z + x1 + x2, emmvar="z",
expnms = c('x1', 'x2'), data=dat3, q=2, family=gaussian()))
# get weights and stratum specific effects at each value of Z
# (note that when Z=0, the effect is equal to psi1)
qgcompint::getstratweights(qfit3,emmval=0)
qgcompint::getstrateffects(qfit3,emmval=0)
qgcompint::getstratweights(qfit3,emmval=1)
qgcompint::getstrateffects(qfit3,emmval=1)
qgcompint::getstratweights(qfit3,emmval=2)
qgcompint::getstrateffects(qfit3,emmval=2)