0
votes

I am trying to use a log scale on my forest plot of hazard ratios. I input the hazard ratio estimates and confidence intervals by hand into my plot, but I need the same values (unchanged) to be on a log scale when plotted. Preferably with the same tick marks as the plot currently has on the arithmetic scale. Is there an easy way to do this?

I tried atransf = exp, which changes all my hazard ratios. I also tried at = log(c(0.25, 0.5, 1, 2, 4, 6)), which changes all the tick marks drastically. How can I convert to the log scale without changing the numeric tick marks of my axes and the values of my hazards?

Thanks for your help.

#Forest Plot
label1 <- as.character(c("<50", "50 to <60", "60"))
label1 <- factor(label1, levels = unique(label1))
hazards1 <- c(1.42, 1.66, 2.85)
lower1 <- c(1.34, 1.50, 2.59)
upper1 <- c(1.51, 1.85, 3.13)
patient_num1 <- c(240000, 180000, 220000)
event_num1 <- c(2600, 1300, 2900)
forestplot1 <- data.frame(label1, hazards1, lower1, upper1, event_num1, patient_num1)
forestplot1$patient_num1 <- rev(forestplot1$patient_num1)

par(mar=c(4,4,1,2))
pdf(file = "figureex.pdf", width = 15, height = 8.5)
pdf.options(encoding='ISOLatin2.enc')
forest(rev(hazards1), ci.lb = rev(lower1), ci.ub = rev(upper1), slab = rev(label1), xlim = c(-4,0), 
       xlab = "Adjusted Hazard Ratio for Event", 
       refline = 1, annotate = T, ylim = c(-1, 29), ilab = cbind(forestplot1$patient_num1, rev(event_num1)),
       ilab.xpos=c(-1,-0.25), at = c(0.25, 0.5, 1, 2, 4, 6), rows = c(1:3),
       cex = 1, yaxs = "i")
text(-4, 27.29, pos = 4, "Variable")
text(-1.25, 27.67, pos = 4, "No. of \nPatients")
text(-0.45, 27.67, pos = 4, "No. of \nEvents")
text(5.05, 27.69, pos = 4, "Hazard Ratio \n(95% CI)")
dev.off()
1
I can't run your code, I get the following error no applicable method for 'forest' applied to an object of class "c('double', 'numeric')", do you only load the package meta or do you load another package? - Chelmy88

1 Answers

1
votes

It looks like you're using the forest function in the metafor package. The function forestplot in the package forestplot allows you to specify the tick marks with xticks as well as use log scale for the tick marks with xlog.