rcoxmodelsummary

How can I change coef to exp(coef) in modelsummary table?


I am trying to create a summary table for my Cox model. However, when I use modelsummary function, it gives me a table that shows coef. But I want to display exp(coef) on my summary table. How can I change coef to exp(coef)?

I use this script to create a summary table:

modelsummary(model.1,
             statistic='({conf.low}, {conf.high})',
             stars=TRUE,
             vcov = 'classical',
             coef_omit = "Intercept",
             coef_rename=c('ln_reb_capacity'='Relative rebel strength',
                           'terrcont'='Rebel territorial control', 'gdp'='Economic strength',
                           'bdbest'='Conflict intensity', 'roughterrain'='Rough terrain',
                           'loot'='Lootable resources', 'in_tpop'='Population size',
                           'powersharing'='Sharing Leadership'),
             title = 'Table I.',
             output='gt'
)

This is the summary table:

 Table I.                                                         
                               ─────────────────────────────────────────────────────────
                                                             Model 1                    
                               ─────────────────────────────────────────────────────────
                                 Relative rebel strength     0.125*                     
                                                             (0.016, 0.235)             
                                 Rebel territorial control   -0.295+                    
                                                             (-0.638, 0.048)            
                                 Economic strength           0.000                      
                                                             (0.000, 0.000)             
                                 Conflict intensity          0.000                      
                                                             (0.000, 0.000)             
                                 Rough terrain               0.098                      
                                                             (-0.210, 0.405)            
                                 Lootable resources          0.105                      
                                                             (-0.298, 0.507)            
                                 Population size             -0.119+                    
                                                             (-0.249, 0.011)            
                                 Sharing Leadership          0.046                      
                                                             (-0.393, 0.486)            
                               ─────────────────────────────────────────────────────────
                                 Num.Obs.                    260                        
                                 AIC                         1678.5                     
                                 BIC                         1707.0                     
                                 RMSE                        0.83                       
                                 Std.Errors                  Classical                  
                               ─────────────────────────────────────────────────────────
                                 + p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001      
                               ─────────────────────────────────────────────────────────

Column names: , Model 1

Here is my result for Cox model:

Call:
coxph(formula = Surv(month_duration, EndConflict) ~ ln_reb_capacity + 
    terrcont + gdp + bdbest + roughterrain + loot + in_tpop + 
    powersharing, data = df)

  n= 260, number of events= 183 
   (108 observations deleted due to missingness)

                        coef    exp(coef)     se(coef)      z Pr(>|z|)  
ln_reb_capacity  0.125154562  1.133323609  0.055831926  2.242   0.0250 *
terrcont        -0.295113621  0.744446997  0.174927860 -1.687   0.0916 .
gdp             -0.000004416  0.999995584  0.000017623 -0.251   0.8021  
bdbest          -0.000010721  0.999989279  0.000016057 -0.668   0.5043  
roughterrain     0.097602616  1.102524573  0.156809154  0.622   0.5337  
loot             0.104686159  1.110362079  0.205406301  0.510   0.6103  
in_tpop         -0.119020975  0.887789179  0.066355450 -1.794   0.0729 .
powersharing     0.046026931  1.047102610  0.224229347  0.205   0.8374  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

                exp(coef) exp(-coef) lower .95 upper .95
ln_reb_capacity    1.1333     0.8824    1.0159     1.264
terrcont           0.7444     1.3433    0.5284     1.049
gdp                1.0000     1.0000    1.0000     1.000
bdbest             1.0000     1.0000    1.0000     1.000
roughterrain       1.1025     0.9070    0.8108     1.499
loot               1.1104     0.9006    0.7424     1.661
in_tpop            0.8878     1.1264    0.7795     1.011
powersharing       1.0471     0.9550    0.6747     1.625

Concordance= 0.617  (se = 0.023 )
Likelihood ratio test= 18.96  on 8 df,   p=0.02
Wald test            = 18.2  on 8 df,   p=0.02
Score (logrank) test = 18.36  on 8 df,   p=0.02

Thanks.


Solution

  • You could adjust the argument exponentiate. If it's TRUE, the estimate, conf.low, and conf.high statistics are exponentiated, and the std.error is transformed to exp(estimate)*std.error (by the delta method).

    modelsummary(model.1,
                 ...,
                 exponentiate = TRUE
    )