gestimation {CausalModels} | R Documentation |
One Parameter G-Estimation of Structural Nested Mean Models
Description
'gestimation' uses the propensity_scores
function to generate inverse probability
weights. The weights can either be standardized weights or non-standardized weights. A grid search is done on \alpha
to construct the best \beta
coefficient in the structural nested mean model. Alternatively, a linear mean model can be used
for a closed form estimator.
Usage
gestimation(
data,
grid,
ids = list(),
f = NA,
family = binomial(),
simple = pkg.env$simple,
p.f = NA,
p.simple = pkg.env$simple,
p.family = binomial(),
p.scores = NA,
SW = TRUE,
n.boot = 100,
type = "one.grid",
...
)
Arguments
data |
a data frame containing the variables in the model.
This should be the same data used in |
grid |
a list of possible |
ids |
(optional) see documentation for |
f |
(optional) an object of class "formula" that overrides the default parameter. NOTE: for g-estimation this should be a propensity formula. |
family |
the family to be used in the general linear model.
By default, this is set to |
simple |
(optional) a boolean indicator to build default formula with interactions for the g-estimation model.
If true, interactions will be excluded. If false, interactions will be included. By default, simple is set to false.
NOTE: |
p.f |
(optional) an object of class "formula" that overrides the default formula for the denominator of the IP weighting function. |
p.simple |
(optional) a boolean indicator to build default formula with interactions for the propensity models. If true, interactions will be excluded. If false, interactions will be included. By default, simple is set to false. NOTE: if this is changed, the coefficient for treatment may not accurately represent the average causal effect. |
p.family |
the family to be used in the underlying propensity model.
By default, this is set to |
p.scores |
(optional) use calculated propensity scores for the weights. If using standardized weights, the numerator will still be modeled. |
SW |
a boolean indicator to indicate the use of standardized weights. By default, this is set to true. |
n.boot |
(optional) an integer value that indicates number of bootstrap iterations to calculate standard error. If no value is given, the standard error from the underlying linear model will be used. NOTE: when type is 'one.grid' bootstrapping is not performed. By default, this is set to 100. |
type |
the type of g-estimation to perform. It must be one of |
... |
additional arguments that may be passed to the underlying model. |
Value
gestimation
returns an object of class "gestimation"
.
The functions print
, summary
, and predict
can be used to interact with
the underlying glm
or geeglm
model.
An object of class "gestimation"
is a list containing the following:
call |
the matched call. |
formula |
the formula used in the model. |
model |
the underlying glm model. If the model performed a grid search, this will be renamed 'best.model' |
weights |
the estimated IP weights. |
type |
returns the value used for the 'type' parameter. |
ATE |
the estimated average treatment effect (risk difference). |
ATE.summary |
a data frame containing the ATE, SE, and 95% CI of the ATE. |
Examples
library(causaldata)
data(nhefs)
nhefs.nmv <- nhefs[which(!is.na(nhefs$wt82)), ]
nhefs.nmv$qsmk <- as.factor(nhefs.nmv$qsmk)
confounders <- c(
"sex", "race", "age", "education", "smokeintensity",
"smokeyrs", "exercise", "active", "wt71"
)
init_params(wt82_71, qsmk,
covariates = confounders,
data = nhefs.nmv
)
gest.model <- gestimation(nhefs.nmv, type = "one.linear", n.boot = 150)
gest.model$ATE.summary