[R] formula formatting/grammar for regression
BKMooney
bkmooney at gmail.com
Fri Feb 27 19:01:11 CET 2009
This is just (or should be) just a simple example of what I would like to
extend to further regression - which is why I was looking for a resource on
the grammar.
If I try:
lm(ypts ~ exp(xpts)), I only get an intercept and one coefficient. And for
the coefficient, I am not sure where that should go? (ie is that A or r in
the formula y=A*exp(r*x) )
Also, when I tried to use nls, I get an error:
nls(ypts ~ exp(xpts))
Error in getInitial.default(func, data, mCall = as.list(match.call(func, :
no 'getInitial' method found for "function" objects
If someone could please point out what I am doing wrong, or point me to a
good resource on this, I would greatly appreciate it.
Thanks!
Dieter Menne wrote:
>
> Brigid Mooney <bkmooney <at> gmail.com> writes:
>
>> I am doing some basic regression analysis, and am getting a bit
>> confused on how to enter non-polynomial formulas to be used.
> ..
>> But am confused on what the formula should be for trying to find a fit
>> to y = A*exp(r*x).
>
> If this example is just a placeholder for "more complex than poly",
> you should check function nls which works for non-linear functions.
>
> However, if you really want to solve this problem only, doing a
> log on you data and fitting a log of the above function with lm()
> is the easiest way out. Results can be a bit different from the
> nonlinear case depending on noise, because in one case weight
> are log-weighted, in the other linearly.
>
> Dieter
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
--
View this message in context: http://www.nabble.com/formula-formatting-grammar-for-regression-tp22249014p22251094.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list