Dear R listers, I am trying to be a new R user, but life is not that easy. My problem is the following one: let's assume to have 3 outcome variables (y1, y2, y3) and 3 explanatory ones (x1, x2, x3). How can I run the following three separate regressions without having to repeat the lm command three times?
fit.1 <- lm(y1 ~ x1) fit.2 <- lm(y2 ~ x2) fit.3 <- lm(y3 ~ x3) Both the y and x variables have been generated extracting random numbers from uniform distributions using a command such as: y1 <- runif(100, min = 0, max = 1) I went to several introductory manuals, the manual R for stata users, econometrics in R, Introductory statistics with R and several blogs and help files, but I didn't find an answer to my question. can you please help me? In Stata I wouldn't have any problem in running this as a loop, but I really can't figure out how to do that with R. Thanks in advance for all your help. Best, f. [[alternative HTML version deleted]] ______________________________________________ R-help@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.