I'm trying to do a meta-analysis in R (using metafor) of trials where the outcomes are hazard ratios and I'm given the 95% CI for them and/or the standard error and n.

So if I have columns like:

Trial name      HR      SE     n

I've looked at http://www.inside-r.org/packages/cran/metafor/docs/dat.pignon2000

It seems what I want is

1) The log of the hazard ratio (easy)

2) The variances (I figure I can do (SE*sqrt(n))^2 , where SE is even given or worked out from the 95% CI).

So the code is something like:

#Effect sizes == log HR
dat$yi <- with(dat, log(mid_per_unit))

#Variances == (SE*sqrt(n))^2
dat$vi <- with(dat, (SE*sqrt(n))^2)

res <- rma(yi, vi, data=dat, method="FE")



1) I'm not sure if this is valid

2) I end up with a Forest plot (I guess) of the log of HR? I guess to find the 'meta-analysed' HR I just do log(the estimate)?

ADDENDUM: Instead of worrying about back-transforming, by far the easiest thing to do is add atransf=exp to the forest() call of the rma object.

  • 3
    $\begingroup$ You could just use the option sei in rma and provide the standard errors directly. Otherwise, use SE$^{2}$ with vi. And do you have the standard errors on the log-scale? $\endgroup$ Jun 27, 2015 at 20:34
  • $\begingroup$ Spot on. And note that log() in R is the natural log, so you back-transform with exp() (not with 10^estimate). $\endgroup$
    – Wolfgang
    Jun 27, 2015 at 21:13
  • 3
    $\begingroup$ If the 95%-confidence intervals were calculated on the log-scale and the exponentiated, you could retrieve the standard error on the log scale by calulcating $(\log(U)-\log(HR))/1.96$ where $U$ is the upper limit of the confidence interval on the original scale. Then you could supply this value to sei. $\endgroup$ Jun 28, 2015 at 11:06
  • $\begingroup$ Really, @COOLSerdash already answered the question in the comments, but given the remaining confusion (with a duplicate question asked by the OP), I bundled up the various points in a more complete answer. And as I indicate in my answer, I very much doubt that the OP really has standard errors for the raw hazard ratios. In all likelihood, those SEs refer to the log hazard ratios. $\endgroup$
    – Wolfgang
    Jun 28, 2015 at 16:14

1 Answer 1


Assuming that you have the log hazard ratios (collected in the vector yi) and the standard errors of the log hazard ratios (collected in the vector sei), then you can fit a fixed-effects model to these data with:

res <- rma(yi, sei=sei, data=dat, method="FE")

As with several other outcome measures typically used for meta-analyses (e.g., risk ratios, odds ratios, incidence rate ratios), we do not meta-analyze the hazard ratios directly, but first log-transform them. This has two purposes:

  1. The sampling distribution of the raw hazard ratio is typically very skewed. However, standard meta-analytic models assume that the sampling distribution of the outcome measure is (at least approximately) normal and that assumption is much more appropriate for the log-transformed hazard ratio.

  2. Raw hazard ratios are not symmetric around 1. So, if one were to average a hazard ratio of 0.5 and 2.0 (which are exact opposites of each other), then we would get 1.25, which makes no sense. However, the log-transformed values are -0.6931 and +0.6931, whose average is 0. After back-transformation (exponentiation), we get 1, and the appropriate conclusion that, on average, the hazard ratio is 1.

Also note that analyses using the Cox proportional hazards model (which is often the source of hazard ratios obtained for a meta-analysis) are done on the log-scale. So, when the standard error is reported together with the hazard ratio, that standard error in all likelihood refers to the log-transformed hazard ratio, not the raw one (in fact, given the skewness of the distribution of the raw hazard ratio, the usefulness of a standard error for the raw hazard ratio, if it were indeed reported, is rather questionable).

Similarly, if a confidence interval is reported, then in all likelihood it was constructed on the log-scale and the bounds were exponentiated afterwards. We can then easily back-calculate the SE of the log hazard ratio. See also this question, which deals exactly with that issue.

The same goes for hazard ratios that are reported in conjunction with the results from the log-rank test. Not surprisingly, as the name of the test implies, the underlying analysis is also done on the log scale. So, a standard error that is computed based on such results again refers to log hazard ratio, not the raw one.

A few additional comments:

  1. The sampling variance of the log hazard ratio is obtained by simply squaring the standard error. So, you could just use rma(yi, sei^2, data=dat, method="FE") or first create vi <- dat$sei^2 and then rma(yi, vi, data=dat, method="FE"). Do not multiply/divide by the sample size or square-root thereof.

  2. The standard error of the log hazard ratio is not the same as taking the log of the standard error of the raw hazard ratio. One cannot just apply the same transformation to the standard error (or variance). In some cases, one can use the delta method to approximate the standard error (or variance) of some random variable following a transformation.

  • 1
    $\begingroup$ (1+), Thanks Wolfang for posting such a complete and comprehensive answer. $\endgroup$ Jun 28, 2015 at 16:34
  • 1
    $\begingroup$ @COOLSerdash You pretty much hit all important points in your comments, so the thanks should also go to you. $\endgroup$
    – Wolfgang
    Jun 28, 2015 at 17:59

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.