Announcement

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

  • Regression for each of prior 6 years

    Dear All,
    Sorry to ask this basic question but I am really struggling to do it.

    I am trying to measure my dependent variable (CONS) as the firm-specific intercept from the following regression model

    reg Accruals lag_Accruals

    However, to measure firm-specific intercept, I should run this model for each of the prior 6 years.

    Firm ID is gvkey
    Time variable is fyear
    Data from 2005 to 2019.

    I would appreciate your help in doing this.

    Thank you very much

    Mona

    Attached Files
    Last edited by mona bakrrr; 29 Mar 2022, 10:19.

  • #2
    However, to measure firm-specific intercept, I should run this model for each of the prior 6 years.
    That's not how I understand what you show in the attachment. I would interpret that as calling for a single fixed-effects regression using all years' data, with the first through sixth lagged valus or accruals as the explanatory variables.

    So I would do it something like this:
    Code:
    xtset gvkey fyear
    xtreg Accruals L(1/6).Accruals, fe
    predict firm_specific_intercept, u
    As you did not post example data, this code is both untested and may be unsuitable for the actual organization of your data. If you are not able to adapt this code to run with your data, please post back with example data, and be sure to use the -dataex- command to do so. so. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    When asking for help with code, always show example daa. When showing example data, always use -dataex-.

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      That's not how I understand what you show in the attachment. I would interpret that as calling for a single fixed-effects regression using all years' data, with the first through sixth lagged valus or accruals as the explanatory variables.

      So I would do it something like this:
      Code:
      xtset gvkey fyear
      xtreg Accruals L(1/6).Accruals, fe
      predict firm_specific_intercept, u
      As you did not post example data, this code is both untested and may be unsuitable for the actual organization of your data. If you are not able to adapt this code to run with your data, please post back with example data, and be sure to use the -dataex- command to do so. so. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

      When asking for help with code, always show example daa. When showing example data, always use -dataex-.
      Thank you very much, highly appreciated.

      Comment


      • #4
        Once again thank you Clyde for your response. I attached a sample of some data I have. I am not sure if i attached it correctly as this is the first time to attach data. So sorry if i did not do what you asked for.


        I have tried these codes which worked very well. but I noticed that the firm_specific_intercept is the same for the firm over years. I am not sure if there is a way to calculate this intercept for each year separately. For instance, for the firm with ID (gvkey) number (1) in 2011, calculate the intercept by running the equation over the period from 2006 to 2011) and then calculate the intercept. For the same firm but in 2012, run the model from 2007 to 2012. and the same for 2013 (from 2008 to 2013).

        This what I initially understood when I read the attached article in the original post.

        I might misunderstood it as I am still new to this measure.

        Once again thank you very much, I highly appreciate your comments.
        Mona
        Attached Files

        Comment


        • #5
          I don't work in this field, so there may be some background information I'm not taking into account, but I really think you are misunderstanding what that article says. Running the regression separately in 6 year blocks like you propose in #4 is mathematically impossible. Consider the period from 2006 to 2011. In the observations for year 2006, no lagged information will be available. In 2007, only a one-year lag is available. In 2008 only a 2 year lag is available, etc. In short, there will not be a single observation in that subset of the data that has all 6 lags available, so the regressions will not run.

          It is also not possible to run a regression that gives a separate firm-specific intercept that changes on a yearly basis. That would, by definition, not be a firm-specific intercept. It would be a firm-year specific intercept. Except that it isn't even really that, because there is only one observation for each firm-year combination, so what you are talking about is just the regression residual (plus the constant term). If that is what the article wanted, I have to believe they would have said it that way: regression residual (plus the constant term). The very phrasing "firm-specific intercept" implies a value that is constant within-firm over time--by definition. I suggest you review that article directly to see what they did; if the methodology section of the article is not clear, review it with a colleague in your discipline who is familiar with this kind of problem.

          It appears you also did not understand what I said about example data. Please re-read it. I did not request an attachment of a data set. I am among the many here who will not download anything from somebody I do not know. I asked you to use the -dataex- command to show the example data here in the Forum thread, and explained how to go about that.

          Comment


          • #6
            Thank you very much for these detailed explanations.
            So sorry to misunderstand your request.
            I would try to remove these attachment, if possible.
            Once again, thank you very much.

            Comment

            Working...
            X