R: polynomial shortcut notation in nls() formula
With the linear model function lm() polynomial formulas can contain a shortcut notation like this: m <- lm(y ~ poly(x,3)) this is a shortcut that keeps the user from having to create x^2 and x^3 variables or typing them in the formula like I(x^2) + I(x^3) . Is there comparable notation for the nonlinear function nls() ? poly(x, 3) is rather more than just a shortcut for x + I(x ^ 2) + I(x ^ 3) - it actually produces legendre polynomials which have the nice property of being uncorrelated: options(digits = 2) x <- runif(100) var(cbind(x, x ^ 2, x ^ 3)) # x # x 0.074 0.073 0.064 # 0.073 0.077 0