Re: [R] mgcv::gam error message for predict.gam

From: Simon Wood <s.wood_at_bath.ac.uk>
Date: Thu, 12 Jun 2008 09:59:26 +0100

Wild extrapolation thought it is... it works for me with mgcv 1.4-0 and R 2.7.0 on linux:

 > test

       1         2               3                 4                5
20.73032 16.83549 59.42120 29.07759 13.09754

what mgcv and R versions are you using, and on what OS? (btw `gam.method' isn't an argument of mgcv:gam for any recent version, not that it makes any difference for gaussian with identity link.)

best,
Simon

On Thursday 12 June 2008 00:16, David Katz wrote:
> Sometimes, for specific models, I get this error from predict.gam in
> library mgcv:
>
> Error in complete.cases(object) : negative length vectors are not allowed
>
> Here's an example:
>
> model.calibrate <-
> gam(meansalesw ~ s(tscore,bs="cs",k=4),
> data=toplot,
> weights=weight,
> gam.method="perf.magic")
>
> > test <- predict(model.calibrate,newdata)
>
> Error in complete.cases(object) : negative length vectors are not allowed
>
> The data is shown below:
> > toplot[,c("meansalesw","tscore","weight")]
>
> meansalesw tscore weight
> 1 0.1275841 0.003446797 15224
> 2 0.1495748 0.004017158 15523
> 3 0.2245844 0.004375278 15520
> 4 0.2197668 0.004753941 15525
> 5 0.1317830 0.005049050 15524
> 6 0.2809621 0.005403199 15498
> 7 0.2933119 0.005764413 15529
> 8 0.4791150 0.006335145 15514
> 9 0.1833688 0.006617095 15528
> 10 0.3200599 0.007135850 15527
> 11 0.4931882 0.007781095 15529
> 12 0.4207684 0.008766088 15512
> 13 0.5928568 0.009731357 15514
> 14 0.8025296 0.010927579 15520
> 15 0.6286192 0.012004714 15513
> 16 0.7477922 0.014083143 15527
> 17 0.7251362 0.017382274 15531
> 18 1.1871948 0.025481173 15521
> 19 1.6495832 0.048264689 15524
> 20 5.1180227 0.131198022 15218
>
> > newdata
>
> tscore
> 1 0.5059341
> 2 0.4125522
> 3 1.4335818
> 4 0.7060673
> 5 0.3229316
>
> Thanks!

-- 

> Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
> +44 1225 386603 www.maths.bath.ac.uk/~sw283
______________________________________________ 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.
Received on Thu 12 Jun 2008 - 08:55:27 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 12 Jun 2008 - 09:30:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive