Announcement

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

  • Panel Data, marginscontplot for continuous independent but binary dependent variable

    Dear all,

    I have panel data (920 observations where 230 individuals participate in an experiment over 4 rounds), it is strongly balanced. Previously, I used xtset CASE (unique ID), round to set the data as panel data.

    I have used xtlogit as I have a binary dependent variable and would like to obtain odd ratios (which I believe xtprobit does not do).

    Code:
     xtlogit reb_sa c.PPD_sa c.PPD_ak c.PPD_ua c.PPD_g, or nolog
    
    Random-effects logistic regression                   Number of obs    =    920
    Group variable: CASE                                 Number of groups =    230
    
    Random effects u_i ~ Gaussian                        Obs per group:
                                                                      min =      4
                                                                      avg =    4.0
                                                                      max =      4
    
    Integration method: mvaghermite                      Integration pts. =     12
    
                                                         Wald chi2(4)     =  33.24
    Log likelihood = -474.47296                          Prob > chi2      = 0.0000
    
    ------------------------------------------------------------------------------
          reb_sa | Odds ratio   Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
          PPD_sa |   1.227043   .2445079     1.03   0.305     .8303182    1.813324
          PPD_ak |   .9948695   .1969983    -0.03   0.979     .6748637    1.466615
          PPD_ua |   1.007079   .2066121     0.03   0.973     .6736452    1.505552
           PPD_g |   .9566518   .1891987    -0.22   0.823     .6492475    1.409605
           _cons |    5.42123   .8201722    11.17   0.000     4.030143    7.292479
    -------------+----------------------------------------------------------------
        /lnsig2u |   .4151769   .2776937                     -.1290927    .9594466
    -------------+----------------------------------------------------------------
         sigma_u |   1.230707   .1708797                      .9374927    1.615627
             rho |   .3152537   .0599454                      .2108282    .4424065
    ------------------------------------------------------------------------------
    Note: Estimates are transformed only in the first equation to odds ratios.
    Note: _cons estimates baseline odds (conditional on zero random effects).
    LR test of rho=0: chibar2(01) = 37.67                  Prob >= chibar2 = 0.000
    
    . 
    end of do-file
    reb_sa is the dependent binary variable and PPD_ are continuous percentage point differences in 4 asset classes. Essentially, I would like to measure whether the percentage point differences drive the dependent variable. Apparently, that is not the case as, unfortunately, my individual coefficients are not significant. Nonetheless, I would like to plot margins graphs for a better visual analysis using the user-written gr0056/marginscontplot.ado (help marginscontplot)

    Code:
    marginscontplot PPD_ak, at1(-25 -20 -15 -10 -5 -4 -3 -2 -1 0 1 2 3 4 5 10 15 20 25)
    I was hoping to have the binary (0/1) dependent variable on the y-axis, and the PPD in one asset class on the x-axis but as you can see, the scale goes from 1.3 to 1.6 (on the y-axis), which doesn't make much sense to me.
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	60.0 KB
ID:	1718222

    I would be most grateful if anyone could kindly explain what went wrong in my analysis. Is it because I have no significance in the model?

    I am using Stata 17.

    Kind regards!

  • #2
    The default prediction for -xtlogit- is the linear predictor but you want the probabilities so you need to use the "margopts(predict(pr))" option in your command

    Comment


    • #3
      Dear Rich, Thank you very much for your comment. Unfortunately, I couldn't find anything on said option neither online, nor in Stata's help files. May I kindly ask you to amend my code or for directions to a help file? Thank you very much, and my apologies for the disturbance.

      Comment


      • #4
        just add what I put in quotes as another option to your command to your -mcp- command

        you can see the start of this in the marginscontplot help file when you see:
        Code:
         margopts(string)             options for margins
        under options

        to get the full detail you need to see the help for -margins-

        Comment


        • #5
          Thank you very much, Rich! You have been most helpful. May I please kindly ask you one last question on this topic:
          Code:
           xtlogit reb_sa c.PPD_sa c.PPD_ak c.PPD_ua c.PPD_g i.T_C i.risk, or nolog
          
          Random-effects logistic regression                   Number of obs    =    920
          Group variable: CASE                                 Number of groups =    230
          
          Random effects u_i ~ Gaussian                        Obs per group:
                                                                            min =      4
                                                                            avg =    4.0
                                                                            max =      4
          
          Integration method: mvaghermite                      Integration pts. =     12
          
                                                               Wald chi2(8)     =  70.05
          Log likelihood = -448.38753                          Prob > chi2      = 0.0000
          
          ------------------------------------------------------------------------------
                reb_sa | Odds ratio   Std. err.      z    P>|z|     [95% conf. interval]
          -------------+----------------------------------------------------------------
                PPD_sa |   1.179302   .2410019     0.81   0.420      .790085    1.760259
                PPD_ak |   1.038981   .2112286     0.19   0.851     .6975174    1.547604
                PPD_ua |   1.096805   .2316543     0.44   0.662     .7250177    1.659244
                 PPD_g |   1.005278   .2039415     0.03   0.979     .6754642    1.496133
                       |
                   T_C |
                   TG  |   .4530152   .1233475    -2.91   0.004     .2656725    .7724651
                       |
                  risk |
                    2  |   1.020173   .2381788     0.09   0.932     .6455724    1.612141
                    3  |    3.27456   .8897093     4.37   0.000     1.922554    5.577343
                    4  |     4.1291   1.179119     4.97   0.000     2.359302    7.226485
                       |
                 _cons |   4.597856   1.167349     6.01   0.000       2.7954    7.562525
          -------------+----------------------------------------------------------------
              /lnsig2u |   .6113413   .2697779                      .0825864    1.140096
          -------------+----------------------------------------------------------------
               sigma_u |   1.357535   .1831165                      1.042158    1.768352
                   rho |   .3590462   .0620845                      .2481952    .4873149
          ------------------------------------------------------------------------------
          Note: Estimates are transformed only in the first equation to odds ratios.
          Note: _cons estimates baseline odds (conditional on zero random effects).
          LR test of rho=0: chibar2(01) = 44.15                  Prob >= chibar2 = 0.000
          
          .
          end of do-file
          Code:
           marginscontplot PPD_ak, at1(-20 -15 -10 -5 -4 -3 -2 -1 0 1 2 3 4 5 10 15 20) margopts(predict(pr))
          I obtained the following graph, where the dependent variable equals 1. Is it possible to add reb_sa (ie the dependent variable)= 0 to the same graph or to create another graph?
          Click image for larger version

Name:	Graph_1.png
Views:	1
Size:	61.1 KB
ID:	1718302



          Again, thank you so very much for all your insights and time!
          Last edited by Mary Burckhette; 24 Jun 2023, 12:56.

          Comment


          • #6
            sorry, but I do not understand; you have, I think, a binary outcome - so each units predicted value is for a "1" and the predicted value of a "0" for that unit is just 1 minus what you already have, correct? so, what am I missing? or maybe someone else can help you

            Comment


            • #7
              Dear Rich, Thank you very much! To confirm my understanding of the graph: If the percentage point difference in the share price between two dates of Akamai Technologies, Inc. (AKAM) (PPD_ak) equals 0, then there is a roughly 75% chance that the dependent binary variable equals 1. Is this correct?

              However, since none of my coeffcients are statistically significant in the regression, the graph is just for illustration, right?

              Once again, thank you so much for your time and dedication!

              Comment


              • #8
                Yes, loosely speaking, what you say is correct

                Comment


                • #9
                  Thank you very much! I appreciate all your help and support!

                  Comment

                  Working...
                  X