library(mgcv)
set.seed(c(1,2,3))
n<-200
sig2<-4
x0 <- runif(n, 0, 1)
x1 <- runif(n, 0, 1)
x2 <- runif(n, 0, 1)
y<-x0^2+x1*x2 +runif(n,-0.3,0.3)
g<-gam(y~s(x0,x1,x2))
persp.gam(g,se=FALSE) # displays the prediction surface in x0, x1
# with x2 fixed at its mean and no confidence intervals
persp.gam(g, view=c("x1","x2"),slice=list(x0=0.75)) # a different slice
persp.gam(g, view=c("x0","x2"),slice=list(x1="x2"))->p
# a view of another slice is drawn and the surfaces saved
persp(p[[1]],theta=60) # another view of the main surface above
persp.gam(g, view=c("x1","x2"),slice=list(x0=0.75),theta=210,phi=40,mask=0.07)
# areas where there is no data not plotted
Run the code above in your browser using DataLab