Say I have my.model
My.model <- coxph(Surv(stop, event) ~ (rx + size + number) * strata(enum),
cluster = id, bladder1)
I would like to create a model report table which contains exp(coefs)
instead of coefs
stargazer(my.model)
is there a parameter like exponentiate = TRUE
which would report exp(coefs)
instead of coefs
?, or I need to transform the model results before passing to stargazer()
?
In order to get exponentiated coeficients, need to add parameters apply.coef = exp, p.auto = FALSE, t.auto = FALSE
.
My.model <- coxph(Surv(stop, event) ~ rx + size + number,
cluster = id, bladder)
Original Model untransformed coeffs
stargazer(My.model, align=TRUE,
type="text", digits = 3)
================================================
Dependent variable:
---------------------------
stop
------------------------------------------------
rx -0.540*
(0.200)
size -0.055
(0.070)
number 0.193***
(0.046)
------------------------------------------------
Observations 340
R2 0.064
Max. Possible R2 0.971
Log Likelihood -588.104
Wald Test 12.510*** (df = 3)
LR Test 22.321*** (df = 3)
Score (Logrank) Test 25.183*** (df = 3)
================================================
Note: se in parenthesis *p<0.1; **p<0.05; ***p<0.01
Use the parameter apply.coef = exp
to exponentiate.
stargazer(My.model, align=TRUE, apply.coef = exp,
type="text", digits = 3)
================================================
Dependent variable:
---------------------------
stop
------------------------------------------------
rx 0.583***
(0.200)
size 0.947***
(0.070)
number 1.213***
(0.046)
------------------------------------------------
Observations 340
R2 0.064
Max. Possible R2 0.971
Log Likelihood -588.104
Wald Test 12.510*** (df = 3)
LR Test 22.321*** (df = 3)
Score (Logrank) Test 25.183*** (df = 3)
================================================
Note: se in parenthesis *p<0.1; **p<0.05; ***p<0.01
However, as you can see, the stars are providing misleading inference, because t.stat = coef/se, however, in this case exponentiated coefs are being used as the numerator to compute the t stats and p values.
Solution is to add parameters p.auto = FALSE
and t.auto = FALSE
this will allows to use the original coefficients to compute the t.stats and p.values of the model.
stargazer(My.model, align=TRUE,
type="text", apply.coef = exp, p.auto = FALSE,
t.auto = FALSE, digits = 3)
================================================
Dependent variable:
---------------------------
stop
------------------------------------------------
rx 0.583*
(0.200)
size 0.947
(0.070)
number 1.213***
(0.046)
------------------------------------------------
Observations 340
R2 0.064
Max. Possible R2 0.971
Log Likelihood -588.104
Wald Test 12.510*** (df = 3)
LR Test 22.321*** (df = 3)
Score (Logrank) Test 25.183*** (df = 3)
================================================
Note: se in parenthesis *p<0.1; **p<0.05; ***p<0.01
Moreover, to avoid confusion with your reader, you may report t.stats or pvalues instead of standard errors.
stargazer(My.model, align=TRUE,
type="text", apply.coef = exp, p.auto = FALSE,
t.auto = FALSE, digits = 3, report=('vc*p'))
================================================
Dependent variable:
---------------------------
stop
------------------------------------------------
rx 0.583*
p = 0.070
size 0.947
p = 0.535
number 1.213***
p = 0.005
------------------------------------------------
Observations 340
R2 0.064
Max. Possible R2 0.971
Log Likelihood -588.104
Wald Test 12.510*** (df = 3)
LR Test 22.321*** (df = 3)
Score (Logrank) Test 25.183*** (df = 3)
================================================
Note: *p<0.1; **p<0.05; ***p<0.01