Description Usage Arguments Details Value Note Author(s) References See Also Examples

Generate the basis matrix for cubic regression splines with penalties on the second derivatives.

1 |

`x ` |
the predictor variable. Missing values are allowed. |

`df ` |
degrees of freedom, basically the dimension of the basis matrix. If supplied in the absence of |

`knots ` |
breakpoints that define the spline. These are generally automatically selected, and not defined by the user. See Details below. |

`intercept ` |
logical. If |

`fx ` |
logical. If |

`S ` |
penalty matrix, usually internally defined if |

The function has a usage similar to `bs`

and `ns`

in the splines package. It produces spline transformations, however using a parameterization that represents the splines fit in terms of values at the knots. A penalty matrix is also defined. The same results are returned by the related `smooth constructor`

in the package mgcv, which is in fact called internally.

The argument `knots`

defines a vector of knots within the range of the predictor `x`

, by default at equally-spaced quantiles. The penalization is defined on the second derivative of the function through a penalty matrix `S`

.

Similarly to `bs`

and `ns`

, setting `intercept=FALSE`

(default) determines the exclusion of the first transformed variables, and the corresponding first row and column in `S`

, thus avoiding identifiability issues during the model fitting. Note how the procedure of imposing identifiability constraints is different from that adopted by `smoothCon`

in the package mgcv, where a more complex reparameterization is produced.

A matrix object of class `"cr"`

. It contains the attributes `df`

, `knots`

, `intercept`

, `fx`

, and `S`

, with values that can be different than the arguments provided due to internal reset.

The function is primarily added here to specify penalized DLMs and DLNMs using the so-called *external* method, *i.e.* by including the penalty matrix in the argument `paraPen`

of the `gam`

regression function in mgcv (see `cbPen`

). However, this approach can be also used to fit standard uni-dimensional penalized cubic spline models as an alternative to the use of specific `smooth constructor`

, as it takes advantage of the use of prediction and plotting functions in dlnm.

Antonio Gasparrini <antonio.gasparrini@lshtm.ac.uk>, with internall calls to functions included in the package mgcv by Simon N. Wood.

Gasparrini A, Scheipl F, Armstrong B, Kenward MG. A penalized framework for distributed lag non-linear models. *Biometrics*. 2017;**73**(3):938-948. [freely available here]

Wood S. N. Generalized Additive Models: An Introduction with R. Chapman and Hall/CRC Press, 2006.

`ps`

for P-splines. `bs`

and `ns`

for B-splines and natural cubic splines, respectively. `cbPen`

for defining tensor-type bi-dimensional penalties in DLNMs. The related `smooth constructor`

for cubic regression spline smooths in mgcv. The `cb smooth constructor`

for cross-basis penalized spline smooths.

See `dlnm-package`

for an introduction to the package and for links to package vignettes providing more detailed information.

1 | ```
# to be added soon
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.