rb | R Documentation |
Based on given observations a matrix is created that creates a basis e.g. of splines or a markov random field that is evaluated for each observation. Additionally a penalty matrix is generated. Shape constraint p-spline bases can also be specified.
rb(x, type = c("pspline", "2dspline", "markov", "krig", "random",
"ridge", "special", "parametric", "penalizedpart_pspline"), B_size = 20,
B = NA, P = NA, bnd = NA, center = TRUE, by = NA, ...)
mono(x, constraint = c("increase", "decrease", "convex", "concave", "flatend"),
by = NA)
x |
Data vector, matrix or data frame. In case of '2dspline', or 'krig' |
type |
Character string defining the type of base that is generated for the given variable(s) |
B_size |
Number of basis functions of psplines. Default is 20. |
B |
For the 'special' |
P |
Square matrix that has to be provided in 'special' case and with 'markov' |
bnd |
Object of class |
center |
Logical to state whether the basis shall be centered in order to fit additive models with one central intercept. |
by |
An optional variable defining varying coefficients, either a factor or numeric variable. Per default treatment coding is used. Note that the main effect needs to be specified in a separate basis. |
constraint |
Character string defining the type of shape constraint that is imposed on the spline curve. The last option 'flatend' results in constant functions at the covariate edges. |
... |
Currently not used. |
Possible types
of bases:
Penalized splines made upon B_size
equidistant knots
with degree 3. The penalization matrix consists
of differences of the second order,
see diff
.
Tensor product of 2 p-spline bases with the same properties as above.
Gaussian markov random field with a neighbourhood
structure given by P
or bnd
.
'kriging' produces a 2-dimensional base, which is calculated as exp(-r/phi)*(1+r/phi)
where phi
is the maximum euclidean distance
between two knots divided by a constant.
A 'random' effect is like the 'markov' random field based on a categorial variable, and since there is no neighbourhood structure, P = I.
In a 'ridge' regression, the base is made from the independent variables while the goal is to determine significant variables from the coefficients. Therefore no penalization is used (P = I).
In the 'special' case, B
and P
are user defined.
A parametric effect.
Penalized splines made upon B_size
equidistant knots with degree 3. The penalization matrix consists of differences of the second order,
see diff
. Generally a P-spline of degree 3 with 2 order penalty can be splited in a linear trend and the deviation of the linear trend. Here only the wiggly deviation of the linear trend is kept. It is possible to combine it with the same covariate of type parametric
List consisting of:
B |
Matrix of the evaluated base, one row for each observation, one column for each base element. |
P |
Penalty square matrix, needed for the smoothing in the regression. |
x |
The observations |
type |
The |
bnd |
The |
Zspathelp |
Matrix that is also only needed with 'markov' |
phi |
Constant only needed with 'kriging' |
center |
The boolean value of the argument |
by |
The variable included in the |
xname |
Name of the variable |
constraint |
Part of the penalty matrix. |
B_size |
Same as input |
P_orig |
Original penalty |
B_mean |
Original mean of design matrix |
param_center |
Parameters of centering the covariate. |
nbp |
Number of penalized parameters in this covariate. |
nbunp |
Number of unpenalized parameters in this covariate. |
The pspline
is now centered around its mean. Thus different results compared to old versions of expectreg
occure.
Fabian Otto- Sobotka
Carl von Ossietzky University Oldenburg
https://uol.de
Thomas Kneib, Elmar Spiegel
Georg August University Goettingen
https://www.uni-goettingen.de
Sabine Schnabel
Wageningen University and Research Centre
https://www.wur.nl
Paul Eilers
Erasmus Medical Center Rotterdam
https://www.erasmusmc.nl
Fahrmeir L and Kneib T and Lang S (2009) Regression Springer, New York
quant.bundle
, expectreg.ls
x <- rnorm(100)
bx <- rb(x,"pspline")
y <- sample(10,100,replace=TRUE)
by <- rb(y,"random")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.