Hello all, I'm trying to establish some confidence intervals on predictions I am making using>predict(nls(...))and predict.nls (unfortunately) does not utilize the se.fit option. A little more background is that I am trying to match the output with older SAS routines to maintain consistency. Because predict.nls does not provide se's for individual predictions, I have been using a method suggested on r-help previously (by P. Dalgaard) using deriv() and vcov(). Specifically, se.fit<-sqrt(apply(gradient, 1, function(x) sum(vcov(myNLSmodel)*outer(x,x)))) where I determine "gradient" by using deriv() and the points for which I am making the predictions. This works for predicting the confidence interval for the mean predicted Y, however, I need the confidence interval for the individual predicted Y. According to the stats text I looked at, I need to change the above formula to se.fit<-sqrt(apply(gradient, 1, function(x) sum(vcov(myNLSmodel)*outer(x,x))+NEWTERM)) where NEWTERM is NEWTERM<-myNLSmodel$m$deviance()/(nObservations - nParameters) So the problem is that while the confidence intervals are close to those provided by SAS, they are always smaller. This, in the end, makes a large difference for the application. Can anyone suggest how I might make the confidence intervals I calculate in R match up with those of SAS for nls? Thanks in advance, Ben Ridenhour ________________________________ Benjamin Ridenhour Centers for Disease Control & Prevention Atlanta, GA 30329 "If we knew what we were doing, it wouldn't be research." --Einstein [[alternative HTML version deleted]]
Ben Ridenhour wrote:> > Hello all, > I'm trying to establish some confidence intervals on predictions I am > making using > >>predict(nls(...)) > > and predict.nls (unfortunately) does not utilize the se.fit option. A > little more background is that I am trying to match the output with older > SAS routines to maintain consistency. Because predict.nls does not provide > se's for individual predictions, I have been using a method suggested on > r-help previously (by P. Dalgaard) using deriv() and vcov(). > Specifically, > > se.fit<-sqrt(apply(gradient, 1, function(x) > sum(vcov(myNLSmodel)*outer(x,x)))) > > where I determine "gradient" by using deriv() and the points for which I > am making the predictions. This works for predicting the confidence > interval for the mean predicted Y, however, I need the confidence interval > for the individual predicted Y. According to the stats text I looked at, I > need to change the above formula to > > se.fit<-sqrt(apply(gradient, 1, function(x) > sum(vcov(myNLSmodel)*outer(x,x))+NEWTERM)) > > where NEWTERM is > > NEWTERM<-myNLSmodel$m$deviance()/(nObservations - nParameters) > > So the problem is that while the confidence intervals are close to those > provided by SAS, they are always smaller. This, in the end, makes a large > difference for the application. Can anyone suggest how I might make the > confidence intervals I calculate in R match up with those of SAS for nls? > > Thanks in advance, > Ben Ridenhour > >Are you multiplying the confidence intervals by +/- 2 or are you using the critical value of the t statistic? Are your formulas above matching those suggested by http://support.sas.com/documentation/cdl/en/statug/59654/HTML/default/statug_nlin_sect026.htm ? -- View this message in context: http://www.nabble.com/Confident-interval-for-nls-predictions-tp25351953p25357586.html Sent from the R help mailing list archive at Nabble.com.