how to display t value in texreg

1.3k views Asked by At

I'm a beginner in R, and I have got a question on texreg.

I have been searching for information online for days but I didn't find much. I want to include the t value in my exported table by using texreg, and I want my t value to be located just under each coefficient in [].

It would be really appreciated if anyone could offer me some hints, thanks!

1

There are 1 answers

1
Philip Leifeld On

Normally, standard errors should be reported in brackets. However, if you really want to replace them by t values, you can do so as follows.

An example regression analysis from the lm documentation:

ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2, 10, 20, labels = c("Ctl","Trt"))
weight <- c(ctl, trt)
lm.D9 <- lm(weight ~ group)
lm.D90 <- lm(weight ~ group - 1)

Solution 1:

screenreg(list(lm.D9, lm.D90), override.se = 
    list(c(0.5, 0.5), c(0.5, 0.5)))

This overrides the standard errors and replaces them by custom values which you provide. The resulting table:

=================================
             Model 1    Model 2  
---------------------------------
(Intercept)   5.03 ***           
             (0.50)              
groupTrt     -0.37       4.66 ***
             (0.50)     (0.50)   
groupCtl                 5.03 ***
                        (0.50)   
---------------------------------
R^2           0.07       0.98    
Adj. R^2      0.02       0.98    
Num. obs.    20         20       
=================================
*** p < 0.001, ** p < 0.01, * p < 0.05

Solution 2:

Instead of handing over the models to texreg, you can extract the coefficients etc. and save them to an object, manipulate the object, and hand over the manipulated object to texreg.

tr1 <- extract(lm.D9)
tr1@se <- c(0.5, 0.5)  # enter new values, e.g., t values
tr2 <- extract(lm.D90)
tr2@se <- c(0.5, 0.5)  # enter new values, e.g., t values
screenreg(list(tr1, tr2))

It is currently not possible to replace the round brackets by square brackets.