You need to start with a basic understanding of how R works. Here are a couple of sources that might help you get started: http://www.burns-stat.com/documents/tutorials/impatient-r/ http://cyclismo.org/tutorial/R/
Sarah On Thu, Dec 3, 2015 at 4:51 PM, Saba Sehrish via R-help <r-help@r-project.org> wrote: > Hi > > > > I am a PhD student and I want to learn how to run Linear regression with > Lag-5 on R through "For Loop". Please find the details below: > > > > 1- I need guidance about Coding/ Programming for Simple Linear > Regression with Lag-5 on R. > > 2- I have time series data of “Daily Returns” of 15 stocks and I > want to see how each stock’sreturn is connected to all other stocks’ returns. > This means, I have to runregression as follows: > > > > a) Impact of Stock 1’s return on return of Stock 2. > Impact of Stock 1’s return onreturn of Stock 3. Impact of Stock 1’s return on > return of Stock 4 ……… tillreturn of Stock 15. b) Then, > Impact of Stock 2’s return on return of Stock 1. Impact of Stock 2’sreturn on > return of Stock 3. Impact of Stock 2’s return on return of Stock 4……… till > return of Stock 15. And this will continue till Stock 15, one after another. > c) As the the process will have to be repeated, therefore > instead of manual coding everytime, “For Loop” is required. > > > > > I shall bereally grateful for a detailed reply. > > > > Thanks. > > > > Regards > > Saba Sehrish > ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.