Skip to content
Prev 201102 / 398503 Next

3-D Plotting of predictions from GAM/GAMM object

On 21/11/2009 3:11 PM, Paul Simonin wrote:
You can use expand.grid() to generate a dataframe corresponding to the 
grid of values, then reshape the results into a matrix.   I don't have 
your data to show a fit, but this shows how the graphing is done.

 > x <- 1:10
 > y <- 1:12
 > grid <- expand.grid(x=x, y=y)  # give names to get named columns
 > z <- matrix(apply(grid, 1, prod), nrow=10) # use predict instead here
 > library(rgl)
 > persp3d(x,y,z, col="red")

Duncan Murdoch