Re: [R] bivariate interpolation

From: Adelchi Azzalini <>
Date: Tue 03 Apr 2007 - 09:43:55 GMT

On Mon, 2 Apr 2007 22:26:06 -0400, eric lee wrote:

EL> Hi.  I'm trying to take a data set with two independent and one dependent
EL> variable and enter a x,y value to predict the dependent with a
EL> nonparametric technique.  I've been using interpp in the akima package,
EL> (windows xp, R 2.4.1), but get values that are orders of magnitude off
EL> when the predictors are slightly out of the range of the data set.  Can
EL> you recommend a function for me?  I've read that predict.loess has the
EL> same problem or just lists NA.  Smooth.spline looks good, but can only do
EL> one predictor instead of bivariate.  I've tried"predict"),
EL> but couldn't find what I needed.  Thanks.

one option is to use sm.regression of package sm, along these lines

 x <- cbind(runif(100,-2, 2), runif(100,-2, 2))  y <- x[,1]^2 + x[,2]^2 + 0.7*x[,1]*x[,2] + rnorm(100)/3  sm.regression(x,y) <- rbind(c(-2,-2),c(2,2), c(2,-2),c(-2,2))  a <- sm.regression(x,y,, eval.grid=FALSE)

Adelchi Azzalini  <>
Dipart.Scienze Statistiche, UniversitÓ di Padova, Italia
tel. +39 049 8274147,

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Tue Apr 03 19:50:28 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 03 Apr 2007 - 10:30:54 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.