Description Usage Arguments Details See Also Examples
This is an internal function called by qgcomp
,
qgcomp.boot
, and qgcomp.noboot
,
but is documented here for clarity. Generally, users will not need to call
this function directly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 
f 
an r formula representing the conditional model for the outcome, given all
exposures and covariates. Interaction terms that include exposure variables
should be represented via the 
qdata 
a data frame with quantized exposures 
intvals 
sequence, the sequence of integer values that the joint exposure is 'set' to for estimating the msm. For quantile gcomputation, this is just 0:(q1), where q is the number of quantiles of exposure. 
expnms 
a character vector with the names of the columns in qdata that represent the exposures of interest (main terms only!) 
rr 
logical, estimate log(risk ratio) (family='binomial' only) 
main 
logical, internal use: produce estimates of exposure effect (psi) and expected outcomes under gcomputation and the MSM 
degree 
polynomial bases for marginal model (e.g. degree = 2 allows that the relationship between the whole exposure mixture and the outcome is quadratic. Default=1) 
id 
(optional) NULL, or variable name indexing individual units of observation (only needed if analyzing data with multiple observations per id/cluster) 
weights 
"case weights"  passed to the "weight" argument of

bayes 
use underlying Bayesian model ( 
MCsize 
integer: sample size for simulation to approximate marginal zero inflated model parameters. This can be left small for testing, but should be as large as needed to reduce simulation error to an acceptable magnitude (can compare psi coefficients for linear fits with qgcomp.zi.noboot to gain some intuition for the level of expected simulation error at a given value of MCsize) 
hasintercept 
(logical) does the model have an intercept? 
... 
arguments to glm (e.g. family) 
This function first computes expected outcomes under hypothetical interventions to simultaneously set all exposures to a specific quantile. These predictions are based on gcomputation, where the exposures are ‘quantized’, meaning that they take on ordered integer values according to their ranks, and the integer values are determined by the number of quantile cutpoints used. The function then takes these expected outcomes and fits an additional model (a marginal structural model) with the expected outcomes as the outcome and the intervention value of the exposures (the quantile integer) as the exposure. Under causal identification assumptions and correct model specification, the MSM yields a causal exposureresponse representing the incremental change in the expected outcome given a joint intervention on all exposures.
qgcomp.boot
, and qgcomp
1 2 3 4 5 6 7 8  set.seed(50)
dat < data.frame(y=runif(200), x1=runif(200), x2=runif(200), z=runif(200))
X < c('x1', 'x2')
qdat < quantize(dat, X, q=4)$data
mod < qgcomp:::msm.fit(f=y ~ z + x1 + x2 + I(x1*x2),
expnms = c('x1', 'x2'), qdata=qdat, intvals=1:4, bayes=FALSE)
summary(mod$fit) # outcome regression model
summary(mod$msmfit) # msm fit (variance not valid  must be obtained via bootstrap)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.