Hi All, I have a data with 15 columns. the first 10 column are dependent(y?s) variables and the following 5 an columns are the independent variables(x?s) ( MY DATA HAS A HEADER WITH THE NAME OF THE VAIABLES). I need to apply linear regression y=a+bx where I need x to be one of the independent variable and y to be one of the dependent variable, but for each x I have to repeat the model for all 5 independent variable one at a time . Also each x is a categorical variable with 4 categories so I have to introduce three variables for each x New Variable 1 New Variable 2 New Variable 3 Category 1 0 0 0 Category 2 1 0 0 Category 3 0 1 0 Category 4 0 0 1 I want R to print out the summary and the analysis of variance for each model. How can this done in R? I want to use some loop that loops over the independent variables for each x ?Also , I am not sure how to deal with the problem of each x being a categorical variable and I have to create these new variables for each x? I hope that someone can help. I really Appreciate it. -- View this message in context: http://www.nabble.com/Linear-Regression---tp17865662p17865662.html Sent from the R help mailing list archive at Nabble.com.
Hi, did you have a look at the manual "An Introduction to R"? (http://cran.r-project.org/doc/manuals/R-intro.html). Chapter "Statistical Models in R" should answer (most of) your questions concerning linear regression. kayj wrote:> > Also each x is a categorical variable with 4 categories so I have to > introduce three variables for each x >If I understood correctly what you mean (-> coding of dummy variables), this is not necessary in R. If you variable is a "factor", R does it for you automatically. If you are unhappy with the choice of reference category, please check: ?relevel I hope this helps, Roland