[R] non-linear regression for 3D data

Duncan Murdoch murdoch.duncan at gmail.com
Wed Aug 11 12:42:35 CEST 2010


On 11/08/2010 6:15 AM, szisziszilvi wrote:
> Hello!
> 
> Is there a simplier way in R to get a nonlinear regression (like nls) for a
> surface? I have 3D data, and it is definitely not a linear surface with
> which it would fit the best. Rather sg like z = a + f(x) + g(y) where
> probably both f and g are polinomes (hopefully quadratic).

That's a linear model if f and g are polynomials.  You can fit it with

lm(z ~ poly(x, 2) + poly(y, 2))

The 2's are the degrees of each polynomial; the intercept a is implied.

Duncan Murdoch



More information about the R-help mailing list