[R] 3-D Plotting of predictions from GAM/GAMM object

Paul Simonin paul.simonin at uvm.edu
Sat Nov 21 21:11:20 CET 2009


Hello all,
  Thank you for the previous assistance I received from this listserve!
  My current question is: How can I create an appropriate matrix of 
values from a GAM (actually a GAMM) to make a 3-D plot? This model is 
fit as a tensor product spline of two predictors and I have used it to 
make specific predictions by calling:

YoyRasPred6<-predict(YoyRas.Distribution.T.L.DT.gamm$gam,newdata=YoyRasSubset6,se.fit=T)

However, this type of command, I believe, produces only a vector of 
values. I have plotted these values and know how to do so in 2-D. 
However, I would like to create a 3-D plot, which I believe will require 
an entire matrix of predictions (z values) based on all possible inputs 
(x and y values). What is an efficient way to do this? It seems there 
must be a better way than simply predicting vector after vector ... as I 
am now, then piecing these together.

Thank you very much for any answers or assistance in general! Best wishes.

Sincerely,
Paul Simonin




More information about the R-help mailing list