At the moment I'm trying to interpret the green and red dashed lines in a contour plot when visualizing a generalized additive model (GAM) with R. These two lines seem to be something like confidence bands, but I'm not sure how to interpret these dashed lines in a contour plot.

Does anybody have experiences with contour plots using R, specifically when fitting GAM?

  • 2
    $\begingroup$ Some example code would help a lot. $\endgroup$ – mpiktas Aug 24 '11 at 12:39
  • $\begingroup$ There are several ways to obtain a contour plot in R, and there are several ways of fitting a GAM in R. As @mpiktas indicated: please (give some example code to) clarify your question. $\endgroup$ – Nick Sabbe Aug 24 '11 at 18:12

I'm guessing that you mean the red and green contours in the last example figure produced by


which looks likes this:

enter image description here

The generalized additive model produces a fitted surface defined by the black contours. The help file (from ?plot.gam) says:

...surfaces at +1 and -1 standard errors are contoured and overlayed on the contour plot for the estimate.

You have an estimated SE at each position (x1,x2); adding one SE to the fitted surface, at each point (x1,x2), gives you another surface, which is depicted using the green dotted contours. Subtracting one SE from the fitted surface gives you another surface, which is depicted using the red dashed curves.

  • 1
    $\begingroup$ Note: I googled "contourplot gam"; the first result was the help file for plot.gam in package mgcv. I ran library(mgcv);example(plot.gam) within R and saw the figure above, at which point the question made sense. $\endgroup$ – Karl Aug 24 '11 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.