| slseKnots {causalSLSE} | R Documentation |
Knots Creator for Basis Functions
Description
The function creates an object of class slseKnots for
semiparametric least squares models. It returns an object of
class slseKnots.
Usage
slseKnots(form, data, X, nbasis = function(n) n^0.3,
knots)
Arguments
form |
A formula that determines the covariates to include in the regression. It is a regular formula and only the right hand side is considered. |
data |
A |
nbasis |
A function to determine the number of basis functions. It has to be a function of one argument, the sample size. |
knots |
An optional list of knots. Each element of the list (one
for each covariate) is either a vector of numeric knots or it is
|
X |
An optional matrix of covariates. When provided, |
Details
The automatic selection is as follows. It is applied to each
variable created by the model.matrix of form except for
the intercept:
The number of knots is the ceiling of what the nbasis function
returns minus 1. Let p-1 be the number of knots. Then, we
compute the p+1 empirical quantiles of the variable for equally
spaced probabilities going from 0 to 1 and drop the first and last
ones. This is done using the function quantile with
type=1. We then remove the duplicated values and the ones equal
to either the min or the max of the variable. if the number
of remaining knots is equal to 0, the set of knots for this variable
is set to NULL.
For manual selection, see the vignette.
Value
It returns an object of class slseKnots. It is a list for which
the length and names are respectively the number of columns and the
column names of the model.matrix of form after
the intercept has been removed. Each element is a numeric vector of
knots, unless the number of knots is set to 0, in which case it is
NULL.
Examples
data(simDat3)
k <- slseKnots(Y ~ X1 * X2, data = simDat3)
k
## We can extract the set for one variable
k$X1