[R] mgcv gam predict problem

Philip Gautier philipgautier at gmail.com
Mon Mar 28 07:10:08 CEST 2011


Hello

I'm using function gam from package mgcv to fit splines.  When I try
to make a prediction slightly beyond the original 'x' range, I get
this error:

> A = runif(50,1,149)
> B = sqrt(A) + rnorm(50)
> range(A)
[1]   3.289136 145.342961
>
>
> fit1 = gam(B ~ s(A, bs="ps"), outer.ok=TRUE)
> predict(fit1, newdata=data.frame(A=149.9), outer.ok=TRUE)
Error in splineDesign(knots, x, ord, derivs, outer.ok = outer.ok) :
  the 'x' data must be in the range 3.14708 to 145.485 unless you set
'outer.ok = TRUE'
>

I've inserted the argument 'outer.ok=TRUE' as you can see, but it
hasn't helped.  How can I obtain this prediction?

Thanks,
Philip Gautier
Dept. of Mathematics and Statistics
American University, Washington, DC



More information about the R-help mailing list