Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transform the coefficient and confidence intervals in texreg output

Tags:

r

texreg

I am fitting several logistic regression models, and trying to use the package texreg to create a nicely looked table to present all models.

As I know, texreg::screenreg can only report the coefficients (the betas) and the correspondings CIs, but for logistic regression, but it is more common to report the exponent of the coefficients (the odds ratios).

I know that I can use override.coef, override.ci.low and override.ci.up to get what I want, but the output table is not desirable, it gives an asterisk if a CI cover 0 which should be 1 after transformation.

Is there a better and simpler way to transform the coefficients and the CIs? Also, is it possible for me to override the asterisk, I want to provide asterisk to represent the magnitude of p-value (*** p < 0.001, ** p < 0.01, * p < 0.05) ? Thanks!


Here is what I have tried

> set.seed(123)
> x1 <- rnorm(1000)
> x2 <- rnorm(1000)
> y <- runif(1000) < (1 / (1 + exp(-(0.3 + 0.5*x1))))
> mod1 <- glm(y~x1, binomial())
> mod2 <- glm(y~x2, binomial())
> mod3 <- glm(y~x1+x2, binomial())
> 
> tex1 <- extract(mod1)
> tex2 <- extract(mod2)
> tex3 <- extract(mod3)
> 
> screenreg(list(tex1, tex2, tex3), ci.force=T)

==========================================================
                Model 1       Model 2        Model 3      
----------------------------------------------------------
(Intercept)        0.30 *        0.28 *         0.30 *    
                [0.17; 0.43]  [ 0.15; 0.41]  [ 0.17; 0.43]
x1                 0.60 *                       0.60 *    
                [0.45; 0.74]                 [ 0.45; 0.74]
x2                               0.05           0.01      
                              [-0.07; 0.18]  [-0.12; 0.14]
----------------------------------------------------------
AIC             1294.48       1369.92        1296.47      
BIC             1304.30       1379.74        1311.19      
Log Likelihood  -645.24       -682.96        -645.23      
Deviance        1290.48       1365.92        1290.47      
Num. obs.       1000          1000           1000         
==========================================================
* 0 outside the confidence interval

After overriding,

> tex1@coef <- exp(tex1@coef)
> tex2@coef <- exp(tex2@coef)
> tex3@coef <- exp(tex3@coef)
> 
> ci1 <- confint(mod1)
Waiting for profiling to be done...
> ci2 <- confint(mod2)
Waiting for profiling to be done...
> ci3 <- confint(mod3)
Waiting for profiling to be done...
> 
> [email protected] <- exp(ci1[, 1])
> [email protected] <- exp(ci2[, 1])
> [email protected] <- exp(ci3[, 1])
> [email protected] <- exp(ci1[, 2])
> [email protected] <- exp(ci2[, 2])
> [email protected] <- exp(ci3[, 2])
> 
> screenreg(list(tex1, tex2, tex3))

========================================================
            Model 1       Model 2       Model 3     
--------------------------------------------------------
(Intercept)        1.34 *        1.32 *        1.34 *   
                [1.18; 1.53]  [1.17; 1.50]  [1.18; 1.53]
x1                 1.81 *                      1.81 *   
                [1.58; 2.10]                [1.58; 2.10]
x2                               1.05 *        1.01 *   
                              [0.93; 1.19]  [0.89; 1.15]
--------------------------------------------------------
AIC             1294.48       1369.92       1296.47     
BIC             1304.30       1379.74       1311.19     
Log Likelihood  -645.24       -682.96       -645.23     
Deviance        1290.48       1365.92       1290.47     
Num. obs.       1000          1000          1000        
========================================================
* 0 outside the confidence interval
like image 609
pe-perry Avatar asked Dec 23 '15 03:12

pe-perry


1 Answers

There is a ci.test parameter which can be set as the "null value" as would be appropriate for the transformed parameters in this case. It should be set at 1.0 rather than 0. So this succeeds:

  screenreg(list(tex1, tex2, tex3), ci.test=1)

#------output--------
========================================================
                Model 1       Model 2       Model 3     
--------------------------------------------------------
(Intercept)        1.34 *        1.32 *        1.34 *   
                [1.18; 1.53]  [1.17; 1.50]  [1.18; 1.53]
x1                 1.81 *                      1.81 *   
                [1.58; 2.10]                [1.58; 2.10]
x2                               1.05          1.01     
                              [0.93; 1.19]  [0.89; 1.15]
--------------------------------------------------------
AIC             1294.48       1369.92       1296.47     
BIC             1304.30       1379.74       1311.19     
Log Likelihood  -645.24       -682.96       -645.23     
Deviance        1290.48       1365.92       1290.47     
Num. obs.       1000          1000          1000        
========================================================
* 1 outside the confidence interval

Notice that 2 of the 6 parameter estimates are no longer starred.

like image 137
IRTFM Avatar answered Sep 28 '22 04:09

IRTFM