[Rd] evaluating variance functions in nlme
Nicholas Lewin-Koh
nikko at hailmail.net
Thu Jul 28 15:31:35 CEST 2005
Hi,
The reason I didn't send this to r-help is I am not interested in just
evaluating the variance function
for a particular set of data. That is not a big deal,
for your example,
pp<-predict(fm1,list(weight=c(15,16)))
vf<-pp^2*(coef(fm1$modelStruct$varFunc))
which is not the point. The point is that for any fit when I use my
function
mypredict(fm1,se.fit=TRUE)
To get the standard error I will need to evaluate an arbitrary variance
function,
Which means parsing the formula to get the terms and retriving those
terms from the input
dataframe, evaluating them properly and then assembling the coeficients
in the right way
for the variance function.
So this was not a how do I evaluate the variance function for model x
question,
but asking help for a generic function to evaluate variance functions
when doing prediction.
Thanks,
Nicholas
On Wed, 27 Jul 2005 20:58:27 -0700, "Spencer Graves"
<spencer.graves at pdf.com> said:
> Yes, this probably should go to R-help, and before you do that, I
> suggest you PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html. It can increase the
> likelihood you will get a useful reply relatively quickly.
>
> I tried the your two calls to "gnls", which of course produced errors
> for me as I don't have your data. The help page for "gnls" included an
> example that looked quite similar to me:
>
> > fm1 <- gnls(weight ~ SSlogis(Time, Asym, xmid, scal), Soybean,
> + weights = varPower())
> > summary(fm1)> fm1 <- gnls(weight ~ SSlogis(Time, Asym,
> xmid, scal), Soybean,
> + weights = varPower())
> > summary(fm1)
>
> Those results plus "str(fm1)" looked like they might help answer your
> question. However, I don't understand enough of what you are asking to
> say.
>
> If an answer might still be worth pursuing to you, I suggest you read
> the posting guide and submit a question following that model to r-help.
>
> spencer graves
>
> Nicholas Lewin-Koh wrote:
>
> > 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
> >
> > ______________________________________________
> > R-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
> --
> Spencer Graves, PhD
> Senior Development Engineer
> PDF Solutions, Inc.
> 333 West San Carlos Street Suite 700
> San Jose, CA 95110, USA
>
> spencer.graves at pdf.com
> www.pdf.com <http://www.pdf.com>
> Tel: 408-938-4420
> Fax: 408-280-7915
More information about the R-devel
mailing list