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 |
data |
A |
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 |
groupInd |
A named vector with the group names and values. By
default, the treatment indicator defined in |
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 , where
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 |
nameY |
The name of the variable representing the outcome |
data |
The dataset passed to the function |
knots |
An object of class |
nameX |
The names of all covariates included in the model. They are
all variables implied by the formula |
nameS |
The prefix added to the covariate names when the basis
functions are generated. By default, it is equal to |
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 |
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