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)
List consisting of:
Matrix of the evaluated base, one row for each observation, one column for each base element.
Penalty square matrix, needed for the smoothing in the regression.
The observations x
given to the function.
The type
as given to the function.
The bnd
as given to the function, only needed with 'markov' type
.
Matrix that is also only needed with 'markov' type
for calculation of the fitted values.
Constant only needed with 'kriging' type
,
otherwise 'NA'.
The boolean value of the argument center
.
The variable included in the by
argument if available.
Name of the variable x
given to the function. Modified by its type.
Part of the penalty matrix.
Same as input
Original penalty P
before restructuring. Used for model selection.
Original mean of design matrix B
before centering.
Parameters of centering the covariate.
Number of penalized parameters in this covariate.
Number of unpenalized parameters in this covariate.
Data vector, matrix or data frame. In case of '2dspline', or 'krig' type
number of variables of x
has to be 2. More dimensions are allowed in 'ridge' and 'special' type
.
'markov' and 'random' type
require a vector of a factor.
Character string defining the type of base that is generated for the given variable(s) x
.
Further description of the possible options is given below in details
.
Number of basis functions of psplines. Default is 20.
For the 'special' type
the base B
and penalization matrix P
are entered manually. The data frame or matrix needs as many rows as observations in x
and as many columns as P
.
Square matrix that has to be provided in 'special' case and with 'markov' type
if no bnd
is given.
Object of class bnd
, required with 'markov' type if P
is not given.
See read.bnd
.
Logical to state whether the basis shall be centered in order to fit additive models with one central intercept.
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.
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.
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
The pspline
is now centered around its mean. Thus different results compared to old versions of expectreg
occure.
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
.
%\item{radial}{2-dimensional base, knots are subset of observations, % base is calculated as r^2*log(r) with r equalling % the euclidean distance between the current observation % and the knots. The base has size 50 if possible.}
'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
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")
Run the code above in your browser using DataLab