# [R] Correct variance for prediction intervals from nlme and gnls objects

Nicholas Lewin-Koh nikko at hailmail.net
Fri Jul 22 20:26:40 CEST 2005

```Hi,
An approximate prediction interval for f(x,b) from Rupert and Carrol
(1988) on pg 53
define q^2=g^2((f(x0,b),x0,a) + 1/N f'b(x0,b)^T S^-1 f'b(x0,b)

where g is the variance function and f'b is the derivative in terms of b
evaluted at x0
and S is
S=(1/N) Sum(1,N) f'b(xi,b)f'b(xi,b)^T/g^2((f(xi,b),a)

and the interval is defined at f(x0,b)+/- t(N-p,alpha/2) sqrt(sigma^2
q^2)

My question is if I were to fit the model
fit<-gnls(y~SSlogis(x,Asymp,xmid,scal),data=foo, weights=varPower)

is attr(fit\$parAssign,"varBetaFact") the correct quantity to use for
S^-1? or is (fit\$dim\$N/fit\$sigma^2)*fit\$VarBeta.
I looked in Pinero and Bates chapter 7.5 but i could not figure out
exactly how
varBeta is estimated in gnls. A pointer to a reference or some guidance

Thanks
Nicholas

PS Sorry for the sloppy notation, email is not latex

On Tue, 19 Jul 2005 11:48:18 -0500, "Douglas Bates" <dmbates at gmail.com>
said:
> On 7/19/05, Nicholas Lewin-Koh <nikko at hailmail.net> wrote:
> > Hello,
> > I am writing a set of functions to do prediction and calibration
> > intervals
> > for at least the subset of selfstarting models if not some more general
> > ones.
> >
> > I need to be able to extract the varFunction from a fit object
> > and evaluate it at a predicted point. Are there any examples around?
> >
> > Also in a self start model, say SSlogis, how would I get the gradient
> > at a point?
>
> I think that the output of
>
> example(SSlogis)
>
> should answer that question for you.

```