cslseModel {causalSLSE}R Documentation

Semiparametric Least Squares Estimator Model

Description

This function creates an object of class cslseModel or slseModel. The former is a list of slseModel objects, one for each treatment group. The model objects contain all specifications about the model being estimated including the starting knots used to construct the basis functions.

Usage

cslseModel(form, data, nbasis = function(n) n^0.3, 
           knots, groupInd=c(treated=1, nontreated=0))
slseModel(form, data, nbasis = function(n) n^0.3, 
           knots)

Arguments

form

A formula for the regression in the case of a simple spline regression, or two formulas separated by |, one for the outcome versus the treatment indicator and one of the confounders. See the details and examples below.

data

A data.frame that contains all variables included in form.

nbasis

A function to determined the number of basis functions. It has to be a function of one argument, the sample size.

knots

An optional list of knots. For cslseModel, it must be a named list using the group names (treated and nontreated). Each element of the list is also a list of length equal to the number of covariates. The choice for each covariate is NULL for no knots or a numeric vector for specific knots. If missing, the knots are automatically generated.

groupInd

A named vector with the group names and values. By default, the treatment indicator defined in form is equal to 1 for the treated and 0 for the nontreated. For now, these are the only allowed names, but the values can differ. In particular, the treatment indicator may be a factor with character values. See the example below.

Details

An object of class slseModel is a regression model with a dependent variable and a set of covariates. We assume that the model can be written as Y=f(X)+e, where f(x) is an unknown function of the covariates that we approximate using linear combinations of basis functions. For now, we only consider local linear splines defined by sets of knots, one for each covariate generated by the model.matrix of form. The knots are automatically determined unless specified by the user.

An object of class cslseModel is a list of slseModel objects, one for each treatment group. The assignment to a group is determined by a treatment indicator, which is the right-hand side variable in the formula to the left of | specified in form. The formula to the right of | is used by model.matrix to generate a set of confounders for each treatment group. See the example below and the vignette to more details.

Value

The function slseModel creates a semiparametric least squares model or a class slseModel object. It is a list with the following elements:

slseForm

The formula for the semiparametric estimation. It links the outcome variable with the matrix of basis functions.

form

The form argument passed to the function slseModel.

nameY

The name of the variable representing the outcome

data

The dataset passed to the function slseModel with the missing values, if any, omitted.

knots

An object of class slseKnots. It is the set of knots that define the local linear splines.

nameX

The names of all covariates included in the model. They are all variables implied by the formula form, which may include interactions and functions of variables.

nameS

The prefix added to the covariate names when the basis functions are generated. By default, it is equal to "U."

xlevels

When relevant, a list of levels of the factors included in the model.

na

A vector of integer representing the observations omitted because of missing values. It is NULL when there are no missing values.

Note that other elements may be present if a knots selection has been applied to the model.

The function cslseModel creates an object of class cslseModel. It is a list of slseModel objects, one for each treatment group. It also contains the following additional attributes:

treatedVar

The name of the variable in the dataset that represents the treatment indicator.

groupInd

A named vector with the value of the treatment indicator corresponding do each treatment group.

See Also

selSLSE for additional elements that can be included in the slseModel object, estSLSE to see how the model is estimated and slseKnots for the format of the knots

Examples

data(simDat3)

## Y is the outcome and Z the treatment indicator
## The confounders are X1, X2 and X1:X2:

mod1 <- cslseModel(Y ~ Z | ~ X1 * X2, data = simDat3)
mod1

## A simple SLSE for a regression model

mod2 <- slseModel(Y ~ X1 * X2, data = simDat3)
mod2

## If the treatment indicator differs from 0-1

data(simDat4)
mod3 <- cslseModel(Y ~ treat | ~ X1 * X2, data = simDat4,
                   groupInd = c(treated = "treat", nontreated = "notreat" ))
mod3

[Package causalSLSE version 0.3-1 Index]