Announcement

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

  • Additional Scalars not Showing Up in Esttab Table - Testparm

    Hi,
    I'm running four cox models assessing the effect of interactions between different types of social support (Informational, Emotional, Financial, and Physical) and sex, on mortality. In addition to exporting specific terms from the models to a table, I was hoping to add additional scalars from testparm (chi2 and p value) functions to the table as well. However, I can't seem to get the added scalars to show up in the exported table. The code below seems to run fine, but no actual scalars show up in the table. Unfortunately, it seems as though the data I'm using exceeds the dataex command limits so I'm unable to share an example of the data.

    Does anyone know how I would be able to attach the testparm scalars to the esttab table?

    David

    Code:
    eststo clear
    
    // INFORMATIONAL
    eststo, title("Informational"): quietly stcox Informational_Male Informational_Female $INFORMATIONAL 
    
    quietly stcox c.Informational#Male $INFORMATIONAL
    testparm i.Male#c.Informational, equal
    estadd scalar Chi2 = r(chi2)
    estadd scalar P = r(p)
    
    // EMOTIONAL
    eststo, title("Emotional"): quietly stcox Emotional_Male Emotional_Female $EMOTIONAL 
    
    quietly stcox c.Emotional#Male $EMOTIONAL
    testparm i.Male#c.Emotional, equal
    estadd scalar Chi2 = r(chi2)
    estadd scalar P = r(p)
    
    // FINANCIAL
    eststo, title("Financial"): quietly stcox Financial_Male Financial_Female $FINANCIAL 
    
    quietly stcox c.Financial#Male $FINANCIAL
    testparm i.Male#c.Financial, equal
    estadd scalar Chi2 = r(chi2)
    estadd scalar P = r(p)
    
    // PHYSICAL
    eststo, title("Physical"): quietly stcox Physical_Male Physical_Female $PHYSICAL 
    
    quietly stcox c.Physical#Male $PHYSICAL
    testparm i.Male#c.Physical, equal
    estadd scalar Chi2 = r(chi2)
    estadd scalar P = r(p)
    
    esttab /*using "Table 5 - Cox Regressions, Sex Interaction.rtf"*/, wide b(2) ci(2) stats(Chi2 P) eform modelwidth(25) ///
                nonumbers noobs mtitles("Informational" "Emotional" "Financial" "Physical") ///
                title(Table 3 - Cox Regressions, Social Support Interaction W/ Sex) varwidth(35) label interaction(" x ") star compress onecell nogaps ///
                addnotes(N for all models is 4907) ///
                keep(Informational_Male Informational_Female Male ///
                Emotional_Male Emotional_Female Male ///
                Financial_Male Financial_Female Male ///
                Physical_Male Physical_Female Male) replace
                
    eststo clear
    
    Table 3 - Cox Regressions, Social Support Interaction W/ Sex
    -------------------------------------------------------------------------------------------------------------------------------------------------------
                                                    Informational                    Emotional                    Financial                     Physical   
    -------------------------------------------------------------------------------------------------------------------------------------------------------
    Informational_Male                           1.04 [0.93,1.17]                                                                                          
    Informational_Female                         1.13 [1.00,1.29]                                                                                          
    Sex (Male)                                2.09*** [1.68,2.60]          1.97*** [1.59,2.44]          1.96*** [1.59,2.43]          2.03*** [1.64,2.52]   
    Emotional_Male                                                            1.04 [0.93,1.17]                                                             
    Emotional_Female                                                          1.13 [0.99,1.29]                                                             
    Financial_Male                                                                                         1.04 [0.93,1.16]                                
    Financial_Female                                                                                       1.13 [0.99,1.29]                                
    Physical_Male                                                                                                                       1.04 [0.93,1.17]   
    Physical_Female                                                                                                                     1.12 [0.98,1.27]   
    -------------------------------------------------------------------------------------------------------------------------------------------------------
    Chi2                                                                                                                                                   
    P                                                                                                                                                      
    -------------------------------------------------------------------------------------------------------------------------------------------------------
    Exponentiated coefficients; 95% confidence intervals in brackets
    N for all models is 4907
    * p<0.05, ** p<0.01, *** p<0.001



  • #2
    estout is from the Stata Journal, as you are asked to expain (FAQ Advice #12). See https://www.statalist.org/forums/for...alar-pseudo-r2

    Comment

    Working...
    X