heavy (version 0.38.19)

heavyPS: Fit a penalized spline under heavy-tailed distributions

Description

Fits a penalized spline to the supplied data.

Usage

heavyPS(x, y, family = Student(df = 4), nseg = 20, deg = 3, ord = 2,
  lambda = 1, method = c("GCV", "none"), ngrid = 200, control)

Arguments

x, y

vectors giving the coordinates of the points in the scatter plot. Missing values are deleted.

family

a description of the error distribution to be used in the model. By default the Student-t distribution with 4 degrees of freedom is considered.

nseg

number of segments used to divide the domain, this information is required to construct the sequence of knots. Default value is 20.

deg

the degree of the spline transformation. Must be a nonnegative integer. The default value is 3. The polynomial degree should be a small integer, usually 0, 1, 2, or 3. Larger values are rarely useful.

ord

the order of the roughness penalty. Default value is 2.

lambda

specifies the smoothing parameter for the fit. It is fixed if method="none". If method="GCV" then weighted generalized cross validation is used to choose an "optimal" smoothing parameter. The default value is 1.

method

the method for choosing the smoothing parameter lambda. If method="none", then lambda is 'fixed'. If method="GCV" (the default) then the smoothing parameter is chosen automatically using the weighted generalized cross validation criterion.

ngrid

number of elements in the grid used to compute the smoother. Only required to plot the fitted P-spline.

control

a list of control values for the estimation algorithm to replace the default values returned by the function heavy.control.

Value

an object of class heavyPS representing the fitted model. Generic functions print and summary, show the results of the fit.

The following components must be included in a legitimate heavyPS object.

call

a list containing an image of the heavyPS call that produced the object.

design

a list containing the B-spline basis matrix, the triangular factor of the penalty matrix and a numeric vector of knot positions with non-decreasing values.

method

one of "GCV" or "none", depending on the fitting criterion used.

family

the heavy.family object used in the fitting process.

coefficients

final estimate of the coefficients vector.

scale

final scale estimate of the random error.

lambda

estimated smoothing parameter for the model (if requested).

fitted.values

fitted model predictions of expected value for each datum.

residuals

the residuals for the fitted model.

plogLik

the penalized log-likelihood at convergence.

edf

the effective number of parameters.

gcv

the minimized smoothing parameter selection score (weighted GCV).

pen

the penalty term at convergence.

numIter

the number of iterations used in the iterative algorithm.

weights

estimated weights corresponding to the assumed heavy-tailed distribution.

distances

squared of scaled residuals.

xgrid

grid of x-values used to fit the P-spline.

ygrid

estimated curve on the x-grid, required to plot the fitted P-spline.

shape

estimated shape parameters, only available if requested.

References

Eilers, P.H.C., and Marx, B.D. (1996). Flexible smoothing using B-splines and penalties (with discussion). Statistical Science 11, 89-121.

Osorio, F. (2016). Influence diagnostics for robust P-splines using scale mixture of normal distributions. Annals of the Institute of Statistical Mathematics 68, 589-619.

Examples

Run this code
# NOT RUN {
data(life)
x <- life$income
y <- life$life
fit <- heavyPS(x, y, family = Student(df = 5), method = "GCV")
summary(fit)
par(pty = "s")
plot(x, y, xlab = "Per Capita Income", ylab = "Life Expectancy")
lines(fit$xgrid, fit$ygrid)
# }

Run the code above in your browser using DataLab