
Last chance! 50% off unlimited learning
Sale ends in
This is a special method function
for creating tensor product bivariate smooths convex in the second covariate which is built by the mgcv
constructor function for smooth terms, smooth.construct
.
It is constructed from a pair of single penalty
marginal smooths. This tensor product is specified by model terms such as s(x1,x2,k=c(q1,q2),bs="tescx",m=c(2,2))
,
where the basis for the first marginal smooth is specified in the second element of bs
.
# S3 method for tescx.smooth.spec
smooth.construct(object, data, knots)
An object of class "tescx.smooth"
. In addition to the usual
elements of a smooth class documented under smooth.construct
of the mgcv
library, this object contains:
A vector of 0's and 1's for model parameter identification: 1's indicate parameters which will be exponentiated, 0's - otherwise.
A matrix of identifiability constraints.
A smooth specification object, generated by an s
term in a GAM formula.
A data frame or list containing the values of the elements of object$term
,
with names given by object$term
.
An optional list containing the knots corresponding to object$term
.
If it is NULL
then the knot locations are generated automatically.
Natalya Pya <nat.pya@gmail.com>
Pya, N. and Wood, S.N. (2015) Shape constrained additive models. Statistics and Computing, 25(3), 543-559
smooth.construct.temicv.smooth.spec
smooth.construct.temicx.smooth.spec
smooth.construct.tedecv.smooth.spec
smooth.construct.tedecx.smooth.spec
smooth.construct.tescv.smooth.spec
if (FALSE) {
## tensor product `tescx' example
require(scam)
simu <- function(x,z) { sin(x) + 2*z^2 }
xs <-seq(0,1,length=30); zs <- seq(-1,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(5)
n <- 500
x <- runif(n)
z <- 2*runif(n)-1
f <- simu(x,z)
y <- f + rnorm(n)*.2
## fit model ...
b <- scam(y~s(x,z,bs="tescx"))
summary(b)
old.par <- par(mfrow=c(2,2),mar=c(4,4,2,2))
plot(b,se=TRUE)
plot(b,pers=TRUE,theta = 50, phi = 20);title("tescx")
plot(y,b$fitted.values,xlab="Simulated data",ylab="Fitted data",pch=".",cex=3)
persp(xs,zs,truth,theta = 50, phi = 20);title("truth")
par(old.par)
vis.scam(b,theta = 50, phi = 20)
}
Run the code above in your browser using DataLab