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
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 > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
I have a 11*1562 set of data. I want to regress using ols all combination of the ten variables on the eleventh. Store the results of the t test of each regression and the r2 to compare which combination is better. the combination can use any amount o variables. How can I do that in R? -- View this message in context: r.789695.n4.nabble.com/R-help-tp4539571p4539571.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]]
On 07.04.2012 17:27, kebrab67 wrote:> I have a 11*1562 set of data. I want to regress using ols all combination of > the ten variables on the eleventh. Store the results of the t test of each > regression and the r2 to compare which combination is better. the > combination can use any amount o variables. How can I do that in R?Yes, sure. For your next post, please do read te posting guide and use a sensible subject line. Uwe Ligges> > -- > View this message in context: r.789695.n4.nabble.com/R-help-tp4539571p4539571.html > Sent from the R help mailing list archive at Nabble.com. > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
On 2012-04-07 08:27, kebrab67 wrote:> I have a 11*1562 set of data. I want to regress using ols all combination of > the ten variables on the eleventh. Store the results of the t test of each > regression and the r2 to compare which combination is better. the > combination can use any amount o variables. How can I do that in R?Personally, I think that what you propose is scientific nonsense. But if you must do this, you might check out the leaps package. Peter Ehlers> > -- > View this message in context: r.789695.n4.nabble.com/R-help-tp4539571p4539571.html > Sent from the R help mailing list archive at Nabble.com. > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.