1
$\begingroup$

Is there a way to output the results of a cox ph with frailty term using stargazer? I get the following error when I try it:

stargazer(fit1) Error in .summary.object$coef[, "z"] : subscript out of bounds

Without the frailty term it is possible. Could someone help me out?

Edit: If my question is unclear, I will create an example. However, I can't share my data.

Edit2: Example:

library(survival)
library(stargazer)
data(rats)

cox_ph=coxph(Surv(time/52,status)~factor(rx), data=rats)
stargazer(cox_ph)

cox_ph_with_frailty=coxph(Surv(time/52,status)~factor(rx)+frailty(litter), data=rats)
stargazer(cox_ph_with_frailty)
str(cox_ph_with_frailty)

stargazer(cox_ph) produces nice Latex output, stargazer(cox_ph_with_frailty) produces the above error.

$\endgroup$
3
  • $\begingroup$ can you share an example along with str(fit1)? $\endgroup$ Commented Apr 12, 2020 at 14:19
  • $\begingroup$ I produced an example. I can add the str(fit1) if it is necessary, however it is quite large. $\endgroup$
    – Cardinal
    Commented Apr 13, 2020 at 9:08
  • $\begingroup$ I believe that the stargazer does not support 'coxph.penal' $\endgroup$ Commented Apr 13, 2020 at 21:54

1 Answer 1

2
+50
$\begingroup$

I don't have expertise in coxph models. Howeveer, I went through the structure of the two models and found the class of "cox_ph_with_frailty" to be coxph.penal.

end of str(cox_ph)

enter image description here

end of stargazer(cox_ph_with_frailty)

enter image description here

I have gone through the documentation for stargazer. It clearly says that it supports coxph, clogit and survreg.

enter image description here

I am aware that texreg will be of more use. The documentation for texreg says it supports coxph.penal.

enter image description here

Another document by Philip Leifeld is also confirming this.

enter image description here

However, When I tried texreg I found that the texreg and extract were not reproducing the complete information available in the output of "cox_ph_with_frailty". We need to do some tweaks in the function.

$\endgroup$
1
  • $\begingroup$ I consider this a complete answer. Thanks! $\endgroup$
    – Cardinal
    Commented Apr 15, 2020 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.