Skip to content
Prev 2186 / 7420 Next

Problem with GAM

On Thu, 2011-06-02 at 15:55 +0100, momadou sow wrote:
Read ?vis.gam more carefully and note what is said about the `...`
argument for passing arguments on to, in this case, `contour()`. Take a
look at `?contour` and 

library(mgcv)
set.seed(0)
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))

## compare default with user-selected levels:
layout(matrix(1:2, ncol = 2))
vis.gam(g, view=c("x1","x2"), plot.type="contour")
vis.gam(g, view=c("x1","x2"), plot.type="contour", levels = seq(0.35,
1.15, by = 0.1))
layout(1)

(Ignore the warnings)
I think there is something else going on here - if you are displaying
the fitted model with +/- standard errors, which can't be done on a
contour plot - vis.gam issues a warning and switches to plotting via
`persp()`. If you meant change the colours on the `persp()` plot then I
think you are out of luck as the hi and lo colours are hard coded in the
function.
HTH

G