Learn R Programming

expectreg (version 0.16)

base: Creates base for a regression based on covariates

Description

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.

Usage

base(x, type = c("pspline", "2dspline", "markov", "radial", "krig", 
                 "random", "ridge", "special", "parametric"),
                 B = NA, P = NA, bnd = NA, center =TRUE)

Arguments

x
Data vector, matrix or data frame. In case of '2dspline', 'radial' 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
type
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.
B
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.
P
Square matrix that has to be provided in 'special' case and with 'markov' type if no bnd is given.
bnd
Object of class bnd, required with 'markov' type if P is not given. See read.bnd.
center
Logical to state whether the basis shall be centered in order to fit additive models with one central intercept.

Value

  • List consisting of:
  • BMatrix of the evaluated base, one row for each observation, one column for each base element.
  • PPenalty square matrix, needed for the smoothing in the regression.
  • xThe observations x given to the function.
  • typeThe type as given to the function.
  • bndThe bnd as given to the function, only needed with 'markov' type.
  • ZspathelpMatrix that is also only needed with 'markov' type for calculation of the fitted values.
  • phiConstant only needed with 'kriging' type, otherwise 'NA'.

Details

Possible types of bases: ll{ pspline Penalized splines made upon 20 equidistant knots and with degree 2. The penalization matrix consists of differences of the second order, see diff. 2dspline Tensor product of 2 p-spline bases with the same properties as above. markov Gaussian markov random field with a neighbourhood structure given by P or bnd. 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. krig 'kriging' produces basically the same base as 'radial', but the base is calculated as exp(-r/phi)*(1+r/phi) where phi is the maximum euclidean distance between two knots divided by a constant. random A 'random' effect is like the 'markov' random field based on a categorial variable, and since there is no neighbourhood structure, P = I. ridge 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). special In the 'special' case, B and P are user defined. parametric A parametric effect. }

References

Fahrmeir L and Kneib T and Lang S (2009) Regression Springer, New York

See Also

expectile.restricted, expectile.laws

Examples

Run this code
x <- rnorm(100)

bx <- base(x,"pspline")

y <- sample(10,100,replace=TRUE)

by <- base(y,"random")

Run the code above in your browser using DataLab