Learn R Programming

scam (version 1.2-17)

shape.constrained.smooth.terms: Shape preserving smooth terms in SCAM

Description

As in mgcv(gam), shape preserving smooth terms are specified in a scam formula using s terms. All the shape constrained smooth terms (SCOP-splines) are constructed using the B-splines basis proposed by Eilers and Marx (1996) with a discrete penalty on the basis coefficients.

The univariate single penalty built-in shape constrained smooth classes are summarized as follows.

  • Monotone increasing SCOP-splines: bs="mpi". To achieve monotone increasing smooths this reparameterizes the coefficients so that they form an increasing sequence.

    For details see smooth.construct.mpi.smooth.spec.

  • Monotone decreasing SCOP-splines: bs="mpd". To achieve monotone decreasing smooths this reparameterizes the coefficients so that they form a decreasing sequence. A first order difference penalty applied to the basis coefficients starting with the second is used for the monotone increasing and decreasing cases.

  • Convex SCOP-splines: bs="cx". This reparameterizes the coefficients so that the second order differences of the basis coefficients are greater than zero.

    For details see smooth.construct.cx.smooth.spec.

  • Concave SCOP-splines: bs="cv". This reparameterizes the coefficients so that the second order differences of the basis coefficients are less than zero.

    For details see smooth.construct.cv.smooth.spec.

  • Increasing and convex SCOP-splines: bs="micx". This reparameterizes the coefficients so that the first and the second order differences of the basis coefficients are greater than zero. For details see smooth.construct.micx.smooth.spec.

  • Increasing and concave SCOP-splines: bs="micv". This reparameterizes the coefficients so that the first order differences of the basis coefficients are greater than zero while the second order difference are less than zero.

  • Decreasing and convex SCOP-splines: bs="mdcx". This reparameterizes the coefficients so that the first order differences of the basis coefficients are less than zero while the second order difference are greater. For details see smooth.construct.mdcx.smooth.spec.

  • Decreasing and concave SCOP-splines: bs="mdcv". This reparameterizes the coefficients so that the first and the second order differences of the basis coefficients are less than zero.

  • Increasing with an additional 'finish-at-zero' constraint SCOP-splines: bs="mifo". This sets the last (m+1) spline coefficients to zero. According to the B-spline basis functions properties, the value of the spline, f(x), is determined by m+2 non-zero basis functions, and only m+1 B-splines are non-zero at knots. Only m+2 B-splines are non-zero on any (k_i, k_{i+1}), and the sum of these m+2 basis functions is 1.

    For details see smooth.construct.mifo.smooth.spec.

  • Increasing with an additional 'start-at-zero' constraint SCOP-spline: bs="miso". This sets the first (m+1) spline coefficients to zero. According to the B-spline basis functions properties, the value of the spline, f(x), is determined by m+2 non-zero basis functions, and only m+1 B-splines are non-zero at knots. Only m+2 B-splines are non-zero on any (k_i, k_{i+1}), and the sum of these m+2 basis functions is 1.

    For details see smooth.construct.miso.smooth.spec.

  • SCOP-spline with positivity constraint: bs="po". This reparameterizes the coefficients so that there are positive. For details see smooth.construct.po.smooth.spec.

  • Decreasing/increasing SCOP-splines used with numeric 'by' variable: bs="mpdBy", bs="mpiBy". These work similar to mpd.smooth.spec, mpi.smooth.spec, but without applying an identifiability constraint ('zero intercept' constraint). Use when the smooth term has a numeric by variable that takes more than one value. For details see smooth.construct.mpd.smooth.spec, smooth.construct.mpi.smooth.spec.

  • Convex/concave SCOP-splines used with numeric 'by' variable: bs="cxdBy", bs="cvBy". These work similar to cx.smooth.spec, cv.smooth.spec, but without applying an identifiability constraint ('zero intercept' constraint). Use when the smooth term has a numeric by variable that takes more than one value.

    For details see smooth.construct.cx.smooth.spec,

    smooth.construct.cv.smooth.spec.

  • Decreasing/increasing and convex/concave SCOP-splines used with numeric 'by' variable: bs="mdcxBy", bs="mdcvBy", bs="micxBy", bs="micvBy".

    These work similar to mdcx.smooth.spec, mdcv.smooth.spec, micx.smooth.spec,
    micv.smooth.spec, but without applying an identifiability constraint ('zero intercept' constraint). Use when the smooth term has a numeric by variable that takes more than one value. For details see smooth.construct.mdcx.smooth.spec,

    smooth.construct.mdcv.smooth.spec,

    smooth.construct.micx.smooth.spec,

    smooth.construct.micv.smooth.spec.

  • Locally shape-constrained P-splines (LSCOP-splines): bs="lmpi". Locally increasing splines that are monotone increasing up to a specified change point and become unconstrained beyond that point. For details see smooth.construct.lmpi.smooth.spec.

For all types of the mixed constrained smoothing a first order difference penalty applied to the basis coefficients starting with the third one is used. Centring ('sum-to-zero') constraint has been applied to univariate SCOP-splines subject to monotonicity (convexity) constraints after implementing the 'zero intercept' identifiability constraint. This is achieved by dropping the first (constant) column of the spline model matrix and subtracting the corresponding column means from the elements of the remaining columns afterwards. 'Sum-to-zero' constraint orthogonalized the smooth to the model intercept term, thus avoiding confounding with the intercept. The standard errors of the estimated intercept become lower with the centring constraint.

Using the concept of the tensor product spline bases bivariate smooths under monotonicity constraint where monotonicity may be assumed on only one of the covariates (single monotonicity) or both of them (double monotonicity) are added as the smooth terms of the SCAM. Bivariate B-spline is constructed by expressing the coefficients of one of the marginal univariate B-spline bases as the B-spline of the other covariate. Double or single monotonicity is achieved by the corresponding re-parametrization of the bivariate basis coefficients to satisfy the sufficient conditions formulated in terms of the first order differences of the coefficients. The following explains the built in bivariate shape constrained smooth classes.

  • Double monotone increasing SCOP-splines: bs="tedmi".

    See smooth.construct.tedmi.smooth.spec for details.

  • Double monotone decreasing SCOP-splines: bs="tedmd".

  • Single monotone increasing SCOP-splines along the first covariate direction: bs="tesmi1".

  • Single monotone increasing SCOP-splines along the second covariate direction: bs="tesmi2".

  • Single monotone decreasing SCOP-splines along the first covariate direction: bs="tesmd1".

  • Single monotone decreasing SCOP-splines along the second covariate direction: bs="tesmd2".

  • SCOP-splines with double concavity constraint: bs="tecvcv".

    See smooth.construct.tecvcv.smooth.spec for details.

  • SCOP-splines with double convexity constraint: bs="tecxcx".

    See smooth.construct.tecxcx.smooth.spec for details.

  • SCOP-splines with convexity wrt the first covariate and concavity wrt the second covariate: bs="tecxcv". See smooth.construct.tecxcv.smooth.spec for details.

  • Decreasing along the first covariate and concave along the second covariate SCOP-splines: bs="tedecv". See smooth.construct.tedecv.smooth.spec for details.

  • Decreasing along the first covariate and convex along the second covariate SCOP-splines: bs="tedecx". See smooth.construct.tedecx.smooth.spec for details.

  • Increasing along the first covariate and concave along the second covariate SCOP-splines: bs="temicv". See smooth.construct.temicv.smooth.spec for details.

  • Increasing along the first covariate and convex along the second covariate SCOP-splines: bs="temicx". See smooth.construct.temicx.smooth.spec for details.

  • Convex along the second covariate SCOP-splines: bs="tescx".

    See smooth.construct.tescx.smooth.spec for details.

  • Concave along the second covariate SCOP-splines: bs="tescv".

    See smooth.construct.tescv.smooth.spec for details.

  • Tensor product interaction with increasing constraint along the first covariate and unconstrained along the second covariate: bs="tismi".

    See smooth.construct.tismi.smooth.spec for details.

  • Tensor product interaction with decreasing constraint along the first covariate and unconstrained along the second covariate: bs="tismd".

    See smooth.construct.tismd.smooth.spec for details.

Double penalties for the shape constrained tensor product smooths are obtained from the penalties of the marginal smooths. For the bivariate SCOP-splines with monotonicity (convexity) constraints along one covariate, the 'sum-to-zero' constraints are applied after dropping the first columns of the model matrix of the constrained marginal smooth. The basis for the unconstrained marginal must be non-negative over the region where the marginal monotonicity (convexity) is to hold. For the bivariate interaction smooths "tismi" and "tismd" the following identifiability steps are implemented: i) dropped the first column of the "mpi" ("mpd") marginals, ii) applied 'sum-to-zero' constraints to the marginals and to the unconstrained B-spline basis, iii) tensor product constructed. The 'sum-to-zero' constraint is applied to the final tensor product model matrix afters removing its first column when constructing bivariate SCOP-splines with double monotonicity (convexity). These result in faster convergence of the optimization routines and more stable intercept estimates.

Also linear functionals of smooths with shape constraints (increasing/decreasing and convex/concave) are supported. See linear.functional.terms.

Arguments

Author

Natalya Pya nat.pya@gmail.com

References

Pya, N. and Wood, S.N. (2015) Shape constrained additive models. Statistics and Computing, 25(3), 543-559

Pya, N. (2010) Additive models with shape constraints. PhD thesis. University of Bath. Department of Mathematical Sciences

Eilers, P.H.C. and B.D. Marx (1996) Flexible Smoothing with B-splines and Penalties. Statistical Science, 11(2):89-121

Wood S.N. (2017) Generalized Additive Models: An Introduction with R (2nd edition). Chapman and Hall/CRC Press

Wood, S.N. (2006) Low rank scale invariant tensor product smooths for generalized additive mixed models. Biometrics 62(4):1025-1036

See Also

s, smooth.construct.mpi.smooth.spec, smooth.construct.mpd.smooth.spec,

smooth.construct.cx.smooth.spec, smooth.construct.cv.smooth.spec,

smooth.construct.micx.smooth.spec, smooth.construct.micv.smooth.spec,

smooth.construct.mdcx.smooth.spec, smooth.construct.mdcv.smooth.spec,

smooth.construct.tedmi.smooth.spec, smooth.construct.tedmd.smooth.spec,

smooth.construct.tesmi1.smooth.spec, smooth.construct.tesmi2.smooth.spec,

smooth.construct.tesmd1.smooth.spec, smooth.construct.tesmd2.smooth.spec,

smooth.construct.tismi.smooth.spec, smooth.construct.tismd.smooth.spec

Examples

Run this code
## see examples for scam 

Run the code above in your browser using DataLab