You can use the well-known Taylor series approximation to the
variance of an arbitrary function:
Var( f(X) ) ~= Sum( s[i]^2*D2[i] ) + 2*Sum( Sum( s[i,j]*D[i]*D[j] ) )
where D2[i] is the second partial derivative of f(x) with respect
to the ith parameter and D[j] is the first partial derivative of f(x)
with respect to the jth parameter. The indices on the summations
for 2*Sum( Sum( ... ) ) are i=1 to (p-1) and j>i, respectively,
where p denotes the total number of parameters in the model. Also,
s[i]^2 denotes the ith diagonal element of the variance-covariance
matrix for the model, and s[i,j] denotes an off-diagonal element
of the same matrix. You should be able to use vcov( ) to extract
the variance-covariance matrix of your fitted model.
This approximation will estimate the functional form of the variance
of f(X). To get the approximate variance of f(X) for a specific
value of X simply plug in X=x.
After this, you will need to add the estimated variance of the
residuals and take the square root to obtain the standard error
used in calculating prediction intervals. I have used this approach
for some highly nonlinear functions in the past, and the approximation
is only "good" when it is reasonable to assume that E(f(x)) ~=
f(E(x)).
[This assumption is present in the derivation of the Taylor
approximation.] When this is not a reasonable assumption, the
approximation can be horrible. In other words, the more locally linear
your nonlinear function is, the better the approximation will work.
Hope this helps,
david paul
-----Original Message-----
From: Enrique Portilla [mailto:portillae at marlab.ac.uk]
Sent: Thursday, August 14, 2003 9:28 AM
To: R-help at stat.math.ethz.ch
Subject: [R] nls confidence intervals
Hi,
Does anyone know how to compute the confidence prediction intervals for a
nonlinear least squares models (nls)?
I was trying to use the function 'predict' as I usually do for other
models
fitting (glm, lm, gams...), but it seems that se.fit, and interval
computation is not implemented for the nls...
Cheers
Enrique
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fisheries Research Services,
Marine Laboratory,
Victoria Road,
Torry,
Aberdeen, UK.
Tel. 44 (0) 1224 295314
~~~~~~~~~~~~~~~~~~~~~~~~~~~
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help