From nikko at hailmail.net  Tue Jul 26 21:56:41 2005
From: nikko at hailmail.net (Nicholas Lewin-Koh)
Date: Tue, 26 Jul 2005 14:56:41 -0500
Subject: [Rd] evaluating variance functions in nlme
Message-ID: <1122407801.26649.239292761@webmail.messagingengine.com>

Hi,
I guess this is a final plea, and maybe this should go to R-help but
here goes.
I am writing a set of functions for calibration and prediction, and to
calculate standard 
errors and intervals I need the variance function to be evaluated at new
prediction points.
So for instance

fit<-gnls(Y~SSlogis(foo,Asym,xmid,scal),weights=varPower())
fit2<-gnls(Y~SSlogis(foo,Asym,xmid,scal),weights=varPower(form=~foo))

Now using fit or fit2 I would like to get the variance function
evaluated at new points. 
I have played with getCovariateFormula, and looked at Initialize.gnls,
summary etc.
but it is not clear to me how to evaluate the form component, especially
in the case of fit
above where form=~fitted(.), in any safe way.

I can grep for "fitted" in the formula eg.
grep("fitted",deparse(getCovariateFormula(fit$modelStruct$varFunc)))
and try to calculate predicted values from the model for the new points
but how to substitute back in the new terms?

I don't need this problem solved on a platter, I just need to unedrstand
an approach,
because my stabs are failing.

Thanks

Nicholas



[Rd] evaluating variance functions in nlme
Nicholas Lewin-Koh