[R] GAM, how to set qr=TRUE
Simon Wood
s.wood at bath.ac.uk
Fri May 4 14:44:32 CEST 2012
Which version of gam are you using (i.e. which package and version number?)
prediction with fitted gam objects should call predict.gam, and I'm not
quite sure why this is not happening here (you do have the mgcv or gam
loaded while trying to predict, I suppose?).
On 03/05/12 22:56, Ben quant wrote:
> Hello,
>
> I don't understand what went wrong or how to fix this. How do I set qr=TRUE
> for gam?
>
> When I produce a fit using gam like this:
>
> fit = gam(y~s(x),data=as.data.frame(l_yx),family=family,control =
> list(keepData=T))
>
> ...then try to use predict:
> (see #1 below in the traceback() )
>
>> traceback()
> 6: stop("lm object does not have a proper 'qr' component.\n Rank zero or
> should not have used lm(.., qr=FALSE).") at #81
> 5: qr.lm(object) at #81
> 4: summary.glm(object, dispersion = dispersion) at #81
> 3: summary(object, dispersion = dispersion) at #81
> 2: predict.glm(fit, data.frame(x = xx), type = "response", se.fit = T,
> col = prediction_col, lty = prediction_ln) at #81
> 1: predict(fit, data.frame(x = xx), type = "response", se.fit = T,
> col = prediction_col, lty = prediction_ln) at #81
>
> ...I get this error:
>
> Error in qr.lm(object) : lm object does not have a proper 'qr' component.
> Rank zero or should not have used lm(.., qr=FALSE).
>
> I read this post: http://tolstoy.newcastle.edu.au/R/devel/06/04/5133.html
>
> So I tried adding qr=T to the gam call but it didn't make any difference.
> This is how I did it:
>
> fit = gam(y~s(x),data=as.data.frame(l_yx),family=family,control =
> list(keepData=T),qr=T)
>
> Its all very strange because I've produced fits with this data may times
> before with no issues (and never having to do anything with the qr
> parameter. I don't understand why this is coming up or how to fix it.
>
> PS - I don't think this matters, but I am calling a script called
> FunctionGamFit.r like this:
> err = system(paste('"C:\\Program Files\\R\\R-2.14.1\\bin\\R.exe"', 'CMD
> BATCH FunctionGamFit.r'), wait = T)
> ...to produce the fit.
>
> Thanks for any help!
>
> ben
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Simon Wood, Mathematical Science, University of Bath BA2 7AY UK
+44 (0)1225 386603 http://people.bath.ac.uk/sw283
More information about the R-help
mailing list