Announcement

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

  • Test statistics from multinomial logit regression using esttab

    Please I would like to perform joint tests of significance in a multinomial logit and include the results in a table using esttab. I have run the following code:

    Code:
    webuse sysdsn1
    quietly{
    eststo clear
    mlogit insure age nonwhite site male ppd
    est store m
    
    forval i = 1/3 {
    est res m
    margins, dydx(*) predict(outcome(`i')) post
    est store m`i'
    }
    
    test site male ppd
    estadd scalar test=r(F)
    
    }
    esttab m1 m2 m3, p scalars(pr2) stats(N pr2 test)
    I want to test the hypothesis site=male=ppd=0 in each of the three outcomes of the dependent variable (insure) and place the chi2 stat (named `test'), under each equation/outcome like in the table below.

    Code:
    ------------------------------------------------------------
                          (1)             (2)             (3)  
                                                                
    ------------------------------------------------------------
    age               0.00116       -0.000928       -0.000228  
                      (0.225)         (0.228)         (0.758)  
    
    nonwhite          -0.0463          0.0236          0.0227  
                      (0.185)         (0.390)         (0.395)  
    
    site               0.0292         -0.0273        -0.00187  
                      (0.089)         (0.055)         (0.886)  
    
    male              -0.0148         -0.0141          0.0289  
                      (0.632)         (0.568)         (0.220)  
    
    ppd                -0.332***        0.355***      -0.0228  
                      (0.000)         (0.000)         (0.163)  
    ------------------------------------------------------------
    N                     615             615             615  
    pr2                                                        
    test                                                   .                                               .  
    ------------------------------------------------------------
    My code is incorrect. I would appreciate if someone could set me straight on this.
    Last edited by Chibo Dike; 08 Mar 2021, 16:53.

  • #2
    estout is from the Stata Journal. You want to match each statistic to its model. 2 points:

    1. Watch out, sometimes test outputs a \(\chi^{2}\) statistic instead of an F-statistic.
    2. There is no need of naming the same statistic differently across models.

    Code:
    webuse sysdsn1, clear
    eststo clear
    mlogit insure age nonwhite site male ppd
    est store m
    
    forval i = 1/3 {
    est res m
    test [`i']: site male ppd
    local res =r(chi2)
    margins, dydx(*) predict(outcome(`i')) post
    est store m`i'
    estadd scalar test= `res'
    }
    esttab m1 m2 m3, p scalars(pr2) stats(N test)
    Res.:

    Code:
    . esttab m1 m2 m3, p scalars(pr2) stats(N test)
    
    ------------------------------------------------------------
                          (1)             (2)             (3)  
                                                                
    ------------------------------------------------------------
    age               0.00116       -0.000928       -0.000228  
                      (0.225)         (0.228)         (0.758)  
    
    nonwhite          -0.0463          0.0236          0.0227  
                      (0.185)         (0.390)         (0.395)  
    
    site               0.0292         -0.0273        -0.00187  
                      (0.089)         (0.055)         (0.886)  
    
    male              -0.0148         -0.0141          0.0289  
                      (0.632)         (0.568)         (0.220)  
    
    ppd                -0.332***        0.355***      -0.0228  
                      (0.000)         (0.000)         (0.163)  
    ------------------------------------------------------------
    N                     615             615             615  
    test                    .           238.5           4.616  
    ------------------------------------------------------------
    p-values in parentheses
    * p<0.05, ** p<0.01, *** p<0.001
    Last edited by Andrew Musau; 08 Mar 2021, 17:07.

    Comment


    • #3
      Thanks a lot, Andrew. Please, I would be grateful for your help on three more issues:

      1) I've seen papers (e.g see attached table) provide test stats for all categories of the multinomial logit including the base category which is outcome 1 in this example. Can you help with that?

      2) Can you also help me add the pseudo r2 to the table? My initial code is cannot do that too.

      3) Since N=615 across all outcomes, is there a way to make 615 appear only under the first column (as in the attached table)?



      Attached Files

      Comment


      • #4
        1) I've seen papers (e.g see attached table) provide test stats for all categories of the multinomial logit including the base category which is outcome 1 in this example. Can you help with that?
        2) Can you also help me add the pseudo r2 to the table? My initial code is cannot do that too.
        Run the test after the margins command.

        Code:
        webuse sysdsn1, clear
        eststo clear
        mlogit insure age nonwhite site male ppd
        est store m
        forval i = 1/3 {
            est res m
            margins, dydx(*) predict(outcome(`i')) post
            est store m`i'
            test site male ppd
            estadd scalar test=r(chi2)
        }
        
        esttab m1 m2 m3, p scalars(pr2) stats(N test)
        Res.:

        Code:
        . esttab m1 m2 m3, p scalars(pr2) stats(N test)
        
        ------------------------------------------------------------
                              (1)             (2)             (3)  
                                                                    
        ------------------------------------------------------------
        age               0.00116       -0.000928       -0.000228  
                          (0.225)         (0.228)         (0.758)  
        
        nonwhite          -0.0463          0.0236          0.0227  
                          (0.185)         (0.390)         (0.395)  
        
        site               0.0292         -0.0273        -0.00187  
                          (0.089)         (0.055)         (0.886)  
        
        male              -0.0148         -0.0141          0.0289  
                          (0.632)         (0.568)         (0.220)  
        
        ppd                -0.332***        0.355***      -0.0228  
                          (0.000)         (0.000)         (0.163)  
        ------------------------------------------------------------
        N                     615             615             615  
        test                204.4           254.5           2.786  
        ------------------------------------------------------------
        p-values in parentheses
        * p<0.05, ** p<0.01, *** p<0.001


        2) Can you also help me add the pseudo r2 to the table? My initial code is cannot do that too.

        3) Since N=615 across all outcomes, is there a way to make 615 appear only under the first column (as in the attached table)?

        #3 is easier in a latex table where you start with a minimally formatted table and then proceed from there. See https://www.statalist.org/forums/for...e-using-estout for some ideas. Otherwise, estout's -prefoot()- option can be useful to this end.


        Code:
        webuse sysdsn1, clear
        eststo clear
        mlogit insure age nonwhite site male ppd
        local N = e(N)
        local pr2= e(r2_p)
        est store m
        forval i = 1/3 {
            est res m
            margins, dydx(*) predict(outcome(`i')) post
            est store m`i'
            test site male ppd
            estadd scalar test=r(chi2)
        }
        
        esttab m1 m2 m3, p ///
        prefoot("   "  "{bf:N}              {bf:`:di %8.0f  `N''}" "   "   ///
        "{bf:Pseudo R2}       {bf:`:di %8.3f  `pr2''}" ) noobs
        Res.:

        Code:
        . esttab m1 m2 m3, p ///
        > prefoot("   "  "{bf:N}              {bf:`:di %8.0f  `N''}" "   "   ///
        > "{bf:Pseudo R2}       {bf:`:di %8.3f  `pr2''}" ) noobs
        
        ------------------------------------------------------------
                              (1)             (2)             (3)  
                                                                    
        ------------------------------------------------------------
        age               0.00116       -0.000928       -0.000228  
                          (0.225)         (0.228)         (0.758)  
        
        nonwhite          -0.0463          0.0236          0.0227  
                          (0.185)         (0.390)         (0.395)  
        
        site               0.0292         -0.0273        -0.00187  
                          (0.089)         (0.055)         (0.886)  
        
        male              -0.0148         -0.0141          0.0289  
                          (0.632)         (0.568)         (0.220)  
        
        ppd                -0.332***        0.355***      -0.0228  
                          (0.000)         (0.000)         (0.163)  
          
        N                   615
          
        Pseudo R2          0.472
        ------------------------------------------------------------
        p-values in parentheses
        * p<0.05, ** p<0.01, *** p<0.001
        Last edited by Andrew Musau; 09 Mar 2021, 05:51.

        Comment


        • #5
          Thanks a lot Andrew.

          Comment

          Working...
          X