1

I have this 3d plot that I draw in cran R

rb = rep(seq(0.1, 1, 0.1), 10)
ro = sort(rb)
lods = runif(100) #create a random LOD score

library(scatterplot3d)
lodsplot<- scatterplot3d(rb, ro, lods)

I found the maximum of the LOD score using max(lods) and thus, find the respective rb and ro. Now, I want to find the 95% CI of rb and ro. Assume max(lods) = 0.8 and respective rb and ro are 0.2 and 0.3, I thought of drawing a plane using:

lodsplot$plane3d(c(0.2, 0.3, 0.8))

and then find points above the plane (which I don't know how to do). Am I thinking correctly? Thank you!

Note:

If I just do a 2d plot, this is how i would do it:

plot(rb, lods, type = "l)
which(lods == max(lods))
limit = max(lods) - 1.92
abline(h = limit)
#Find intersect points:
above <- lr > limit
intersect.points <- which(diff(above) != 0)



    
Community
  • 1
  • 1
Meo
  • 140
  • 1
  • 9
  • You seem to be asking two questions here: How to find a confidence interval; How to find point above the plane. If so, maybe rephrase it so it's clearly what you want. – Dominic Comtois Jan 26 '16 at 18:36
  • I want to find confidence interval of rb and ro. The reason i mentioned point above the plane is because the method I used to find confidence interval in 2d plot is to find point above the abline. – Meo Jan 26 '16 at 18:39
  • 1
    I just edited the question to make it clearer! Thank you Dominic Comtois! – Meo Jan 26 '16 at 18:41

1 Answers1

1

You need to find the points that are above your plane defining the hypothesized 95% upper bound which you are suggesting has the equation:

 lods = 0.2+ 0.3*rb+ 0.8*ro

So calculate the item numbers for the points satisfying the implicit inequality:

high <- which(lods > 0.2+ 0.3*rb+ 0.8*ro)

And plot:

png()
lodsplot<- scatterplot3d(rb, ro, lods)
high <- which(lods > 0.2+ 0.3*rb+ 0.8*ro)
lodsplot$plane3d(c(0.2, 0.3, 0.8))
lodsplot$points3d( rb[high], ro[high], lods[high], col="red"); dev.off()

enter image description here

Notice that the plane3d function in scatterplot3d also accepts a result from lm or glm, so you could first calculate a model where lods ~ rb +ro and then calculate a 95% prediction surface using predict( ..., type="response") and color the points using this method. See: predict and multiplicative variables / interaction terms in probit regressions for a worked example on an equivalent procedure on an admittedly more complex model.

You can also do a search on [r] prediction surface and find other potentially useful answers such as this BenBolker suggestion to use rgl: "A: scatterplot3d for Response Surface in R"

Community
  • 1
  • 1
IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • 42-, can you please explain why the equation should be lods = 0.2 + 0.3*rb + 0.8*ro? And where does the 95% confidence interval come into play? I just want to understand more about the math behind this. Thank you so much for your help! – Meo Jan 27 '16 at 18:38
  • The implicit equation of the plane in your call to `plane3d` is `Z=0.2+ 0.3*X+ 0.8*Y`; where X,Y,Z have the role of rb,ro and lods respectively. I see that you were assuming a different order of the assignment, but if you look at the actual plane that was drawn you can see that the intercept is 0.2. The 95% CI would need to be calculated with `predict` using type="response using a grid of values over whatever range of X and Y values deemed appropriate. (I'm assuming that your choice of terminology re: the desired CI's was a bit confused. The cannot be CI's for `ro` and `rb`; they are fixed.) – IRTFM Jan 27 '16 at 18:58
  • Oh I see. I think I understood the plane3d wrong. What I want is to find the 95% confidence interval of lods (which is a log likelihood), and then find the matching rb and ro, which is the x and y coordinate of the points. I did find the solution though. I calculated the 95% confidence interval of lods, and then applied xyz.coords. Anyway, thank you 42-. Your use of points3d actually led me to the answer! – Meo Jan 27 '16 at 22:36