[R] Prediction and confidence intervals from predict.drc
David Winsemius
dwinsemius at comcast.net
Tue Sep 7 05:11:31 CEST 2010
On Sep 6, 2010, at 7:54 PM, Brant Inman wrote:
> R-helpers,
>
> I am using the package "drc" to fit a 4 parameter logistic model.
> When I
> use the predict function to get prediction on a new dataset, I am not
> getting the requested confidence or prediction intervals. Any idea
> what
> is going on? Here is code to reproduce the problem:
>
> ---
>
> library(drc)
>
> # Fit model to existing dataset in package
> spinach.model <- drm(SLOPE~DOSE, data = spinach, fct = LL.4())
(Comparing to the predict example code.) You did not specify a CURVE
argument. Not sure what effect that would have.
>
> #Generate new fake dataset
> newdt <- data.frame(matrix(c(seq(0, 150, 0.1), rep(NA, 1501)), ncol=2,
> byrow=F))
> colnames(newdt) <- c('DOSE', 'SLOPE')
You did not include a CURVE variable. But this provokes nary a
complaint. I wondered if the estimates may be an unlabeled mixture
from the 5 CURVEs
>
> #Use predict function to get prediction and confidence intervals
> pred <- predict(spinach.model, interval='prediction', newdata=newdt)
You did not specify CURVE. The example uses one:
predict(spinach.model1, data.frame(dose=2, CURVE=c("1", "2", "3")),
interval = "prediction")
With your object:
> head(predict(spinach.model, data.frame(dose=2, CURVE=c("1")),
+ interval = "prediction"))
Prediction Lower Upper
0.3500492 -0.2790351 0.9791336
With the original example:
> predict(spinach.model1, data.frame(dose=2, CURVE=c("1", "2", "3")),
+ interval = "confidence")
Prediction Lower Upper
[1,] 0.9048476 0.8552178 0.9544775
[2,] 0.4208307 0.3626741 0.4789873
[3,] 0.5581673 0.4971838 0.6191509
>
With your object
> predict(spinach.model, data.frame(dose=2, CURVE=c("1")),
+ interval = "confidence")
Prediction Lower Upper
0.3500492 0.2673464 0.4327521
> conf <- predict(spinach.model, interval='confidence', newdata=newdt)
> head(pred); head(conf)
>
> ---
>
> Examining the output shows the point estimates but not the intervals.
> Would like the intervals.
>
>
> I am using the most recent versions of R and drc on Windows XP.
>
> Thanks,
>
> Brant
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list