smooth.construct.miso.smooth.spec: Constructor for monotone increasing SCOP-splines with an...

View source: R/uni.smooth.const-with-po.r

smooth.construct.miso.smooth.specR Documentation

Constructor for monotone increasing SCOP-splines with an additional 'start at zero' constraint

Description

This is a special method function for creating smooths subject to a monotone increasing constraint plus the smooths should pass through zero at the left-end point of the covariate range. This is similar to the pc argument to s in mgcv(gam) when pc=min(x), where x is a covariate. The smooth is built by the mgcv constructor function for smooth terms, smooth.construct. 'Zero intercept' identifiability constraints used for univariate SCOP-splines are substituted with a 'start at zero' constraint here. This smooth is specified via model terms such as s(x,k,bs="miso",m=2), where k denotes the basis dimension and m+1 is the order of the B-spline basis.

Usage

## S3 method for class 'miso.smooth.spec'
smooth.construct(object, data, knots)

Arguments

object

A smooth specification object, generated by an s term in a GAM formula.

data

A data frame or list containing the data required by this term, with names given by object$term. The by variable is the last element.

knots

An optional list containing the knots supplied for basis setup. If it is NULL then the knot locations are generated automatically.

Details

The constructor is not called directly, but as with gam(mgcv) is used internally.

A 'start at zero' constraint is achieved by setting 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.

If the knots of the spline are not supplied, then they are placed evenly throughout the covariate values with an exception of the m inner knots following the first inner knot that are joined with that first knot. This is done in order to avoid an otherwise plateau fit at the left-end region. If the knots are supplied, then the number of supplied knots should be k+m+2, and the range of the middle k-m knots must include all the covariate values.

Value

An object of class "miso.smooth".

Author(s)

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

See Also

smooth.construct.mpi.smooth.spec, smooth.construct.mifo.smooth.spec,

smooth.construct.mpd.smooth.spec, smooth.construct.mdcv.smooth.spec,

smooth.construct.mdcx.smooth.spec, smooth.construct.micv.smooth.spec,

smooth.construct.micx.smooth.spec

Examples

 
  ## Monotone increasing SCOP-spline examples with a start at zero constraint...
  ## passing through 0 at -1...
  require(scam)
  set.seed(7)
  n <- 100;
  x <- c(-1,runif(n-1)*4-1); ## starting at -1 for a function to be zero at a start
  z <- runif(n)
  y <- exp(4*x)/(1+exp(4*x)) -0.01798621+ z*(1-z)*5 + rnorm(100)*.4
  m1 <- scam(y~s(x,bs='miso')+s(z)) 
  plot(m1,pages=1)
  newd<- data.frame(x=-1,z=0)
  predict(m1,newd, type='terms')


## Not run: 
  ## passing through 0 at 0...
  set.seed(53)
  n <- 100;
  x <- c(0,runif(n-1)); ## starting at 0 for a function to be zero at a start
  z <- runif(n)
  y <- exp(3*x)/10-.1 + z*(1-z)*5 + rnorm(100)*.4
  m2 <- scam(y~s(x,bs='miso')+s(z)) 
  plot(m2,pages=1)
  newd<- data.frame(x=0,z=0)
  predict(m2,newd, type='terms')

    
## End(Not run)

scam documentation built on June 22, 2024, 10:43 a.m.