Announcement

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

  • #16
    Jared Greathouse Thank you for your input and approach. If I interpret my results correctly, I'm not in this range, though. Am I right?

    Also, would you use the -predict- command to create such a plot?

    Comment


    • #17
      Re #14: Sorry, I spoke too quickly. I was thinking about linear probability and logistic models in non-panel data, where it is easier to do that. I don't know of a good way to test the fit of an -xtlogit, fe- model, and I don't know of even a bad way to do that which could be made comparable to a test of fit of a linear probability model in panel data.

      With regard to the linear probability model, while R2 statistics are aggregate measures of fit, I always like to look at scatter plots of predicted vs observed values. Now, with a dichotomous outcome, the observed values are always 0 or 1. So the next best thing is to group the observations into bins based on the predicted outcome. (What I'm recommending here is very much in the spirit of the Hosmer-Lemeshow test used with logistic or probit models in non-panel data.) Then plot the observed number of 1 responses vs the predicted number of 1 responses in each bin. The bins should be of roughly equal size and the number of them should be such that each bin contains around 50-100 observations: that smooths things out reasonably well in most circumstances. By inspecting a graph like that you not only get a visual impression of how well calibrated the model is, you also can see if there are systematic errors in the model. For example, the model might systematically overpredict in one part of the range and underpredict in others. That might suggest ways to improve the model by adding variables or interaction terms if the original fit seems unsatisfactory.

      Comment


      • #18
        Dear Mr. Schechter @Clyde Schechter,

        I hope you are well. I have a question regarding the use of -margins-

        Notice that the -margins- results are different for the two regressions; yet these two models are not substantively different--they are just two different ways of breaking the colinearity between treat and idcode. You have the same problem. When you use -xtreg, fe- Stata has one particular strategy for dealing with the colinearity. But the -margins- results would be different if another one were used. This is why these margins are not estimable: they are just artifacts of the particular choices made to break colinearity. In fact, you have this problem twice: once for worker_id and treat, and again for post and year. Nevertheless, note that your key outcome, the DID estimate of the treatment effect, comes out the same in both models--it is the coefficient of the interaction term in the regression output. And that is what really counts here.
        in my DID analysis with panel data, where the time period ranges from months 5 to 29. I am using a Linear Probability Model (LPM), and below is my code and result:

        Code:
         xtreg $y treat time $x $control i.month_indicator, fe vce(cluster id_num)
        note: treat omitted because of collinearity.
        note: 29.month_indicator omitted because of collinearity.
        
        Fixed-effects (within) regression               Number of obs     =    179,538
        Group variable: id_num                          Number of groups  =     11,218
        
        R-squared:                                      Obs per group:
             Within  = 0.3352                                         min =          1
             Between = 0.2767                                         avg =       16.0
             Overall = 0.3322                                         max =         25
        
                                                        F(33,11217)       =     312.91
        corr(u_i, Xb) = -0.1940                         Prob > F          =     0.0000
        
                                       (Std. err. adjusted for 11,218 clusters in id_num)
        ---------------------------------------------------------------------------------
                        |               Robust
        Y             | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
        ----------------+----------------------------------------------------------------
                  treat |          0  (omitted)
                   time |   .1563764   .0082816    18.88   0.000      .140143    .1726098
             treat_post |  -.0973506    .004796   -20.30   0.000    -.1067516   -.0879497
                        |
        month_indicator |
                     6  |   .0088768   .0049505     1.79   0.073    -.0008271    .0185807
                     7  |   .0217028   .0048793     4.45   0.000     .0121386    .0312671
                     8  |   .0273711   .0050675     5.40   0.000      .017438    .0373042
                     9  |   .0265076   .0052259     5.07   0.000     .0162639    .0367512
                    10  |   .0450282   .0052348     8.60   0.000      .034767    .0552893
                    11  |   .0410444   .0053232     7.71   0.000     .0306099    .0514788
                    12  |   .0426608   .0054737     7.79   0.000     .0319314    .0533901
                    13  |   .0563141   .0055621    10.12   0.000     .0454114    .0672169
                    14  |   .0549608   .0056474     9.73   0.000     .0438909    .0660306
                    15  |   .0598383    .005735    10.43   0.000     .0485966      .07108
                    16  |   .0663735   .0058667    11.31   0.000     .0548737    .0778733
                    17  |  -.0300051     .00465    -6.45   0.000    -.0391199   -.0208902
                    18  |  -.0243395   .0044541    -5.46   0.000    -.0330703   -.0156087
                    19  |  -.0151883   .0044271    -3.43   0.001    -.0238661   -.0065105
                    20  |  -.0157295   .0043193    -3.64   0.000     -.024196    -.007263
                    21  |  -.0131291   .0041711    -3.15   0.002    -.0213052    -.004953
                    22  |  -.0054799   .0041665    -1.32   0.188    -.0136469    .0026871
                    23  |  -.0143556   .0039684    -3.62   0.000    -.0221344   -.0065768
                    24  |  -.0190829   .0038441    -4.96   0.000     -.026618   -.0115478
                    25  |  -.0056036   .0037541    -1.49   0.136    -.0129624    .0017551
                    26  |  -.0031526   .0036179    -0.87   0.384    -.0102444    .0039392
                    27  |  -.0006298   .0033876    -0.19   0.853      -.00727    .0060104
                    28  |   .0013787   .0033443     0.41   0.680    -.0051768    .0079341
                    29  |          0  (omitted)
                        |
                  _cons |   .5143838   .0225582    22.80   0.000     .4701657    .5586019
        ----------------+----------------------------------------------------------------
        My Stata version: 17.0

        My question is:
        I would like to examine the marginal probabilities for both the treatment and control groups within each month to compare them. As you mentioned, the treatment group is omitted due to the fixed effects. Could you please advise on how I should modify the code to achieve this?

        Thank you for your time and assistance.

        Kind regards,
        Xiao
        Hi everyone, I have some questions about the difference-in-differences (DID) model with fixed effects. I am dealing with a monthly panel dataset – from 2005 to
        Last edited by xiao wen; 21 Sep 2024, 11:32.

        Comment


        • #19
          Code:
          regress outcome_variable i.treat##i.post, vce(cluster id_num)
          margins treat, over(month)

          Comment


          • #20
            Originally posted by clyde schechter View Post
            Code:
            regress outcome_variable i.treat##i.post, vce(cluster id_num)
            margins treat, over(month)
            really appreciate for it!

            Comment

            Working...
            X