[R] OLS variables
Leaf Sun
leaflovesun at yahoo.ca
Sun Nov 6 21:03:55 CET 2005
Thanks for the information!
Leaf
======= At 2005-11-06, 11:07:31 you wrote: =======
>IMHO, the details section of help(formula) provides a nicer help.
>
>Regards, Adai
>
>
>On Sun, 2005-11-06 at 08:27 -0500, John Fox wrote:
>> Dear Leaf,
>>
>> I assume that you're using lm() to fit the model, and that you don't really
>> want *all* of the interactions among 20 predictors: You'd need quite a lot
>> of data to fit a model with 2^20 terms in it, and might have trouble
>> interpreting the results.
>>
>> If you know which interactions you're looking for, then why not specify them
>> directly, as in lm(y ~ x1*x2 + x3*x4*x5 + etc.)? On the other hand, it you
>> want to include all interactions, say, up to three-way, and you've put the
>> variables in a data frame, then lm(y ~ .^3, data=DataFrame) will do it.
>> There are many terms in this model, however, if not quite 2^20.
>>
>> The introductory manual that comes with R has information on model formulas
>> in Section 11.
>>
>> I hope this helps,
>> John
>>
>> --------------------------------
>> John Fox
>> Department of Sociology
>> McMaster University
>> Hamilton, Ontario
>> Canada L8S 4M4
>> 905-525-9140x23604
>> http://socserv.mcmaster.ca/jfox
>> --------------------------------
>>
>> > -----Original Message-----
>> > From: r-help-bounces at stat.math.ethz.ch
>> > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Leaf Sun
>> > Sent: Sunday, November 06, 2005 3:11 AM
>> > To: r-help at stat.math.ethz.ch
>> > Subject: [R] OLS variables
>> >
>> > Dear all,
>> >
>> > Is there any simple way in R that can I put the all the
>> > interactions of the variables in the OLS model?
>> >
>> > e.g.
>> >
>> > I have a bunch of variables, x1,x2,.... x20... I expect then
>> > to have interaction (e.g. x1*x2, x3*x4*x5... ) with some
>> > combinations(2 way or higher dimensions).
>> >
>> > Is there any way that I can write the model simpler?
>> >
>> > Thanks!
>> >
>> > Leaf
>> >
>> >
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>
>--
>Adaikalavan Ramasamy ramasamy at cancer.org.uk
>Centre for Statistics in Medicine http://www.ihs.ox.ac.uk/csm/
>Wolfson College Annexe Tel : 01865 284 408
>Linton Road, Oxford OX2 6UD Fax : 01865 284 424
>
>.
= = = = = = = = = = = = = = = = = = = =
Leaf Sun
leaflovesun at yahoo.ca
2005-11-06
More information about the R-help
mailing list