Last data update: 2014.03.03

R: Specifying a smooth term in the gcrq formula.
psR Documentation

Specifying a smooth term in the gcrq formula.

Description

Function used to define the smooth term (via P-splines) within the gcrq formula. The function actually does not evaluate a (spline) smooth, but simply it passes relevant information to proper fitter functions.

Usage

ps(x, monotone = 0, lambda = 0, pdiff = 3, ndx = NULL, deg = 3, 
    var.pen = NULL)

Arguments

x

The quantitative covariate supposed to have a nonlinear relationships with the quantiles. In growth charts this variable is typically the age.

monotone

Numeric value to set up monotonicity restrictions on the fitted smooth function

  • '0' = no constrain;

  • '1' = non decreasing smooth function;

  • '-1' = non increasing smooth function.

lambda

A supplied smoothing parameter for the smooth term. If it is a vector, cross validation is performed to select the ‘best’ value.

pdiff

The difference order of the penalty. Default to 3.

ndx

The number of intervals of the covariate range used to build the B-spline basis. If NULL, default, the empirical rule of Ruppert is used, namely min(n/4,40).

deg

The degree of the spline polynomial. Default to 3.

var.pen

A character indicating the varying penalty. See Details.

Details

When lambda=0 an unpenalized fit is obtained. The fit gets smoother as lambda increases, and for a very large value of lambda it approaches to a polynomial of degree pdiff-1. It is also possible to put a varying penalty to set a different amount of smoothing. For instance for a constant smoothing (var.pen=NULL) the penalty is lambda sum_k Δ^2_k where Delta_k is the k-th difference (of order pdiff) of the spline coefficients. When a varying penalty is set, the penalty becomes lambda sum_k Δ^2_k w_k. The weights w_k depend on var.pen; for instance var.pen="((1:k)^2)" results in w_k=k^2. See model m5 in examples of gcrq.

Value

The function simply returns the covariate with added attributes relevant to smooth term.

Author(s)

Vito M. R. Muggeo

References

For a general discussion on using B-spline and penalties in regression model see

Eilers PHC, Marx BD. (1996) Flexible smoothing with B-splines and penalties. Statistical Sciences, 11:89-121.

See Also

gcrq

Examples

##see ?gcrq

Results