The hazard ratio is calculated using survival analysis methodologies such as the Cox proportional hazards model. This model assesses the effect of various covariates on the hazard rate. The formula for the HR in this model is:
\[ \text{HR} = \exp(\beta) \]
where \(\beta\) is the coefficient for the covariate of interest in the Cox model. The exponential function ensures that the HR is always positive.