4

I am trying to draw a forest plot for the results of cox model with repeated measures considering subjects ids; here is a part of my big data;

data <- read.table(header=TRUE, text="
  Id   start end     QS   Age Event 
  01     0     70     1    25   1
  01    70     78     2    25   1
  01    78     85     3    25   1
  02     0     92     4    23   1
  02    92     98     5    23   1
  02    98     105    6    23   1
  02   105     106    7    23   0
")

The cox model is:

set.seed(1234)
model <- coxph(Surv(start, end, Event) ~  QS + Age
           + cluster(Id), data = data, id=Id)

with the results:


> model
Call:
coxph(formula = Surv(start, end, Event) ~ QS, data = data, id = Id, 
    cluster = Id)

         coef  exp(coef)   se(coef)  robust se      z      p
QS -1.896e+01  5.829e-09  1.310e+04  1.000e+00 -18.96 <2e-16

Likelihood ratio test=4.16  on 1 df, p=0.04142
n= 7, number of events= 6 

The function for forest plot

ggforest(model, data = data)

provides a figure like:

enter image description here

which is not my ideal and I am not sure if it is the right picture. For example why the id is considered as a variable in the picture.

Katie
  • 119
  • 1
  • 7
  • What if you use `model <- coxph(Surv(start, end, Event) ~ QS + Age, data = dat, cluster = Id)` then `ggforest(model)`? – Tung Dec 25 '21 at 08:25
  • Thank you for your comment. It would still dedicate one row for cluster. – Katie Dec 26 '21 at 20:31

0 Answers0