# heavyPS

##### Fit a penalized spline under heavy-tailed distributions

Fits a penalized spline to the supplied data.

- Keywords
- smooth

##### 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.

a list containing an image of the `heavyPS`

call that produced the object.

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.

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

the `heavy.family`

object used in the fitting process.

final estimate of the coefficients vector.

final scale estimate of the random error.

estimated smoothing parameter for the model (if requested).

fitted model predictions of expected value for each datum.

the residuals for the fitted model.

the penalized log-likelihood at convergence.

the effective number of parameters.

the minimized smoothing parameter selection score (weighted GCV).

the penalty term at convergence.

the number of iterations used in the iterative algorithm.

estimated weights corresponding to the assumed heavy-tailed distribution.

squared of scaled residuals.

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

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

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

```
# 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)
# }
```

*Documentation reproduced from package heavy, version 0.38.196, License: GPL (>= 2)*