Approximate a f(x,y)
Akima is "free for non-commercial use" but this may be a commercial application. Your solution for 1 variable is called piecewise linear interpolation; there are many ways to extend this to 2 variables. Piecewise linear on triangles, for example, or piecewise bilinear. For the latter, given x=(x1,x2) and the values at integers in f[,] compute the interpolated value as i <- floor(x) w <- x - i m <- f[i[1]:(i[1]+1),i[2]:(i[2]+1)] f1 <- c(1-w[1],w[1])%*%m c(1-w[2],w[2])%*%f1 ie there are 4 nearest grid points and the weights are just products of the 1-variable weights. Reid Huntsinger -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Liaw, Andy Sent: Wednesday, September 29, 2004 11:09 AM To: 'Naji'; r-help at stat.math.ethz.ch Subject: RE: [R] Approximate a f(x,y) The `akima' package on CRAN probably would help. HTH, Andy
From: Naji Hi all, Running simulations, I'm generating market response to 2 factors X&Y.. There is no closed form for the market response.. The results are store in a matrix Z(X <- seq(.02,.98,.02), Y <- seq(.01,.19,.01)).. For optmization purpose I need to approximate the values for any factor X in 0,02-0,98 and Y in 0,01-0,19 How can I do it ? For one factor : Xn-1 < x <= Xn f(x)=(f(Xn-1)*(x-Xn-1)+f(Xn)*(Xn-x))/(Xn-Xn-1) I don't know how to generalize this for two factors.. Thanks in Advance Naji
______________________________________________ R-help at 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
______________________________________________ R-help at 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 ---------------------------------------------------------------------------- -- Notice: This e-mail message, together with any attachments,...{{dropped}}