drgeeData: Extracting Variables and Model Matrices for Generalized...

Description Usage Arguments Details Value Author(s) See Also

View source: R/drgeeData.R

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

1
2
3
4
5
6
7
drgeeData(outcome, exposure,
          oformula, eformula, iaformula = formula(~1),
          olink = c("identity", "log", "logit"),
          elink = c("identity", "log", "logit"),
          data, subset = NULL,
          estimation.method = c("dr", "o", "e"),
          cond = FALSE, clusterid, clusterid.vcov)

Arguments

outcome

The outcome as a variable or as a character string naming a variable in the data argument. If it is not found in the data argument, it will be searched for in the calling frame. If missing, the outcome is assumed to be the response of oformula.

exposure

The exposure as a variable or as a character string naming a variable in the data argument. If it is not found in the data argument, it will be searched for in the calling frame. If missing, the outcome is assumed to be the response of eformula.

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 added. Default value is no interactions, i.e. formula(~1).

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 "logit".

data

A data frame or environment containing the variables in iaformula, oformula and eformula. If missing, variables are expected to be found in the calling frame.

subset

An optional vector defining a subset of the data to be used.

estimation.method

A character string naming the desired estimation method. Choose "o" for O-estimation, "e" for E-estimation or "dr" for DR-estimation. Default is "dr".

cond

A logical value indicating whether the nuisance models should have cluster-specific intercepts. If cond=TRUE the design matrices for the nuisance models do not have an intercept. Requires a clusterid argument.

clusterid

A cluster-defining variable or a character string naming a cluster-defining variable in the data argument. If it is not found in the data argument, it will be searched for in the calling frame. If missing, each observation will be considered to be a separate cluster. This argument is required when cond = TRUE.

clusterid.vcov

A cluster-defining variable or a character string naming a cluster-defining variable in the data argument to be used for adding contributions from the same cluster. These clusters can be different from the clusters defined by clusterid. However, each cluster defined by clusterid needs to be contained in exactly one cluster defined by clusterid.vcov. This variable is useful when the clusters are hierarchical.

Details

drgeeData is called by drgee and gee to extract data from a data.frame or environment object. The data can then be used to for O-estimation, E-estimation or DR-estimation. drgeeData uses model.frame and model.matrix to remove incomplete observations and to convert factors to dummy variables. It also performs check the supplied data for errors or inconsistencies.

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

Value

drgee.data returns an object of class drgeeData containing

used.rows

The rows numbers in the original data for the used rows (after subset selection and exlusions).

orig.order

The original order of the observations.

y

The outcome matrix.

a

The exposure matrix.

x

The matrix of of interactions defined in iaformula. This matrix will always contain a column with 1's.

ax

The matrix of elementwise product(s) of a and each column in x.

v

The matrix of terms in the outcome nuisance model.

z

The matrix of terms in the exposure nuisance model.

yx

The matrix of elementwise product(s) of y and each column in x.

id

A factor defining clusters. For independent observations, the number of levels equals the number of complete observations.

clustname

A string for the name of the cluster defining variable.

y.names

A string for the name of the outcome.

a.names

A string for the name of the exposure.

x.names

A string vector for the variable names in x.

ax.names

A string vector for the variable names in ax.

v.names

A string vector for the variable names in v.

z.names

A string vector for the variable names in z.

yx.names

A string vector for the variable names in yx.

olink

A character string naming the link function in the outcome nuisance model.

elink

A character string naming the link function in the outcome nuisance model.

cond

A logical value indicating whether cluster-specific intercepts should be assumed. If TRUE, the is no column for the intercept in v and z. Outcome concordant will also be removed.

oterms

The terms object corresponding to the outcome nuisance model.

eterms

The terms object corresponding to the exposure nuisance model.

Author(s)

Johan Zetterqvist, Arvid Sjölander

See Also

drgee, gee, model.frame and model.matrix.


drgee documentation built on Jan. 11, 2020, 9:43 a.m.