Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Selecting different time-periods OLS panel regression

    Hello everybody,

    This is my first time using both Stata and this forum so I'm a rookie regarding this program. I'm investigating certain variables pre, during and post economical crisis of 2007. For this I have a sample of around 2000 companies with 7 variables during 2005 until 2015. Now I have successfully ran an OLS Pooled Regression for the time period of 2005-2015 (All years). I wonder if there is a fast command to divide this in 3 time periods: 2005-2007, 2008-2011, 2012-2015. I thus need three OLS Pooled Regressions instead of one. I can of course manually prepare my data in excel separately for those three time periods, however I wonder if it is possible to do it in a quicker way through Stata.

    Edit: After posting this question I forgot to tell that it might also be useful for my research to have OLS Pooled regressions for each year individually as well. Thus the same question but than individually per year. This means 10 individual OLS Regressions and 3 time-period OLS Regressions.

    Thank you very much,

    Vincent van der Stee
    Last edited by Vincent Stee; 13 May 2017, 09:55.

  • #2
    Welcome to Statalist, Vincent.

    Yours is a very basic Stata question. I'm sympathetic to you as a new user of Stata - it's a lot to absorb. And even worse if perhaps you are under pressure to produce some output quickly. Nevertheless, I'd like to encourage you to take a step back from your immediate tasks.

    When I began using Stata in a serious way, I started, as have others here, by reading my way through the Getting Started with Stata manual relevant to my setup. Chapter 18 then gives suggested further reading, much of which is in the Stata User's Guide, and I worked my way through much of that reading as well. There are a lot of examples to copy and paste into Stata's do-file editor to run yourself, and better yet, to experiment with changing the options to see how the results change.

    All of these manuals are included as PDFs in the Stata installation (since version 11) and are accessible from within Stata - for example, through the PDF Documentation section of Stata's Help menu. The objective in doing the reading was not so much to master Stata as to be sure I'd become familiar with a wide variety of important basic techniques, so that when the time came that I needed them, I might recall their existence, if not the full syntax, and know how to find out more about them in the help files and PDF manuals.

    The Stata documentation is really exemplary - there's just a lot of it. The path I followed surfaces the things you need to know to get started in a hurry and to work effectively.

    With that said, the most direct answer is found by looking at what Stata tells you when you run the help if command to learn about Stata's if qualifier. So if your dataset has variables y, x, and year, then
    Code:
    regress y x
    performs a pooled regression of all your observations, and
    Code:
    regress y x if inrange(year,2005,2007)
    performs a pooled regression of your data from the years 2005-2007.

    Comment


    • #3
      Thank you very much. Indeed I am under pressure so I do not have very much time to experiment with Stata. I Should have beforehand but it is what it is and I have to deliver next saturday. Thank you alot anyways. This will save me a decent amount of time.

      Comment


      • #4
        Vincent:
        you're dealing with a panel dataset. Hence, in the limited cases in which -regress- outperforms -xtreg- (which is conceived for dealing with panel datasets with continuous dependent variable) you should have clustered your standard errors on the -panelid- (presumably -company-, in your case): otherwise your estimates are biased, as your observations are not independent.
        As far as dividing the time horizon into three periods is concerned, you can add a categorical variable to the set of your predictors, Elaborating a bit on William's helpful code:
        Code:
        g period=0 if inrange(year, 2005,2007)
        replace period=1 if inrange(year, 2008,2011)
        replace period=2 if inrange(year, 2012,2015)
        As per -fvvarlist- (see the related helpfile by typing from within Stata -help fvvarlist-), you can add -period- to the set of your predictors via the notation
        Code:
        i.period
        As a closing-out remarks, in order to increase your chances of getting helpful replies, please follow FAQ advice about posting wgat you typed and what Stata gave you back (via CODE delimiters). Thanks.
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment

        Working...
        X