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

Simon Wood s.wood at bath.ac.uk
Thu Jun 12 10:59:26 CEST 2008


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



More information about the R-help mailing list