[R] persp( ) Question

From: Greg Tarpinian <sasprog474_at_yahoo.com>
Date: Sat 07 May 2005 - 00:18:08 EST


I have successfully fitted the model

    loess.fit1 <- loess(response ~ X*Y)

and plotted it in 3D using

X.grid <- seq(0,10,length=100)
Y.grid <- seq(0,1000,length=100)
pred.loess1 <- predict(loess.fit1,

        expand.grid(x = X.grid, y = Y.grid)) persp(X.grid, Y.grid, pred.loess1, theta = 0, phi = 12)

I would like to add a series of points along the fitted surface at X.grid = 2, in red. The example in the online help uses

f <- function(x,y)
  { r <- sqrt(x^2+y^2); 10 * sin(r)/r }
trans3d <- function(x,y,z, pmat)
{
  tr <- cbind(x,y,z,1) %*% pmat
  list(x = tr[,1]/tr[,4], y= tr[,2]/tr[,4]) }
phi <- seq(0, 2*pi, len = 201)

r1 <- 7.725 # radius of 2nd maximum
xr <- r1 * cos(phi)
yr <- r1 * sin(phi)
lines(trans3d(xr,yr, f(xr,yr), res), 
      col = "pink", lwd=2)


to add points to the fitted mathematical surface. I have not been able to reproduce this sort of functionality partly because I don't have a functional representation of my surface and partly because I don't understand what trans3d( ) is doing. Any help would be greatly appreciated.

Kind regards,

    Greg                 

Stay connected, organized, and protected. Take the tour:



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat May 07 00:25:41 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:37 EST