[R] R Help
R. Michael Weylandt
michael.weylandt at gmail.com
Sat Mar 31 16:55:27 CEST 2012
This sounds a little bit like homework (since you know the actual
model), so I'll just point you in the right direction:
I'd do something like:
n <- 2^(1:10)
y <- 2*n^2 - 5*n + 3
dtf <- data.frame(y = y, n=n)
lm( **********, data = dtf)
The ***** should be replaced by a "formula" object: to find the syntax
for those, just google around or read ?formula and the examples of
?lm. The help pages are a little opaque (very good, just not super
beginner friendly) but the easiest way to set up formulas is
+ includes a term
: includes just a cross term
* includes a cross term and the individual terms (i.e., A*B = A + B + A:B)
- removes a term.
That should help you set things up.
Hope this helps,
Michael
On Sat, Mar 31, 2012 at 10:03 AM, Jaymin Shah <jayminshah1 at hotmail.com> wrote:
> Hi,
>
> I have a polynomial of 2n^2-5n+3 and I have my n values going up in powers of 2 i.e. n=2,4,8,16…..
>
> I wanted to fit this curve to the function A*n*log2(n) +B*n where A and B are to be found.
>
> How would i do this?
>
> Thank you
>
>
> Jaymin
>
> ______________________________________________
> 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.
More information about the R-help
mailing list