You can get around this by using the 'knots' argument to 'gam' to
specify p-spline knots which span the range over which you want to
predict. Alternatively use the "cr", "tp" or "ds" bases (splines with
derivative based penalties), which don't have this problem.
best,
Simon
On 28/03/11 06:10, Philip Gautier wrote:
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
______________________________________________
R-help@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
______________________________________________
R-help@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.