Risk (Prospective)
Menu location: Analysis_Clinical Epidemiology_Risk (Prospective).
This function calculates relative risk, risk difference and population attributable risk difference with confidence intervals.
You can examine the risk of an outcome, such as disease, given the incidence of the outcome in relation to an exposure, such as a suspected risk or protection factor for a disease. The study design should be prospective. If you need information on retrospective studies see risk (retrospective).
The type of data used by this function is counts or frequencies (number of individuals with a study characteristic). If you want to analyse person-time data (e.g. months of follow up) instead of counts then please see incidence rates.
In studies of the incidence of a particular outcome in two groups of individuals, defined by the presence or absence of a particular characteristic, the relative risk can be calculated directly from the resultant fourfold table; the odds ratio for that table approximates the relative risk when the outcome is rare. Relative risk is used for prospective studies where you follow groups with different characteristics to observe whether or not a particular outcome occurs:
| EXPOSURE | |||
| EXPOSED | UNEXPOSED | ||
| OUTCOME: | YES: | a | b |
| NO: | c | d | |
Outcome rate exposed (Pe) = a/(a+c)
Outcome rate not exposed (Pu) = b/(b+d)
Relative risk (RR) = Pe/Pu
Risk difference (RD) = Pe-Pu
Estimate of population exposure (Px) = (a+c)/(a+b+c+d)
Population attributable risk % = 100*(Px*(RR-1))/(1+(Px*(RR-1)))
In retrospective studies where you select subjects by outcome not by group characteristic then you would use the odds ratio ((a/c)/(b/d)) and not the relative risk. See risk (retrospective) for more information.
In addition to the relative measure of effect (relative risk) you may wish to express the absolute effect size in your study as the risk difference. Risk difference is sometimes referred to as attributable risk and when expressed as a percentage of the risk in the exposed group it is also referred to as attributable proportion or attributable rate percent (for a protective factor the corresponding measure, as a percentage of the risk in the unexposed group, is the preventive fraction). Attributable risk or risk difference is used to quantify risk in the exposed group that is attributable to the exposure.
Population attributable risk estimates the proportion of disease in the study population that is attributable to the exposure. In order to calculate population attributable risk, the prevalence of exposure in the study population must be known or estimated, StatsDirect prompts you to enter this value or to default to an estimate made from your study data. Population attributable risk is presented as a percentage with a confidence interval when the relative risk is greater than one (Sahai and Khurshid, 1996).
Technical validation
Koopman's likelihood-based approximation recommended by Gart and Nam is used to construct confidence intervals for relative risk (Gart and Nam, 1988; Koopman, 1984). Please note that relative risk, risk ratio and likelihood ratio are all calculations for ratios of binomial probabilities, therefore, the approach to confidence intervals is the same for each of them.
The confidence interval for risk difference is constructed using the robust approximation of Miettinen and Nurminen (Miettinen and Nurminen, 1985; Mee, 1984; Anbar, 1983; Gart and Nam, 1990; Newcombe, 1998b).
Approximate power is calculated as the power achieved with the given sample size to detect the observed effect with a two-sided probability of type I error of (100-CI%)% based on analysis with Fisher's exact test or a continuity corrected chi-square test of independence in a fourfold contingency table (Dupont, 1990).
Walter's approximate variance formula is used to construct the confidence interval for population attributable risk (Walter, 1978; Leung and Kupper, 1981).
Example
From Sahai and Khurshid (1996, p. 208).
The following data are a subset of the Framingham study results showing the number of cases of coronary heart disease (CHD) becoming clinically apparent six years after follow up of a cohort of 1329 men in the 40 to 59 age group. The men are divided by their level of serum cholesterol (a suspected risk factor) at the start of the study:
| Cholesterol >=220 mg% | Cholesterol < 220 mg% | |
| CHD: | 72 | 20 |
| No CHD: | 684 | 553 |
To analyse these data in StatsDirect select Risk (Prospective) from the Clinical Epidemiology section of the Analysis menu. Choose the default 95% confidence interval. Then enter the above frequencies into the 2 by 2 table on the screen.
For this example:
Risk ratio (relative risk in incidence study) = 2.728571
Approximate (Koopman) 95% confidence interval = 1.694347 to 4.412075
Approximate power (for 5% significance) = 99.13%
Risk difference = 0.060334
Approximate (Miettinen) 95% confidence interval = 0.034379 to 0.086777
Population exposure % = 56.884876
Population attributable risk % = 49.578875
Approximate (Walter) 95% confidence interval = 30.469457 to 68.688294
Here we can say that the risk of CHD in men of this age is around two and a half times greater for those of them with serum cholesterol above 220 mg% compared with those with lower cholesterol levels. The confidence interval excludes one, indicating a significant result, and with 97.5% confidence we can say that this relative risk is at least 1.69 if the cohort is typical of men of this age in the wider population to which we are applying these results.
The population attributable risk estimates the proportion of disease (or other outcome) in the population that is attributable to the exposure. From these results we can say, with 95% confidence, that somewhere between 30% and 70% of the cases of CHD in 40 to 59 year old men are associated with high cholesterol (above 220 mg%).
R code
This R code reproduces the example above. It needs no packages and was checked with R 4.6.1. Paste it into R, or save it as a script and run it.
# Risk (prospective): the StatsDirect help example (Sahai and Khurshid 1996, coronary
# heart disease after six years in 1329 Framingham men aged 40 to 59, by serum
# cholesterol at the start) in R
counts <- matrix(c(72, 20,
684, 553), 2, byrow = TRUE,
dimnames = list(CHD = c("Yes", "No"),
Cholesterol = c("220 or more", "Under 220")))
print(addmargins(counts))
a <- counts[1, 1] # exposed with the outcome
b <- counts[1, 2] # unexposed with the outcome
c <- counts[2, 1] # exposed without it
d <- counts[2, 2] # unexposed without it
n1 <- a + c # exposed
n2 <- b + d # unexposed
m1 <- a + b # with the outcome
n <- n1 + n2
# R's standard test compares the two outcome rates, 72 of 756 and 20 of 573, with
# a chi-square test (uncorrected here). The two rates it prints are the risks in the
# exposed and the unexposed, but its interval for their difference is the simple
# normal (Wald) one, not the Miettinen and Nurminen interval of the report
print(prop.test(t(counts), correct = FALSE))
six <- function(x) formatC(x, digits = 6, format = "f", drop0trailing = TRUE)
p1 <- a / n1
p0 <- b / n2
rr <- p1 / p0
cat("Risk ratio (relative risk in incidence study) =", six(rr), "\n")
# Base R has no function for the confidence interval of a ratio of two binomial
# proportions, so the limits are found as Koopman (1984) defines them: the ratios at
# which the score chi-square, with the two rates estimated under the constraint that
# they have that ratio, reaches the 95% critical value. Every count in the example is
# greater than zero, which this function assumes.
koopman <- function(x1, n1, x0, n0, level = 0.95) {
chi2 <- function(theta) {
A <- (n0 + n1) * theta
B <- -((x0 + n1) * theta + x1 + n0)
q0 <- (-B - sqrt(B^2 - 4 * A * (x0 + x1))) / (2 * A) # constrained estimate
q1 <- theta * q0
(x1 - n1 * q1)^2 / (n1 * q1 * (1 - q1)) *
(1 + n1 * (theta - q1) / (n0 * (1 - q1)))
}
est <- (x1 / n1) / (x0 / n0)
f <- function(lt) chi2(exp(lt)) - qchisq(level, 1)
lower <- exp(uniroot(f, c(log(est) - 20, log(est)), tol = 1e-12)$root)
upper <- exp(uniroot(f, c(log(est), log(est) + 20), tol = 1e-12)$root)
c(lower, upper)
}
k <- koopman(a, n1, b, n2)
cat("Approximate (Koopman) 95% confidence interval =", six(k[1]), "to", six(k[2]),
"\n")
# Approximate power: the power with which Fisher's exact test on groups of this size
# (756 exposed, 573 unexposed) would detect the observed difference between the two
# rates at the two sided 5% level. It is the power at which the continuity corrected
# sample size formula of Casagrande, Pike and Smith (1978), in the form given by
# Fleiss, returns the size of the exposed group.
alpha <- 0.05
m <- n2 / n1 # unexposed per exposed subject
z <- qnorm(1 - alpha / 2)
pbar <- (p1 + m * p0) / (m + 1)
size_for_power <- function(power) {
zb <- qnorm(power)
np <- (z * sqrt((1 + 1 / m) * pbar * (1 - pbar)) +
zb * sqrt(p0 * (1 - p0) / m + p1 * (1 - p1)))^2 / (p0 - p1)^2
np * (1 + sqrt(1 + 2 * (m + 1) / (np * m * abs(p0 - p1))))^2 / 4
}
power <- uniroot(function(pw) size_for_power(pw) - n1, c(alpha, 1 - 1e-12),
tol = 1e-10)$root # the size falls as the power asked for falls
cat("Approximate power (for 5% significance) = ",
formatC(100 * power, digits = 2, format = "f"), "%\n", sep = "")
# The risk difference, with the score interval of Miettinen and Nurminen (1985): the
# differences at which the chi-square, with the two rates estimated by maximum
# likelihood under the constraint that they differ by that amount, reaches the 95%
# critical value. The variance carries their factor of N / (N - 1).
cat("Risk difference =", six(p1 - p0), "\n")
miettinen <- function(x1, n1, x0, n0, level = 0.95) {
dhat <- x1 / n1 - x0 / n0
chi2 <- function(delta) {
loglik <- function(q0) {
q1 <- q0 + delta
x1 * log(q1) + (n1 - x1) * log(1 - q1) + x0 * log(q0) + (n0 - x0) * log(1 - q0)
}
q0 <- optimize(loglik, c(max(0, -delta), min(1, 1 - delta)), maximum = TRUE,
tol = 1e-12)$maximum
q1 <- q0 + delta
(dhat - delta)^2 /
((q1 * (1 - q1) / n1 + q0 * (1 - q0) / n0) * (n1 + n0) / (n1 + n0 - 1))
}
f <- function(delta) chi2(delta) - qchisq(level, 1)
lower <- uniroot(f, c(-1 + 1e-9, dhat), tol = 1e-12)$root
upper <- uniroot(f, c(dhat, 1 - 1e-9), tol = 1e-12)$root
c(lower, upper)
}
mn <- miettinen(a, n1, b, n2)
cat("Approximate (Miettinen) 95% confidence interval =", six(mn[1]), "to", six(mn[2]),
"\n")
# Population attributable risk, reported when the relative risk exceeds 1. With no
# population figure entered, the proportion exposed is estimated from the cohort as
# (a + c) / n, and the attributable fraction Px (RR - 1) / (1 + Px (RR - 1)) is then
# the same as 1 - (b / (b + d)) / ((a + b) / n): the share of the overall incidence
# that would go if the whole cohort had the rate of the unexposed. Its large sample
# variance is Walter's (1978). All three are printed as percentages.
px <- n1 / n
par <- px * (rr - 1) / (1 + px * (rr - 1))
var_par <- b * n * (a * d * (n - b) + b^2 * c) / (m1^3 * n2^3)
cat("Population exposure % =", six(100 * px), "\n")
cat("Population attributable risk % =", six(100 * par), "\n")
cat("Approximate (Walter) 95% confidence interval =",
six(100 * (par - z * sqrt(var_par))), "to", six(100 * (par + z * sqrt(var_par))),
"\n")