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

From: David Katz <david_at_davidkatzconsulting.com>
Date: Wed, 11 Jun 2008 16:16:54 -0700 (PDT)

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!

-- 
View this message in context: http://www.nabble.com/mgcv%3A%3Agam-error-message-for-predict.gam-tp17789318p17789318.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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 - 03:39:38 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