[R] A easy way to write formula

2008-07-27 Thread Jinsong Zhao
Hi I have a data frame, including x1, x2, x3, and y. I use lm() to fit second-order linear model, like the following: ft - lm(y ~ x1 + x2 + x3 + I(x1 * x1) + I(x1 * x2) + I(x1 * x3) + I(x2 * x2) + I(x2 * x3) + I(x3 * x3), mydata) if the independent variable number is large, the formula will be

Re: [R] A easy way to write formula

2008-07-27 Thread ONKELINX, Thierry
for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Jinsong Zhao Verzonden: zondag 27 juli 2008 9:39 Aan: r-help@r-project.org Onderwerp: [R] A easy way

Re: [R] A easy way to write formula

2008-07-27 Thread Mark Difford
PROTECTED] [mailto:[EMAIL PROTECTED] Namens Jinsong Zhao Verzonden: zondag 27 juli 2008 9:39 Aan: r-help@r-project.org Onderwerp: [R] A easy way to write formula Hi I have a data frame, including x1, x2, x3, and y. I use lm() to fit second-order linear model, like the following: ft - lm(y

Re: [R] A easy way to write formula

2008-07-27 Thread hadley wickham
On Sun, Jul 27, 2008 at 4:19 AM, Mark Difford [EMAIL PROTECTED] wrote: Hi Jinsong and Thierry, (x1 + x2 + x3) ^2 will give you the main effects and the interactions. Although it wasn't specifically requested it is perhaps important to note that (...)^2 doesn't expand to give _all_