make.fastDR.formula: Make formulas appropriate for using in fastDR

View source: R/fast.dr.R

make.fastDR.formulaR Documentation

Make formulas appropriate for using in fastDR

Description

make.fastDR.formula is a function that helps the user write appropriate formulas for use in fastDR. Since

Usage

make.fastDR.formula(y.vars,
                    t.var,
                    x.vars=".",
                    weights.var=NULL,
                    key.var,
                    data=NULL)

Arguments

y.vars

a vector of strings indicating the names of the outcome variables (e.g. c("y1","y2"))

t.var

a string giving the name of the treatment variable (e.g. "treat")

x.vars

a vector of strings giving the names of the covariates (e.g. c("X1","X2")). x.vars may also take the value ".", which will select all variables in data not otherwise given in the other components

weights.var

a string giving the name of the observation weights (e.g. "samp.weights")

key.var

a string giving the name of the variable containing the observation IDs (e.g. "caseID")

data

a data frame that will be sent to fastDR

Value

Returns a list with appropriately formatted R formulas ready to be submitted to fastDR

Author(s)

Greg Ridgeway gridge@sas.upenn.edu

See Also

fastDR

Examples

# 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)


gregridgeway/fastDR documentation built on July 28, 2023, 12:34 p.m.