Re: [S] Fw: difference between predict

Prof Brian D Ripley (ripley@stats.ox.ac.uk)
Tue, 25 Aug 1998 12:12:24 +0100 (BST)


On Tue, 25 Aug 1998, Prof Brian D Ripley wrote:

> On Tue, 25 Aug 1998, alain Le Tertre wrote:
>
> > I have received some e-mail from people who need the answer, but no answer,
> > even from s-help.
> > So, i'll resend my question.
> > -----Original Message-----
> > From: alain Le Tertre <alain@worldnet.fr>
> > To: s-news <s-news@wubios.wustl.edu>
> > Date: mercredi 29 juillet 1998 10:24
> > Subject: difference between predict
> >
> >
> > >In S-plus 4 guide to statistics p 221, "Specifying type="terms" allows you
> > >to compute the component of the prediction for each term separately.
> > Summing
> > >the columns of the matrix and adding the constant (intercept) term is
> > >equivalent to specifying type="link"".
> > >So try :
> > >zzz_gam(Kyphosis ~ poly(Age, 2) + s(Start), data = kyphosis)
> > >cbind(predict(zzz,type="link"),zzz$coef[1]+rowSums(predict(zzz,type="terms"
> > )
> > >))
> > >give you :
> > >1 1.6582944 2.059893
> > > 2 1.1161389 1.517737
> > > 3 1.6671144 2.068713
> > > 4 1.1938420 1.595441
> > > 5 0.8517588 1.253357
> > > 6 0.8213737 1.222972
> > > 7 1.0687632 1.470362
> > > 8 1.0036325 1.405231
> > > 9 1.1289169 1.530515
> > >10 1.2703754 1.671974
> > >11 1.1993687 1.600967
> > >[snip]
> > >Did i misunderstand something?
>
> Yes, you forgot what you did. That is not the answer I get in any version
> of S-PLUS, including 4.0. For predict(zzz,type="terms") I get

Clarification: I misread your code, but my reasoning is correct. (Why are
you so adverse to spaces? It makes S code so much harder for humans to
parse.) The constant mentioned is not zzz$coef[1], nor is the
`(Intercept)', it is the constant attribute.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

----------------------------------------------------------------------- This message was distributed by s-news@wubios.wustl.edu. To unsubscribe send e-mail to s-news-request@wubios.wustl.edu with the BODY of the message: unsubscribe s-news