Edu
Edu

Reputation: 903

R: Mixed Effects Cox Model (coxme) output in latex

I have derived a Mixed Effects Cox Model with coxme and I am trying to extract the result in a latex table. I see that texreg() does not work and I wonder whether there would be other alternatives.

Upvotes: 1

Views: 1013

Answers (1)

r.bot
r.bot

Reputation: 5424

I really like the broom with pixiedust packages for this type of problem. Broom won't handle coxme objects out of the box, but a third package ehahelper provides functions for these objects.

# install ehahelper, not on cran
devtools::install_github('junkka/ehahelper')

Once installed do tidying

library(coxme)
library(ehahelper)
library(broom)
fit <- coxme(Surv(y, uncens) ~ trt + (1|center), eortc)
tidy_fit <- tidy(fit)
class(tidy_fit)
[1] "data.frame"
tidy_fit
  term  estimate  std.error statistic p.value  conf.low conf.high
1  trt 0.7086127 0.06424398     11.03       0 0.5826968 0.8345286

Once in a dataframe, you will be able to export to xtable, or use pixiedust within a markdown doc to pdf.

Upvotes: 4

Related Questions