smooth.construct.tedmi.smooth.spec: Tensor product smoothing constructor for bivariate functions...

View source: R/bivar.smooth.const.R

smooth.construct.tedmi.smooth.specR Documentation

Tensor product smoothing constructor for bivariate functions with monotonicity constraints: increasing in both covariates

Description

This is a special method function for constructing tensor product bivariate smooths that are monotonically increasing in both covariates. It is called by the mgcv constructor function for smooth terms, smooth.construct. The tensor product smooth is constructed from a pair of marginal smooths, each with a single penalty and represented using B-spline basis functions. The smooth is specified using model terms such as s(x1, x2, k = c(q1, q2), bs = "tedmi", m = c(2, 2)), where q1 and q2 denote the basis dimensions of the marginal smooths.

Starting with scam version 1.2-15, the sum-to-zero constraint is applied to this smoother after imposing the SCOP constraints, including the SCOP identifiability constraint. This adjustment shifts the smooth vertically without changing its shape.

Usage

## S3 method for class 'tedmi.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 values of the elements of object$term, with names given by object$term.

knots

An optional list containing the knots corresponding to object$term. If it is NULL then the knot locations are generated automatically.

Value

An object of class "tedmi.smooth". In addition to the usual elements of a smooth class documented under smooth.construct of the mgcv library, this object contains:

p.ident

A vector of 0's and 1's for model parameter identification: 1's indicate parameters which will be exponentiated, 0's - otherwise.

Zc

A matrix of identifiability constraints.

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.tedmd.smooth.spec

Examples

 
## tensor product `tedmi' example 
require(scam)
simu <- function(x,z) { exp(4*x)/(1+exp(4*x))+2*exp(z-0.5)   } 
xs <- seq(-1,3,length=30); zs <- seq(0,1,length=30)
pr <- data.frame(x=rep(xs,30),z=rep(zs,rep(30,30)))
truth <- matrix(simu(pr$x,pr$z),30,30)
   
set.seed(2)
n <- 500
x <- runif(n)*4-1
z <- runif(n)
f <- simu(x,z)
y <- f + rnorm(n)*.1
## fit model ...
b <- scam(y~s(x,z,k=c(10,10),bs="tedmi"))
summary(b)
old.par <- par(mfrow=c(2,2),mar=c(4,4,2,2))
plot(b,se=TRUE)
plot(b,pers=TRUE,theta = 30, phi = 40);title("tedmi")
plot(y,b$fitted.values,xlab="Simulated data",ylab="Fitted data",pch=".",cex=3)
persp(xs,zs,truth,theta = 30, phi = 40);title("truth")
par(old.par)  
vis.scam(b,theta = 30, phi = 40)     
 

scam documentation built on Oct. 17, 2026, 1:07 a.m.