make.fastDR.formula | R Documentation |
make.fastDR.formula
is a function that helps the user write appropriate formulas for use in fastDR. Since
make.fastDR.formula(y.vars,
t.var,
x.vars=".",
weights.var=NULL,
key.var,
data=NULL)
y.vars |
a vector of strings indicating the names of the outcome variables (e.g. |
t.var |
a string giving the name of the treatment variable (e.g. |
x.vars |
a vector of strings giving the names of the covariates (e.g. |
weights.var |
a string giving the name of the observation weights (e.g. |
key.var |
a string giving the name of the variable containing the observation IDs (e.g. |
data |
a data frame that will be sent to |
Returns a list with appropriately formatted R formulas ready to be submitted to fastDR
Greg Ridgeway gridge@sas.upenn.edu
fastDR
# NHANES example from survey package
data(nhanes)
# add a unique ID to each row
nhanes$observationID <- 1:nrow(nhanes)
# recode the "treatment" (male) to a 0/1 indicator
nhanes$male <- as.numeric(nhanes$RIAGENDR==1)
# create a second random outcome
nhanes$Y2 <- rnorm(nrow(nhanes),0,1)
# drop unused variables
j <- which((names(nhanes) == "SDMVPSU") |
(names(nhanes) == "SDMVSTRA"))
nhanes <- nhanes[,-j]
my.forms <- make.fastDR.formula(y.vars=c("HI_CHOL","Y2"),
t.var="male",
x.vars=".",
weights.var="WTMEC2YR",
key.var="observationID",
data=nhanes)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.