I have just fitted a lm model containing a bs smooth term. I asked Martin how I could see the estimated function. He said that such a possibility -- which is available in S-Plus' plot.gam -- was on your list of desirable functions. This is a vote to give it high priority. (I appreciate all your efforts!) Werner Stahel ------------------ This message was sent by --------------------------------- Werner Stahel http://stat.ethz.ch/~stahel Seminar fuer Statistik phone : +41 1 632 34 30 ETH-Zentrum, LEO fax : +41 1 632 12 28 CH-8092 Zurich, Switzerland meet me: Leonhardstr. 27 ----------------------------------------------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 7 Apr 2000, Werner Stahel wrote:> > I have just fitted a lm model containing a bs smooth term. > I asked Martin how I could see the estimated function. > He said that such a possibility -- > which is available in S-Plus' plot.gam -- > was on your list of desirable functions. > This is a vote to give it high priority.You *can* see the estimated function with predict(,type="terms") using eg model<-lm(y~bs(x,6)+z) tm<-predict(model,type="terms") plot(x,tm[,"bs(x, 6)"] (or for a curve plot) oo<-order(x) plot(x[oo],tm[oo,"bs(x, 6)"] If you want pointwise standard errors use predict(model, type="terms",se.fit=TRUE) -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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._