I have a bit of a bizarre question, but hoping someone can help me. I am attempting to create a surface plot of the bottom of a lake and then add some points showing plant frequency for a visual of where aquatic plants are occurring throughout the lake.
Right now I am working on creating the surface plot in both scatterplot3d and wireframe using the scatterplot3d and lattice packages, respectively, in R. In order to achieve the type of plot I am interested in I have converted the depths to negative values (imagine the lake's water surface as 0 on the z-axis), then created a loess model of depth by latitude and longitude coordinates. However, one problem that I'm having is that the loess model predicts positive depths (which is, of course, impossible in a lake; one can only go down into the water column from a depth of 0).
Example
x <- seq(1,100,1)
y <- seq(1,100,1)
depth <- rbeta(100, 1, 50)*100
depth <- -depth
dep.lo <- loess(depth~x*y, degree=2, span=.25) # this shows a big warning, but it works
coord.fit <- expand.grid(x=x, y=y)
coord.fit$depth <- as.numeric(predict(dep.lo, newdata=coord.fit))
range(coord.fit$depth)
# -14.041011 6.986745
As you can see, my depth goes from -14 to almost 7. Is there a way to set an upper bound on a loess model so that my model doesn't achieve these sorts of positive values?
Thanks for any help,
Paul