[S] problem with predict.gam

Renaud Lancelot (lancelot@telecomplus.sn)
Thu, 07 May 1998 21:39:24 +0100


Thanks to Song Qian, Phil Spector and Anne York who provided me the
answer to my question which was:

****************

> lo.temp <- gam(temp$y ~ lo(temp$x, span=0.5))
> lo.temp
Call:
gam(formula = temp$y ~ lo(temp$x, span = 0.5))

Degrees of Freedom: 23 total; 17.52406 Residual
Residual Deviance: 20.73873

I want to predict the fitted value for a particuliar x value Theta
> Theta
[1] 272.449

so I make a new data.frame:
> new <- data.frame(x=Theta)
> new
x
1 272.449

and I use the predict.gam() function:

> predict.gam(lo.temp, newdata=new)
Error in safe.predict.gam(object, newdata, type, se.fit, terms): Length
of variable 1 is 2 != length of row names (23)
Dumped

What is wrong ?

************************

The problem comes from that I did not pass the data.frame as an argument
to the gam function: I used gam(temp$y ~ lo(temp$x, span=0.5)) instead
of gam(y ~ lo(x, span=0.5), data=temp). With this last specification,
predict.gam() works perfectly.

Thanks again !

Renaud

-- 
Renaud Lancelot
Programme PPR
ISRA-LNERV
BP 2057 Dakar-Hann (Senegal)
tel (221) 832 49 02 - fax (221) 821 18 79
-----------------------------------------------------------------------
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