Announcement

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

  • Levene’s test

    Dear researchers,
    I have unbalanced panel data for more than 200 firms for the period that extend from 2000 to 2015. In specific year, set of standards have been issued. Firms, accordingly, have started to adopt the standards. I have noticed that the adoption is not simultaneous. For instance, firm A adopted in 2009, firm B adopted in 2010, firm C adopted in 2013, and so on. I have used the following codes:
    Code:
    xtreg ChangeinNI Size Growth Leverage i.Year if Event==0, fe
    xtreg ChangeinNI Size Growth Leverage i.Year if Event==1, fe
    Where
    Event = 0 for the firm-year observations before the adoption of the standards.
    Event = 1 for the firm-year observations after the adoption of the standards.
    Then, I wanted to get the residuals for each mentioned-above code, by using the following codes:
    Code:
    predict resid, resid
    predict resid1, resid
    Then, I wanted to get the standard deviation of the residuals by using the below codes:
    Code:
    egen SD= sd(resid)
    egen SD1= sd( resid1 )
    And, I want to apply the Levene’s test to test differences in standard deviation for the two residuals that I have obtained from the above, but what is the code for it?

    Many thanks in advance.

  • #2
    If I understand you correctly, then you could run something like
    Code:
    sdtest resid==resid1
    If you really want Levene's test, then you need to estimate your model for all groups together, predict the residuals and then run
    Code:
    robvar resid, by(Event)

    Comment


    • #3
      Thank you very much Seven-Kristjan for your answer.

      Actually, what I need is to run the first regression when the Event is 0 (i.e. before the adoption of the standards), and then running the second regression when the Event is 1 (i.e. after the adoption of the standards). Then, getting the residuals for each model, and their standard deviation. Finally, comparing the standard deviations by using the Levene's Test.

      So, what I have done is:
      Firstly:
      Code:
      xtreg ChangeinNI Size Growth Leverage DISSUE Turn CFO i.Year if Event==0,
      predict resid, resid
      
      xtreg ChangeinNI Size Growth Leverage DISSUE Turn CFO i.Year if Event==1, fe
      
      predict resid1, resid
      Then I should get the standard deviation of the residuals, and later using the Levene’s test
      Code:
      egen SD= sd(resid), by(COMPANY)
      egen SD1= sd( resid1 ), by(COMPANY)
      
      sdtest SD == SD1

      But I don't know if I should run the standard deviation by COMPANY or by Year? I think it is better to run it by year because the residuals are predicted yearly? What do you think?

      Comment


      • #4
        Originally posted by Omar Shaher View Post
        But I don't know if I should run the standard deviation by COMPANY or by Year? I think it is better to run it by year because the residuals are predicted yearly? What do you think?
        You have only one residual variance from the fitted xtreg model. (Look at the bottom part of the regression output table.) So, the two variances that you have to compare are that for the residuals from the first fitted model (Event == 0) against that for the residuals of the second (Event == 1).

        So, you'd do something likeSven-Kristjan recommended, namely
        Code:
        xtreg ChangeinNI Size Growth Leverage DISSUE Turn CFO i.Year if Event==0, fe
        predict double residuals0, e
        
        xtreg ChangeinNI Size Growth Leverage DISSUE Turn CFO i.Year if Event==1, fe
        predict double residuals1, e
        
        quietly generate double residuals = cond(Event, residuals1, residuals0) if inlist(Event, 0, 1)
        robvar residuals, by(Event)
        Have you assured yourself that there isn't substantial autocorrelation in the residuals? I'm not sure how that would affect the interpretability of Levene's test statistic(s).

        Comment


        • #5
          Hello everyone,

          I am studying the evolution of firms scores from 2009 until 2013. For the purpose of this study, I will be using oneway and the post-hoc Tukey test to test for significant score increases from one year to another. E.g from 2009 to 2010, 2011 to 2012 etc. However, if I would like to use the Tukey test, I first need to use the Levene's test to make sure the variance of the scores of each firm is equal to each other.

          My dataset looks at follows.

          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          Firmcode Year score
          "TF"      2009 76
          "TF"      2010 66
          "TF"      2011 70
          "TF"      2012 82
          "TF"      2013 85
          "APS"     2009 60
          "APS"     2010 77
          "APS"     2011 65
          "APS"     2012 80
          "APS"     2013 80
          "BBS"     2009 55
          "BBS"     2010  .
          "BBS"     2011 60
          "BBS"     2012 88
          "BBS"    2013 86
          end
          If
          Code:
          oneway score Year, tab
          I receive the Standard deviation per year (2009-2013) as part of my output. Of course, when I copy these values into a new variable and perform
          Code:
          sdtest (var standard deviation 2009) == (var standard deviation 2010)
          It does not provide me with an output as these are merely numbers without taking into consideration the sd of the original dataset. How can I perform a Levene's test with this dataset?

          Many thanks in advance!
          Last edited by Raymond Portocarero; 05 Nov 2021, 05:29.

          Comment

          Working...
          X