[R] plot.gam

Thomas Lumley thomas at biostat.washington.edu
Fri Apr 7 19:46:07 CEST 2000


While it is relatively easy to plot the estimated curves that plot.gam
produces using predict(,type="terms") it seems to be very hard to get it
automated.

Getting the fitted function is easy. Getting the untransformed variable to
plot it against, though, is hard. 

Suppose we fit

	model<-lm(y~sin(x)+ns(z,3))


Given 'model' how can we extract x & z?  We can't work them out from
model.frame(model), which only contains transformed versions.  Even
assuming we can guess what the name of the variable is (not trivial --
which is the variable in  ns(z,df)? In ns(df=df,z)?), we don't know where
to find it.

It seems that we would have to assume that model$call$data contains the
variables if evaluated in the calling frame. This means that plot.gam
wouldn't necessarily work if called from inside a function, or if the
original data set had been changed since the model was fitted, or if the
default na.action had been changed or various other problems.

Ideas?

	-thomas

Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list