Learn R Programming

drgee (version 1.0.1)

drgeeData: Extracting Variables and Model Matrices for Generalized Estimating equations

Description

Given a main model, an outcome nuisance model and an exposure nuisance model drgeeData extracts the model variables and matrices from a data.frame or an environment object. It also performs some data cleaning and error checking.

Usage

drgeeData(oformula, eformula, iaformula = formula(~1),
              olink = c("identity", "log", "logit"),
              elink = c("identity", "log", "logit"),
              data = NULL, clusterid = NULL)

Arguments

oformula
An expression or formula for the outcome nuisance model. The outcome is identified as the response in this formula.
eformula
An expression or formula for the exposure nuisance model. The exposure is identified as the response in this formula.
iaformula
An expression or formula where the RHS should contain the variables that "interact" (i.e. are supposed to be multiplied with) with the exposure in the main model to create the terms associated with the parameters of interest. "1" will always a
olink
A character string naming the link function in the outcome nuisance model. Have to be "identity", "log" or "logit". Default is "identity".
elink
A character string naming the link function in the exposure nuisance model. Have to be "identity", "log" or "logit". Default is "identity". When olink="logit" this is replaced by
data
A data frame or environment containing the variables in iaformula, oformula and eformula. Default is NULL in which case the variables will be expected to be found in the environment of the
clusterid
A optional character string naming a cluster-defining variable in the data argument.

Value

  • drgeeData returns an object of class drgeeData containing
  • yThe outcome matrix.
  • aThe exposure matrix.
  • xThe matrix of of interactions defined in iaformula. This matrix will always contain a column with 1's.
  • axThe matrix of elementwise product(s) of a and each column in x.
  • vThe matrix of terms in the outcome nuisance model.
  • zThe matrix of terms in the exposure nuisance model.
  • yxThe matrix of elementwise product(s) of y and each column in x.
  • idA factor defining clusters. For independent observations, the number of levels equals the number of complete observations.
  • olinkA character string naming the link function in the outcome nuisance model.
  • elinkA character string naming the link function in the outcome nuisance model.
  • All matrix elements have rows corresponding to the complete observations in the original data.

encoding

latin1

Details

drgeeData is called by drgee and uses the oformula, eformula and iaformula arguments to extract data from a data.frame or environment object. The data can then be used to for outcome/exposure nuisance model based estimation or doubly robust estimation by calling obeFit, ebeFit or drFit respectively. drgeeData uses model.frame and model.matrix to remove incomplete observations and to convert factors to dummy variables. Factor outcome is only allowed when olink="logit" and then only when the factor has two levels. There are no restrictions on the exposure (RHS of eformula) or on factors appearing on the RHS of oformula, eformula and iaformula.

The class method summary.drgeeData produces strings for the formulas with terms referring to the columns in the produced design matrices.

See Also

drgee, model.frame and model.matrix.