Peppy <s.adi.purnomo at EnergyLink.co.nz> writes:
> Dear Help desk,
An interesting concept - the R "Help desk" is in fact a mailing list.
> I have a model that I believe to be non linear. The relationship is
> something like:
>
> Response = Var1 + Var1^2 + Var1^3
In terms of the way the parameters enter the model, this is still a
linear model, even though it is nonlinear in terms of the variable.
> Can I examine this relationship using glm or lm? However, glm or lm gives
> out pnly 1 coeficient for the model which is on Var1, unless I created
some
> dummy var like (Var2 = Var1^2 and Var3 = Var1^3).
You are correct. This is a deficiency in the model formula language
used in R. The meaning of the ^2 operator in formulas is appropriate
for factors but not the expected meaning for numeric variables.
> Is there any other function handling this relationship?
The preferred way to do this is to use the I() function to protect
the ^2 and ^3 from being evaluated as part of the linear model
formula. That is, write the call to lm with
formula = Response ~ Var1 + I(Var1^2) + I(Var1^3)
> My R is 0.64.2
The most recently released version is 0.65.1. As R is freely
available it is probably a good idea to upgrade.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._