Hello all, I’ve fitted a bivariate smoothing model (with GAM) to some data, using two explanatory variables, x and y. Now I’d like to add the surface corresponding to my fit to a 3D scatterplot generated using plot3d().
My approach so far is to create a grid of x and y values and the corresponding predicted values and to try to use surface3d with that grid. grid <- expand.grid(x = seq(-1,1,length=20), y = seq(-1,1, length=20)) grid$z <- predict(fit.nonparametric, newdata=grid) surface3d(grid$x, grid$y, matrix(grid$z, nrow=length(grid$x), ncol=length(grid$y))) This however plots a number of surfaces that do not look like the fitted surface obtained by vis.gam(fit.nonparametric which actually looks a lot like the „truth“ (I’m using simulated data so I know the true regression surface). I think I’m using surface3d wrong but I can’t seem to spot my mistake. Thanks! ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.