Without seeing the data and results it's hard to say. mgcv::predict.gam is already `safe' so that's not the issue. It's also pretty heavily tested, so a problem with that function wouldn't be the first place I'd look. How `large positive' are the predictions relative to the observed response? How well do the x1,x2 cover the unit square? Smoothers often do not extrapolate well even over quite modest distances...
Slight negative predictions are not really surprising, given that the model you have fitted allows -ve fitted values. You could fix this by using a log link (with gaussian or Gamma family). If you think the results are not right, I can take a look at what's happening if you send me the data, R and mgcv version numbers and exact commands generating the problem (`off line'). I would not use the data for any other purpose of course. It may take a little while to get to however, as I've one or two local difficulties here at the moment. best, Simon On Wednesday 08 August 2007 16:58, Johnson, Elizabeth wrote: > I am fitting a two dimensional smoother in gam, say junk = > gam(y~s(x1,x2)), to a response variable y that is always positive and > pretty well behaved, both x1 and x2 are contained within [0,1]. > > > > I then create a new dataset for prediction with values of (x1,x2) within > the range of the original data. > > > > predict(junk,newdata,type="response") > > > > My predicted values are a bit strange (some negative and some large > positive values). > > > > When I plot the predicted surface, it looks well behaved with no strange > dips/etc. > > > > Could it be a problem with the predict command? > > Is there a "safe" version of predict for higher-dimensional smoothers in > gam? > > > > Elizabeth Johnson > > Research Associate > > Johns Hopkins Unviersity > > Department of Biostatistics > > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@stat.math.ethz.ch 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 Sciences, University of Bath, Bath, BA2 7AY UK > +44 1225 386603 www.maths.bath.ac.uk/~sw283 ______________________________________________ R-help@stat.math.ethz.ch 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.