Formula for non-linear regression in R I want to know if it is possible for a library in R to evaluate the association of independent variables and create a formula? I am trying to come up with a model to predict power consumption of a machine, using some hardware counters and performance attributes. When I use linear regression, I have no problem since I could represent my formula like power~lm(a1+a2+a3+a4), but for the non-linear case, I am not sure what would be the formula or which model should I choose. 
I would want to have a way to do this:
power ~ <some-non-linear-reg-pkg>(a1+a2+a3+non-linear(a4))

I reviewed some packages for non-linear regression such as nls and gnm, and they expect a formula to be provided by the user. I am however able to identify which variables have linear associations and which are non-linear (by performing correlation tests), the problem is building a formula out of them. 
 A: Look at using linear regression but with a polynomial (poly) function or spline function on the predictors that you think may have a non-linear relationship.  Then plotting and further examination of those results may suggest the form of a non-linear function (or the linear model may be sufficient for your purposes).
example:
library(TeachingDemos)  # for Predict.Plot
library(splines)

     fit.lm1 <- lm( Sepal.Width ~ ns(Petal.Width,3)*ns(Petal.Length,3)+Species,
             data=iris)

     Predict.Plot(fit.lm1, pred.var = "Petal.Width", Petal.Width = 1.22,
           Petal.Length = 4.3, Species = "versicolor",
             plot.args = list(ylim=range(iris$Sepal.Width), col='blue'),
           type = "response")
     Predict.Plot(fit.lm1, pred.var = "Petal.Width", Petal.Width = 1.22,
           Petal.Length = 4.3, Species = "virginica",
             plot.args = list(col='red'),
           type = "response", add=TRUE)
     Predict.Plot(fit.lm1, pred.var = "Petal.Width", Petal.Width = 1.22,
           Petal.Length = 4.4, Species = "virginica",
             plot.args = list(col='purple'),
           type = "response", add=TRUE)

This is actually the 1st example from the help page for Predict.Plot.
A: A nonlinear regression function is never going to decide the functional form for you.
You might want to stick with a linear model and use a transformation of the variable with the nonlinear relationship. For example, check the correlation between power $a4^2$, $ln(a4)$, or some other transformation and use which ever one has the higher correlation.
