Hi,
I would like to create a forest plot for a multistate cox model but I found several errors. This is the code:
data3$Age <- factor(data3$Age, levels = c("2", "3","4","5","6","7","1","8"), labels = c("0-19", "20-29","30-39","40-49","50-59","60-69","70-79","over 80"))
data3$Age = relevel(data3$Age, ref = "70-79")
cfit5 <- coxph(Surv(tstart, tstop, event) ~ Age, data=data3, id=ID_PER)
print(cfit5)
ggforest(cfit5, data = data3, main='Hazard ratios')
The print(cfit5) returns:
Call:
coxph(formula = Surv(tstart, tstop, event) ~ Age, data = data3,
id = ID_PER)
1:2 coef exp(coef) se(coef) robust se z p
Age0-19 -4.837530 0.007927 0.451604 0.451514 -10.714 < 2e-16
Age20-29 -3.275286 0.037806 0.250534 0.250780 -13.060 < 2e-16
Age30-39 -2.555934 0.077620 0.161761 0.161791 -15.798 < 2e-16
Age40-49 -1.659342 0.190264 0.107592 0.107605 -15.421 < 2e-16
Age50-59 -1.259441 0.283813 0.095800 0.095584 -13.176 < 2e-16
Age60-69 -0.447559 0.639186 0.090040 0.089715 -4.989 6.08e-07
Ageover 80 0.113969 1.120717 0.079134 0.079331 1.437 0.151
1:3 coef exp(coef) se(coef) robust se z p
Age0-19 -4.04378 0.01753 1.02154 1.02226 -3.956 7.63e-05
Age20-29 -3.70267 0.02466 1.02154 1.02129 -3.625 0.000288
Age30-39 -2.16580 0.11466 0.45848 0.45777 -4.731 2.23e-06
Age40-49 -1.93219 0.14483 0.39324 0.39234 -4.925 8.44e-07
Age50-59 -1.33445 0.26330 0.32560 0.32678 -4.084 4.43e-05
Age60-69 -0.23070 0.79398 0.28377 0.28356 -0.814 0.415890
Ageover 80 -0.83425 0.43420 0.33189 0.33192 -2.513 0.011957
2:3 coef exp(coef) se(coef) robust se z p
Age0-19 1.074e+00 2.928e+00 1.017e+00 1.084e+00 0.991 0.321624
Age20-29 -1.253e+01 3.610e-06 3.597e+02 3.256e-01 -38.486 < 2e-16
Age30-39 -3.211e-02 9.684e-01 4.831e-01 4.980e-01 -0.064 0.948584
Age40-49 -9.726e-01 3.781e-01 4.473e-01 4.510e-01 -2.157 0.031028
Age50-59 -1.839e-01 8.320e-01 2.983e-01 3.006e-01 -0.612 0.540722
Age60-69 2.390e-01 1.270e+00 2.507e-01 2.538e-01 0.942 0.346310
Ageover 80 -1.149e+00 3.170e-01 3.036e-01 3.054e-01 -3.761 0.000169
States: 1= (s0), 2= altro ricovero, 3= intensiva
Likelihood ratio test=1658 on 21 df, p=< 2.2e-16
n= 18823, number of events= 1524
The result of the model is good but then when I try to create the forest plot I obtain:
Errore in axisTicks(rangeb/2, log = TRUE, nint = 7) :
log - axis(), 'at' creation, _LARGE_ range: invalid {xy}axp or par; nint=7
axp[0:1]=(1e-307,1e+308), usr[0:1]=(0,inf); i=615, ni=87
In aggiunta: Messaggi di avvertimento:
1: In min(x) : nessun argomento non-mancante al minimo; si restituisce Inf
2: In max(x) :
nessun argomento non-mancante al massimo; si restituisce -Inf
Can someone help me? Thank you