UK-based online statistics and data analysis support for USA, UK, and international clients. No exams, no impersonation, no fabricated data.
Chi-Square and Categorical Data Tests

Relative Risk: Formula, Calculator, Interpretation, Python, R, SPSS and Excel Guide

Comparing event probabilities in two independent groups Relative Risk: Formula, Calculator, Interpretation, Python, R, SPSS and Excel Guide Relative risk, also called the risk ratio, compares...

Statistics guide Ethical learning support SPSS/R/Python/Excel friendly
Relative Risk: Formula, Calculator, Interpretation, Python, R, SPSS and Excel Guide


Comparing event probabilities in two independent groups

Relative Risk: Formula, Calculator, Interpretation, Python, R, SPSS and Excel Guide

Relative risk, also called the risk ratio, compares an event probability in one group with the event probability in a reference group. This complete guide explains the relative risk formula, how to calculate and interpret relative risk, confidence intervals, absolute versus relative risk, odds ratio comparisons, calculator checks, Python, R, SPSS, Stata and Excel workflows, APA reporting, ten unique chart interpretations and downloadable reports through a worked analysis of 649 students.

2 × 2 cohort-style table
649 observations
RR = 0.7563
95% CI [0.6914, 0.8274]

Relative Risk Model Overview

Relative risk is the ratio of two event probabilities. It answers a proportional question: how large is the event risk in the numerator group compared with the event risk in the reference group? The term risk ratio is statistically equivalent and is often preferred because the estimate is a ratio rather than a vague measure of “relative” risk.

What Question Does It Answer?

The worked analysis asks whether the probability of G3 ≥ 10 differs between MS and GP students. MS is defined as the numerator or exposed group, GP is the reference group, and the event is passing the selected threshold.

H0: RR = 1    versus    H1: RR ≠ 1

How Relative Risk Is Built

First calculate the event proportion within each group. Then divide the MS risk by the GP risk. A value of 1 means equal risks, a value below 1 means the numerator group has a lower event risk, and a value above 1 means the numerator group has a higher event risk.

How Relative Risk Differs from an Odds Ratio

Relative risk compares probabilities, while an odds ratio compares odds. The distinction matters when the event is common. In this table, RR = 0.756 but the odds ratio is about 0.190, so substituting odds language for risk language would strongly exaggerate the proportional difference.

Worked Example at a Glance

Among 226 MS students, 158 reached G3 ≥ 10, giving a pass risk of 69.91%. Among 423 GP students, 391 reached the threshold, giving a pass risk of 92.43%. The MS-to-GP relative risk is 0.7563, with a 95% Katz log confidence interval from 0.6914 to 0.8274. The absolute MS-minus-GP risk difference is −22.52 percentage points.

Overview conclusion: MS students had about 75.6% of the observed GP pass risk, or a 24.4% lower relative pass risk. The comparison is statistically precise, but it remains an unadjusted observational association rather than evidence that school alone caused the difference.
AdvertisementGoogle AdSense top placement reserved here

Quick Answer: Relative Risk Result

The analysis compares the probability of G3 ≥ 10 in MS with the probability in GP. The risk ratio and its Katz log confidence interval are the primary results.

MS pass risk69.91%
GP pass risk92.43%
Relative risk0.7563
95% confidence interval0.6914–0.8274

Estimate Summary

  • Numerator group: MS
  • Reference group: GP
  • Event: G3 ≥ 10
  • Relative risk: 0.7563316
  • Interval method: Katz log confidence interval

Substantive Meaning

  • MS: 158 of 226 passed.
  • GP: 391 of 423 passed.
  • MS risk was 24.37% lower on a relative scale.
  • MS risk was 22.52 percentage points lower on an absolute scale.
  • The confidence interval lies entirely below 1.
Best interpretation: the observed probability of G3 ≥ 10 in MS was 0.756 times the observed probability in GP, RR = 0.756, 95% CI [0.691, 0.827].
Do not report only “24% lower”: also report both group risks, the absolute percentage-point difference, the confidence interval and the direction of comparison. Avoid causal “reduction” wording unless the design supports it.

Table of Contents

  1. Research question, hypotheses and data design
  2. When to use relative risk
  3. Relative risk formula and calculation
  4. Variables and data dictionary
  5. Worked 2 × 2 table and complete results
  6. Relative risk versus odds ratio and related methods
  7. Relative risk calculator steps
  8. Ten unique Python and R chart interpretations
  9. Python, R, SPSS, Stata and Excel workflows
  10. Expandable software code
  11. Assumptions, limitations and advanced interpretation
  12. APA reporting for relative risk
  13. Common mistakes and corrections
  14. Reports and worked Excel download
  15. Related Salar Cafe guides
  16. Frequently asked questions
  17. Conclusion

Research Question, Hypotheses and Data Design

Group variableSchool with MS as numerator group and GP as reference.
Binary outcomeG3 ≥ 10 versus G3 < 10.
Inferential targetRatio of the two observed pass probabilities.

Research Question

How does the observed probability of G3 ≥ 10 in MS compare with the observed probability in GP?

Null and Alternative Hypotheses

HypothesisStatistical statementMeaning
Null hypothesisH0: RR = 1The two group risks are equal.
Two-sided alternativeH1: RR ≠ 1The risks differ in either direction.
Directional alternativeH1: RR < 1The MS pass risk is lower than the GP risk; use only when prespecified.

Sampling Design Behind the Estimate

Relative risk requires meaningful group denominators. Each student belongs to one school group, and the event proportion is calculated within that group. The table resembles a cohort comparison because both pass and non-pass counts are available for each school.

Why the Comparison Direction Must Be Declared

MS/GP = 0.7563, while GP/MS = 1.3222. These values are reciprocals and describe the same data from opposite directions. The numerator and reference groups must be specified before interpretation. See null and alternative hypothesis and Type I and Type II error.

Design statement for the Methods section: “Relative risk was calculated as the probability of G3 ≥ 10 in MS divided by the corresponding probability in GP. Each student contributed one independent binary outcome.”

When to Use Relative Risk

Use Relative Risk When

  • The outcome is binary.
  • Two independent groups are compared.
  • Event probabilities can be estimated in both groups.
  • Complete event and non-event denominators are available.
  • The design is a cohort, randomized trial or suitable cross-sectional comparison.
  • A probability ratio is more interpretable than an odds ratio.
  • The comparison direction is prespecified.
  • Absolute and relative effects can be reported together.

Choose Another Method When

  • The study samples participants by outcome status, as in a typical case-control design.
  • The same people are measured twice or matched.
  • Observations are clustered and ordinary independent intervals are inadequate.
  • The outcome has more than two categories.
  • Time to event and censoring are central.
  • Covariate adjustment is required.
  • The group denominators do not represent risk sets.
  • The exposure or outcome ordering is ambiguous.

Simple Test-Selection Logic

Question 1Can group-specific risks be estimated?

If no, ordinary relative risk may not be appropriate.

Question 2Are groups independent?

If no, use a paired, clustered or repeated-measures method.

Question 3Is adjustment needed?

If yes, consider log-binomial, modified Poisson or another regression model.

Relative Risk Is Not Restricted to Rare Outcomes

Relative risk remains directly interpretable whether an outcome is rare or common, provided risks are estimable. The rare-outcome condition is relevant when an odds ratio is used as an approximation to relative risk, not when RR itself is calculated.

Relative Risk and Outcome Dichotomization

The worked analysis converts G3 to pass versus non-pass. This answers a threshold question but discards differences within the two bands. A complete project can report the binary risk comparison and separately analyse the original quantitative outcome.

Relative Risk Formula and Calculation

The relative risk calculation has three core stages: calculate the event risk in each group, divide the numerator-group risk by the reference-group risk, and construct uncertainty on the logarithmic scale.

Step 1: Define the Four 2 × 2 Counts

a = 158 MS events    and    b = 68 MS non-events
c = 391 GP events    and    d = 32 GP non-events
nMS = a+b = 226    and    nGP = c+d = 423

Step 2: Calculate the MS Risk

RiskMS = a/(a+b) = 158/226 = 0.6991150

Step 3: Calculate the GP Risk and Relative Risk

RiskGP = c/(c+d) = 391/423 = 0.9243499
RR = RiskMS/RiskGP = 0.6991150/0.9243499 = 0.7563316

RR = 0.7563 means the MS pass risk is 75.63% of the GP pass risk. Equivalently, the observed MS pass risk is 24.37% lower on a relative scale.

Step 4: Calculate the Standard Error of ln(RR)

The Katz interval is calculated on the logarithmic scale using SE[ln(RR)] = √[(1/a − 1/(a+b)) + (1/c − 1/(c+d))] = 0.0458019.

Step 5: Calculate the 95% Confidence Interval

95% CI = exp{{ln(RR) ± 1.96 × SE[ln(RR)]}}

Substituting the observed values gives a 95% confidence interval of [0.6913940, 0.8273683].

Step 6: Calculate the Absolute Risk Difference

Risk difference = 0.6991150 − 0.9243499 = −0.2252348

Step 7: Calculate the Relative Difference

Relative difference = 1 − 0.7563316 = 0.2436684

The two effect scales complement each other: the observed MS pass risk is 22.52 percentage points lower and 24.37% lower relative to GP.

How to Interpret Common Relative Risk Values

Relative riskBasic interpretationRequired wording safeguard
RR = 1Equal observed risksAn interval may still show uncertainty around equality.
RR < 1Numerator-group risk is lowerState the numerator and reference groups.
RR > 1Numerator-group risk is higherDo not convert association automatically into causation.
RR = 0No events in the numerator group when reference risk is positiveOrdinary log intervals may fail with zero cells.

Variables and Data Dictionary

VariableRoleCodingNCountsMeaning
schoolIndependent grouping variableMS = numerator group; GP = reference group649MS = 226; GP = 423Defines the two risk denominators.
G3Original quantitative outcomeFinal grade649Not analysed on its original scale hereSource used to create the pass threshold.
G3 ≥ 10Binary event1 = pass649549 eventsEvent probability compared across schools.
G3 < 10Binary non-event0 = non-pass649100 non-eventsCompletes each group denominator.

Observed 2 × 2 Table

SchoolG3 ≥ 10G3 < 10TotalPass risk
MS158682260.6991150
GP391324230.9243499
Total5491006490.8459168

2 × 2 Cell Labels Used in the Formula

CellCountFormula roleInterpretation
a158Numerator-group eventsMS students with G3 ≥ 10.
b68Numerator-group non-eventsMS students with G3 < 10.
c391Reference-group eventsGP students with G3 ≥ 10.
d32Reference-group non-eventsGP students with G3 < 10.
Coding rule: always identify the event, numerator group and reference group. Reversing MS and GP changes RR to its reciprocal and changes the wording of every relative interpretation.

Worked 2 × 2 Table and Complete Results

MS pass risk0.699115

158 of 226

GP pass risk0.924350

391 of 423

Relative risk0.756332

MS divided by GP

95% CI lower0.691394

Katz log interval

95% CI upper0.827368

Katz log interval

Risk difference−0.225235

MS minus GP

Primary Relative Risk Result

MeasureEstimate95% lower95% upperInterpretation
Relative risk, MS/GP0.75633160.69139400.8273683MS has a lower observed pass risk.

Effect and Comparison Estimates

MeasureEstimate95% lower95% upperInterpretation
MS pass risk0.6991150Observed probability of G3 ≥ 10 in MS.
GP pass risk0.9243499Observed probability of G3 ≥ 10 in GP.
Risk difference, MS − GP−0.2252348−0.2901235−0.1603462MS is 22.52 percentage points lower.
Relative difference, 1 − RR0.2436684MS risk is 24.37% lower relatively.
Odds ratio, MS/GP0.19016100.12016640.3009261Odds measure; not interchangeable with RR.

Statistical Interpretation

The 95% confidence interval for the MS-to-GP relative risk lies entirely below 1. Under the Katz log interval, the data support a lower MS pass risk than GP pass risk.

Practical Interpretation

The absolute difference is large in straightforward percentage-point terms: 69.91% versus 92.43%, a gap of 22.52 points. The relative statement, RR = 0.756, adds that the MS risk is about three quarters of the GP risk. Report both because effect size interpretation depends on scale.

Confidence-Interval Interpretation

The interval [0.691, 0.827] describes plausible relative-risk values under the selected method and assumptions. It does not incorporate possible clustering, confounding, threshold sensitivity or measurement error.

Result summary: MS students had a lower observed G3 ≥ 10 probability than GP students, RR = 0.756, 95% CI [0.691, 0.827], with an absolute difference of −22.52 percentage points.
AdvertisementGoogle AdSense placement reserved after the Results section

Relative Risk Versus Odds Ratio, Risk Difference and Related Methods

Relative risk

Ratio of two event probabilities; primary measure in this guide.

Odds ratio

Ratio of two event odds; can look more extreme for common outcomes.

Risk difference

Absolute percentage-point gap between the two event probabilities.

Chi-square or exact test

Tests association but does not replace an interpretable effect estimate.

Numerical Comparison for the Worked Table

Method or measureEstimate/statisticInterval or p-valueInterpretive role
Relative risk, MS/GP0.756331695% CI [0.6913940, 0.8273683]Primary proportional probability comparison.
Risk difference, MS − GP−0.225234895% CI [−0.2901235, −0.1603462]Absolute percentage-point comparison.
Odds ratio, MS/GP0.190161095% CI [0.1201664, 0.3009261]Odds comparison; much farther from 1.
Pearson chi-squareχ²(1) = 57.3314p < .001Global unadjusted association test.
Fisher exact testOR = 0.1902p < .001Conditional exact association comparison.
FeatureRelative riskOdds ratioRisk differenceAssociation test
ScaleRatioRatio of oddsAbsolute differenceTest statistic and p-value
Null value110Depends on reference distribution
Direct probability meaningYesNoYesNo effect magnitude by itself
Useful for common outcomesYesRequires careful interpretationYesYes for testing
Main limitationNeeds estimable risks and group denominatorsOften misread as riskDepends strongly on baseline riskCan encourage p-value-only reporting

Relative Risk Versus Odds Ratio

The search phrase relative risk vs odds ratio reflects a common interpretation problem. RR = 0.756 means the MS probability is 75.6% of the GP probability. OR = 0.190 means the MS odds are 19.0% of the GP odds. Because passing is common, the odds ratio is much farther from 1 and must not be described as a probability ratio.

Relative Risk Versus Absolute Risk

Absolute vs relative risk is not an either-or decision. The relative result is 24.37% lower, while the absolute result is 22.52 percentage points lower. Absolute effects often communicate practical magnitude more directly.

Should Every Method Be Reported?

No. Report relative risk and absolute risk difference as the main effect measures. A chi-square test or Fisher’s exact test can be included as supporting inference, but method shopping based on the smallest p-value should be avoided.

Relative Risk Calculator: Step-by-Step Workflow

A reliable relative risk calculator must identify the event, numerator group and reference group before dividing probabilities. It should also provide a confidence interval and retain the four underlying counts.

Calculator Inputs for the Worked Example

InputValueMeaning
Numerator-group events158MS students with G3 ≥ 10.
Numerator-group non-events68MS students with G3 < 10.
Reference-group events391GP students with G3 ≥ 10.
Reference-group non-events32GP students with G3 < 10.
Confidence level95%Uses z = 1.959964 for the Katz interval.
Comparison directionMS/GPDetermines the reported ratio and wording.

Calculator Step 1: Confirm the Group Totals

The calculator must return 226 for MS and 423 for GP. If it uses 549 and 100 as group totals, the outcome categories have been mistaken for the groups.

Calculator Step 2: Confirm the Two Risks

The expected group risks are 0.699115 for MS and 0.924350 for GP. A risk should never be calculated from the grand total when the research question concerns a within-group probability.

Calculator Step 3: Confirm the Relative Risk

MS divided by GP should equal 0.7563316. Reversing the group direction should return approximately 1.322171, the reciprocal.

Calculator Step 4: Inspect the Confidence Interval

The Katz log interval should be approximately [0.691394, 0.827368]. A calculator should identify the interval method and warn when zero cells make the ordinary log formula unstable.

Calculator Step 5: Interpret Absolute and Relative Effects

Read RR beside the −22.52-percentage-point risk difference. A calculator that returns only a ratio without the underlying risks is incomplete for applied reporting.

Expected target: MS risk = 0.699115, GP risk = 0.924350, RR = 0.756332 and 95% CI [0.691394, 0.827368].

Ten Unique Python and R Relative Risk Chart Interpretations

The supplied files contain ten unique chart URLs. The observed-table figure is shared by Python and R and is displayed once, while every other Python-only and R-only chart is displayed and interpreted separately.

Cross-software rule: Python and R must reproduce the same four counts and core estimates. Their unique visualizations are retained, but the identical observed-table image is not duplicated.

Chart 1: Relative Risk Observed 2 × 2 TablePython + R

Relative Risk observed table comparing MS and GP pass outcomes
Observed counts for school group by G3 pass outcome.
Pattern

MS contains 158 passes and 68 non-passes, while GP contains 391 passes and 32 non-passes.

Key Values

MS: 158/226 pass. GP: 391/423 pass. Total N = 649.

Interpretation

The table supplies the four counts used in every risk, relative risk, confidence interval and comparison calculation.

Why It Matters

Relative risk uses group-specific denominators. Comparing only 158 with 391 would confound risk with unequal group size.

Next step: Confirm the event category and group order before calculating either risk.

Chart 2: Python Group Risk ComparisonPython

Python Relative Risk chart comparing MS and GP pass risks
Python comparison of the observed pass probabilities in the two school groups.
Pattern

The GP pass-risk bar is substantially higher than the MS pass-risk bar.

Key Values

MS risk: 0.6991 or 69.91%. GP risk: 0.9243 or 92.43%.

Absolute Gap

MS minus GP equals −0.2252, a difference of −22.52 percentage points.

Python Meaning

The risks are calculated from each NumPy or pandas row total, not from the grand total of 649.

Next step: Divide the two risks in the prespecified direction to obtain the risk ratio.

Chart 3: Python Relative Risk with 95% Confidence IntervalPython

Python Relative Risk estimate with 95 percent confidence interval
Relative risk and Katz log-scale confidence interval against the null value of 1.
Estimate

RR = 0.7563 when MS is compared with GP.

Confidence Interval

The 95% Katz interval is [0.6914, 0.8274].

Interpretation

The entire interval lies below 1, supporting a lower observed pass risk in MS than GP.

Precision

The interval is relatively narrow because the table includes 549 passes and 100 non-passes across 649 observations.

Next step: State the numerator and reference group every time the relative risk is reported.

Chart 4: Python Outcome Counts by GroupPython

Python Relative Risk outcome count chart for pass and non-pass categories
Pass and non-pass counts displayed separately within MS and GP.
Pass Counts

There are 158 MS passes and 391 GP passes.

Non-Pass Counts

There are 68 MS non-passes and 32 GP non-passes.

Interpretation

GP has more passes despite also having the larger sample; the decisive comparison is the within-group pass proportion.

Why It Matters

Displaying both event and non-event counts prevents a risk ratio from being detached from the underlying data.

Next step: Report the four counts beside the relative risk in formal analysis.

Chart 5: Python Relative Risk Result SummaryPython

Python Relative Risk summary chart with risks estimate and confidence interval
Python summary of group risks, relative risk, interval and absolute difference.
Primary Result

RR = 0.7563 with 95% CI [0.6914, 0.8274].

Risk Values

MS = 69.91%; GP = 92.43%.

Absolute Difference

MS minus GP = −22.52 percentage points.

Decision

The confidence interval excludes 1, so equal observed risks are not supported by the log-RR interval.

Next step: Separate statistical evidence from causal or policy conclusions.

Chart 6: R School-Specific Pass RisksR

R Relative Risk school-specific pass-risk chart
R display of school-specific pass risks generated from a labelled 2 × 2 matrix.
R Profile

The R output reproduces MS risk = 0.6991 and GP risk = 0.9243.

Matrix Orientation

Rows identify schools and columns identify pass versus non-pass outcomes.

Interpretation

MS has about 75.6% of the GP pass risk under the selected comparison direction.

R Check

Use explicit dimnames so the numerator, denominator and event category remain visible in the code and output.

Next step: Verify that the R matrix is not transposed before extracting row risks.

Chart 7: R Relative Risk ComponentsR

R Relative Risk component chart showing group risks and log calculations
R decomposition of the two risks and their ratio.
Numerator

MS risk = 158/(158 + 68) = 0.699115.

Denominator

GP risk = 391/(391 + 32) = 0.924350.

Log Component

ln(RR) = −0.279275 and SE[ln(RR)] = 0.045802.

Interpretation

A negative log relative risk corresponds to RR below 1 and a lower numerator-group risk.

Next step: Use the log scale for interval construction, then exponentiate back to the risk-ratio scale.

Chart 8: R Relative Risk Confidence IntervalR

R Relative Risk confidence interval chart
R relative risk estimate and 95% confidence interval relative to the null line.
Point Estimate

The R estimate is 0.7563316.

Lower Limit

The lower confidence limit is 0.6913940.

Upper Limit

The upper confidence limit is 0.8273683.

Statistical Meaning

Because both limits are below 1, the interval indicates a lower MS pass risk under the stated comparison.

Next step: Report the interval method as a Katz log confidence interval.

Chart 9: R Absolute and Relative Risk ComparisonR

R chart comparing absolute risk difference and relative risk
R comparison of absolute and relative descriptions of the same group contrast.
Absolute Scale

The MS pass risk is 22.52 percentage points lower than the GP pass risk.

Relative Scale

RR = 0.7563, corresponding to a 24.37% lower relative pass risk.

Interpretation

Absolute and relative summaries answer different questions and should be reported together.

Caution

The phrase “risk reduction” can imply intervention causality; in this observational school comparison, use descriptive wording.

Next step: Lead with the absolute percentage-point difference when practical meaning is central.

Chart 10: R Relative Risk Result SummaryR

R Relative Risk result summary chart
R summary of counts, risks, relative risk and confidence interval.
Counts

MS: 158 passes and 68 non-passes; GP: 391 passes and 32 non-passes.

Estimate

Relative risk = 0.7563.

Interval

95% CI [0.6914, 0.8274].

Conclusion

The observed MS pass probability is lower, but the table alone does not establish why the school profiles differ.

Next step: Keep the noncausal limitation beside the final R result.
AdvertisementGoogle AdSense placement reserved after the Python and R charts

Relative Risk in Python, R, SPSS, Stata and Excel

Relative Risk in Python

Python can calculate relative risk directly from a NumPy array or pandas table. SciPy supports comparison tests, while the RR and Katz interval remain transparent formula calculations.

  • Keep rows as groups and columns as event/non-event.
  • Calculate each row risk separately.
  • Use the log scale for the interval.
  • Report the four counts and group labels.
  • Calculate absolute risk difference beside RR.

See categorical data analysis in Python.

Relative Risk in R

R can calculate RR from a labelled matrix or use epidemiology packages. Explicit manual formulas make the direction and denominators easy to audit.

  • Assign dimnames to rows and columns.
  • Extract risks from the correct rows.
  • Build the Katz interval on ln(RR).
  • Retain risk difference and relative difference.
  • Check package orientation before reporting.

See categorical data analysis in R.

Relative Risk in SPSS

SPSS CROSSTABS can produce row percentages, chi-square output and risk estimates for a 2 × 2 table.

  • Verify row and column category ordering.
  • Request RISK and CHISQ statistics.
  • Read the displayed risk estimate label carefully.
  • Do not assume the first ratio uses the desired event.
  • Export the crosstab with counts and row percentages.

See categorical data analysis in SPSS.

Relative Risk in Stata

Stata’s cohort-study command can calculate risk ratios and related measures once exposure and event variables are coded as binary.

  • Code GP as the reference exposure category.
  • Code pass as the event.
  • Use cs for cohort-style measures.
  • Use tabulation for visible row risks.
  • Confirm that the reported direction is MS versus GP.

Relative Risk in Excel

Excel can reproduce every primary calculation with visible formulas and is useful for teaching, audit and calculator-style work.

  • Enter the four counts in a clearly labelled table.
  • Calculate group totals with SUM.
  • Calculate each risk from its row denominator.
  • Use LN and EXP for confidence limits.
  • Add checks for zero event cells.

Expandable Code for Relative Risk

Python: relative risk and Katz confidence interval
import math
from scipy.stats import norm

a = 158  # MS pass
b = 68   # MS non-pass
c = 391  # GP pass
d = 32   # GP non-pass

risk_ms = a / (a + b)
risk_gp = c / (c + d)
relative_risk = risk_ms / risk_gp

se_log_rr = math.sqrt(
    (1 / a) - (1 / (a + b)) +
    (1 / c) - (1 / (c + d))
)
z_critical = norm.ppf(0.975)

lower = math.exp(
    math.log(relative_risk) - z_critical * se_log_rr
)
upper = math.exp(
    math.log(relative_risk) + z_critical * se_log_rr
)

print(risk_ms)
print(risk_gp)
print(relative_risk)
print(lower, upper)
Python: absolute effects and comparison tests
import math
from scipy.stats import chi2_contingency, fisher_exact

table = [[158, 68],
         [391, 32]]

risk_ms = 158 / 226
risk_gp = 391 / 423

risk_difference = risk_ms - risk_gp
relative_risk_reduction = 1 - (risk_ms / risk_gp)
odds_ratio = (158 * 32) / (68 * 391)

chi2, p_chi, df, expected = chi2_contingency(
    table,
    correction=False
)
fisher_or, p_fisher = fisher_exact(
    table,
    alternative="two-sided"
)

print(risk_difference)
print(relative_risk_reduction)
print(odds_ratio)
print(chi2, p_chi)
print(fisher_or, p_fisher)
R: labelled 2 × 2 relative risk workflow
observed <- matrix(
  c(158, 68,
    391, 32),
  nrow = 2,
  byrow = TRUE,
  dimnames = list(
    school = c("MS", "GP"),
    outcome = c("Pass", "Non-pass")
  )
)

risk_ms <- observed["MS", "Pass"] / sum(observed["MS", ])
risk_gp <- observed["GP", "Pass"] / sum(observed["GP", ])
rr <- risk_ms / risk_gp

se_log_rr <- sqrt(
  1 / observed["MS", "Pass"] -
  1 / sum(observed["MS", ]) +
  1 / observed["GP", "Pass"] -
  1 / sum(observed["GP", ])
)

ci <- exp(log(rr) + c(-1, 1) * qnorm(.975) * se_log_rr)

risk_difference <- risk_ms - risk_gp
relative_risk_reduction <- 1 - rr

list(
  risk_ms = risk_ms,
  risk_gp = risk_gp,
  relative_risk = rr,
  confidence_interval = ci,
  risk_difference = risk_difference,
  relative_risk_reduction = relative_risk_reduction
)
SPSS: crosstab and risk estimates
* Create a binary pass outcome: 1 = G3 >= 10; 0 = G3 < 10.
COMPUTE pass = (G3 >= 10).
VALUE LABELS pass 0 'Non-pass' 1 'Pass'.

* Ensure school categories are clearly labelled before analysis.
CROSSTABS
  /TABLES = school BY pass
  /FORMAT = AVALUE TABLES
  /STATISTICS = CHISQ RISK
  /CELLS = COUNT ROW
  /COUNT ROUND CELL.

* Read the risk estimate only after checking the displayed
* row, column, event, and reference-category order.
Stata: cohort-style risk ratio
generate byte pass = G3 >= 10
label define pass_lbl 0 "Non-pass" 1 "Pass"
label values pass pass_lbl

generate byte ms_exposure = school == "MS"
label define exposure_lbl 0 "GP reference" 1 "MS exposed"
label values ms_exposure exposure_lbl

cs pass ms_exposure

tabulate ms_exposure pass, row chi2 exact
Excel: worksheet formulas
Suggested input cells

B3 = 158    MS pass
B4 = 68     MS non-pass
C3 = 391    GP pass
C4 = 32     GP non-pass

MS risk:
=B3/SUM(B3:B4)

GP risk:
=C3/SUM(C3:C4)

Relative risk:
=(B3/SUM(B3:B4))/(C3/SUM(C3:C4))

SE of ln(RR):
=SQRT(1/B3-1/SUM(B3:B4)+1/C3-1/SUM(C3:C4))

95% CI lower:
=EXP(LN(Relative_Risk_Cell)-NORM.S.INV(0.975)*SE_Log_RR_Cell)

95% CI upper:
=EXP(LN(Relative_Risk_Cell)+NORM.S.INV(0.975)*SE_Log_RR_Cell)

Risk difference, MS minus GP:
=B3/SUM(B3:B4)-C3/SUM(C3:C4)

Relative risk reduction:
=1-Relative_Risk_Cell

Assumptions, Limitations and Advanced Interpretation

Core Assumptions

Data Conditions

  • Two independent groups
  • Binary event definition
  • Complete group denominators
  • One record per observation
  • Correct group and event coding
  • Meaningful risk-set interpretation

Reporting Conditions

  • State numerator and reference groups
  • Report both group risks
  • Name the confidence interval method
  • Report an absolute effect
  • Avoid odds/risk confusion
  • Avoid unsupported causal language
Independent observations

Each student should contribute one record to one school row and one pass-outcome column. Repeated records, matched observations or unresolved duplicates violate the ordinary two-group risk calculation.

Binary and mutually exclusive outcome

The event must be clearly defined as G3 ≥ 10 and the non-event as G3 < 10. Every observation must belong to exactly one of those categories.

Group denominators must represent the risk sets

The denominators 226 and 423 must be the complete analysed MS and GP groups. Excluding non-events after group formation would distort the risks.

Relative risk needs an interpretable sampling design

Risk ratios are most natural in cohort, trial or cross-sectional settings where group-specific event proportions can be estimated. Case-control sampling generally does not estimate population risks directly.

Reference-group choice changes the numerical ratio

MS/GP = 0.7563, while GP/MS = 1.3222. Both encode the same contrast, but the wording and confidence interval must match the chosen direction.

A confidence interval is not an assumption check

An interval excluding 1 describes sampling uncertainty under the model; it does not verify independence, data quality, absence of confounding or correct event coding.

Common outcomes make odds ratios look more extreme

The pass outcome is common in both groups. The odds ratio is about 0.190, much farther from 1 than RR = 0.756, so odds must not be described as risks.

Zero cells require special handling

The ordinary Katz standard error contains reciprocal cell counts. A zero event count can make the log estimate or interval undefined, requiring a justified correction or exact/model-based procedure.

Clustering can narrow naive intervals

Students may share classrooms, teachers or local conditions. If clustering is material, a simple 2 × 2 interval can understate uncertainty and a multilevel or robust approach may be needed.

Confounding remains possible

School and pass outcome may both be related to prior attainment, study time, absences or other variables. Relative risk from this table is unadjusted.

Effect modification may hide behind one overall ratio

A single overall risk ratio can mask different ratios across gender, prior achievement or another stratum. Stratified analysis or an interaction model can examine heterogeneity.

Causal language requires a causal design

The observed school comparison is descriptive. Relative risk does not by itself show that changing school would change a student's pass probability.

APA Reporting for Relative Risk

APA-style relative risk reporting should make the event, group direction, four counts, both risks, RR, confidence interval, absolute difference and causal limitations visible. The estimate is not interpretable when the numerator and reference groups are omitted.

What to Include in an APA-Style Report

Method Information

  • Two independent groups
  • Binary event definition
  • Numerator and reference groups
  • Confidence level and method
  • Software or calculation procedure
  • Observational or experimental design

Results Information

  • Four observed counts
  • Both group risks
  • Relative risk and interval
  • Absolute risk difference
  • Relative difference where useful
  • Noncausal practical interpretation

APA-Style Methods Sentence

“Relative risk was calculated to compare the probability of G3 ≥ 10 in MS with the corresponding probability in GP. MS was treated as the numerator group and GP as the reference group. A 95% Katz log confidence interval was calculated for the risk ratio.”

Full APA-Style Results Example

“The G3 ≥ 10 outcome occurred for 158 of 226 MS students (69.91%) and 391 of 423 GP students (92.43%). The MS-to-GP relative risk was 0.756, 95% CI [0.691, 0.827]. Thus, the observed MS pass risk was 24.37% lower on a relative scale and 22.52 percentage points lower on an absolute scale. These unadjusted observational results do not establish a causal effect of school.”

Concise APA Results Sentence

“The probability of G3 ≥ 10 was lower in MS (69.91%) than GP (92.43%), RR = 0.756, 95% CI [0.691, 0.827], an absolute difference of −22.52 percentage points.”

Includes 1

Nonsignificant Relative Risk

Sample

The event occurred in a/n₁ of Group 1 and c/n₀ of Group 0.

Estimate

The relative risk was RR, 95% CI [lower, upper].

Meaning

Because the interval included 1, the analysis did not provide sufficient evidence of unequal risks; it did not prove exact equality.

Below 1

Lower Numerator-Group Risk

Sample

The event risk was risk₁ in Group 1 and risk₀ in the reference group.

Estimate

The relative risk was RR below 1, 95% CI [lower, upper].

Meaning

The numerator group had a (1 − RR) × 100% lower observed event risk. The statement describes association unless the design supports causation.

Above 1

Higher Numerator-Group Risk

Sample

The event occurred in Group 1 count/total and reference count/total.

Estimate

The relative risk was RR above 1, 95% CI [lower, upper].

Meaning

The numerator group had a (RR − 1) × 100% higher observed event risk.

These relative risk APA templates separate the sample description, risk-ratio result and practical interpretation. Replace every highlighted field, preserve the comparison direction and avoid causal wording unless justified by the design.

Reusable APA Templates for Relative Risk

APA Comparison with an Odds Ratio

“Relative risk was selected as the primary effect because group-specific event probabilities were directly estimable. The odds ratio was reported only as a secondary comparison and was not interpreted as a probability ratio.”

APA-Style Table for the Main Results

Group or statisticValue95% CI
MS G3 ≥ 10, n/N (%)158/226 (69.91%)
GP G3 ≥ 10, n/N (%)391/423 (92.43%)
Relative risk, MS/GP0.756[0.691, 0.827]
Risk difference, MS − GP−0.225[−0.290, −0.160]
Relative difference, 1 − RR0.244
Odds ratio, MS/GP0.190[0.120, 0.301]

Suggested table note: “RR compares MS with GP. Confidence limits for RR use the Katz log method. The risk-difference interval uses a large-sample Wald method. Estimates are unadjusted.”

APA Rounding Rules

  • Report RR and confidence limits to two or three decimals.
  • Report both group percentages with one or two decimals.
  • Use consistent precision across interval limits.
  • Do not report a ratio without naming its direction.
  • Use p < .001 only when a supporting test is actually below .001.
  • Do not report p = .000.

APA Interpretation Words to Use

AvoidUse insteadReason
“MS caused fewer passes.”“MS had a lower observed pass risk.”The table is observational and unadjusted.
“Students were 75.6% less likely.”“MS risk was 75.6% of GP risk, or 24.4% lower.”RR itself is the retained proportion, not the percentage reduction.
“The odds ratio was the relative risk.”“RR was 0.756; OR was 0.190.”Odds and probability are different scales.
“The groups were different because the interval was narrow.”“The interval excluded 1 and was relatively precise.”Precision and effect magnitude are separate.
“Relative risk reduction proves benefit.”“The observed numerator-group risk was lower.”Benefit requires a meaningful intervention and causal design.
Best final APA report for this analysis: report 69.91% versus 92.43%, RR = 0.756, 95% CI [0.691, 0.827], the −22.52-percentage-point absolute difference and an explicit statement that the school comparison is unadjusted and noncausal.

Common Relative Risk Mistakes and How to Correct Them

Common mistakeWhy it is a problemCorrect approach
Dividing event counts directly158/391 ignores unequal group denominators.Divide each event count by its own group total first.
Failing to name the reference groupThe ratio and interpretation become ambiguous.State MS/GP or GP/MS explicitly.
Calling RR = 0.756 a 75.6% reductionThe reduction is 1 − RR = 24.4%.Say the risk is 75.6% as large or 24.4% lower.
Using odds and risk interchangeablyThe outcome is common and OR = 0.190 differs sharply from RR.Use probability language for RR and odds language for OR.
Ignoring absolute riskA ratio alone can obscure the 22.52-point gap.Report the risk difference beside RR.
Using causal “risk reduction” language automaticallyThe school comparison is observational.Use descriptive association wording.
Applying the log formula with a zero cellReciprocal terms become undefined.Use a justified correction or another interval method.
Using relative risk in an outcome-sampled case-control designPopulation risks are not directly estimated.Use an odds ratio or a design-appropriate model.
Ignoring clustering or confoundingThe unadjusted interval may overstate precision or misattribute association.Use robust, stratified or regression methods when needed.
Reporting only a confidence-interval decisionThe reader cannot see counts, risks or practical magnitude.Report the complete effect summary.
Best practice: show the four counts, both group risks, RR direction, confidence interval, absolute risk difference and design limitation in the same results section.

Relative Risk Reports and Worked Excel Download

Download use: the PDFs provide software-specific output, while the Excel workbook exposes the formulas and verification values for teaching, audit and calculator checks.

Frequently Asked Questions About Relative Risk

The questions below address the relative risk formula, interpretation, calculator checks, confidence intervals, software, odds-ratio comparisons and reporting.

What is relative risk?

Relative risk, also called the risk ratio, is the event probability in one group divided by the event probability in a reference group.

Is relative risk the same as risk ratio?

Yes. In epidemiology and applied statistics, relative risk and risk ratio usually refer to the same quantity.

What is the relative risk formula?

RR = [a/(a+b)]/[c/(c+d)], where a and b form the numerator group and c and d form the reference group.

What is the relative risk in this example?

The MS-to-GP relative risk is 0.7563316.

How do I interpret RR = 0.756?

The observed MS pass risk is about 75.6% of the GP pass risk, or about 24.4% lower on a relative scale.

What are the group risks?

MS pass risk is 158/226 = 69.91%; GP pass risk is 391/423 = 92.43%.

What is the 95% confidence interval?

The Katz log-scale 95% confidence interval is [0.6914, 0.8274].

What is the null value for relative risk?

The null value is 1 because RR = 1 indicates equal risks in the two groups.

Does the interval exclude 1?

Yes. Both limits are below 1 under the MS-to-GP comparison.

What is the absolute risk difference?

MS minus GP is −0.2252, or −22.52 percentage points.

What is relative risk reduction here?

One minus RR equals 0.2437, or 24.37%; use descriptive wording because this is not a randomized intervention.

Can relative risk be greater than 1?

Yes. RR greater than 1 means the numerator group has a higher event risk than the reference group.

Can relative risk equal 0?

RR can be 0 when the numerator group has zero events and the reference risk is positive, although interval estimation then needs special handling.

Can relative risk be negative?

No. Risks are nonnegative, so a valid relative risk cannot be negative.

Why does group order matter?

Reversing the groups takes the reciprocal: MS/GP = 0.7563, while GP/MS is about 1.3222.

Is relative risk the same as odds ratio?

No. Relative risk compares probabilities; an odds ratio compares odds. They can differ greatly when the outcome is common.

What is the odds ratio in this table?

The MS-to-GP odds ratio is approximately 0.1902, which should not be described as a 0.1902 risk ratio.

When should I use relative risk?

Use it when group-specific event probabilities can be estimated from an appropriate cohort, trial or cross-sectional design.

Can I use relative risk in a case-control study?

Ordinary case-control sampling fixes outcome counts and generally does not estimate population risk directly, so the odds ratio is usually used.

Does relative risk prove causation?

No. Causal interpretation depends on design, exchangeability, measurement and control of confounding.

How do I calculate relative risk in Python?

Calculate each row risk from its own denominator, divide the numerator-group risk by the reference risk, and use the log scale for the Katz interval.

How do I calculate relative risk in R?

Use a labelled 2 × 2 matrix, calculate row risks, divide them in the intended direction and exponentiate the log-scale interval limits.

How do I calculate relative risk in SPSS?

Use CROSSTABS with RISK statistics, then verify which displayed category and group define the reported risk estimate.

Can Excel calculate relative risk?

Yes. Excel can calculate risks, RR, the log standard error and Katz confidence limits with transparent worksheet formulas.

What should an APA report include?

Report the four counts, both risks, comparison direction, RR, confidence interval, absolute difference and a noncausal interpretation.

How should RR = 0.7563316 be rounded?

RR = 0.756 or RR = 0.76 is usually sufficient in prose, with consistent precision for the confidence interval.

What if a cell count is zero?

The ordinary log formula may fail. Use a justified continuity correction, exact method or appropriate regression model.

What if observations are clustered?

Use a method that accounts for clustering, such as robust standard errors, generalized estimating equations or a multilevel model.

Should I report absolute and relative risk?

Yes. The percentage-point difference and relative ratio provide complementary practical and proportional interpretations.

What is the main conclusion?

MS students had a lower observed pass risk than GP students: RR = 0.756, 95% CI [0.691, 0.827], with an absolute difference of −22.52 percentage points.

Relative Risk Conclusion

Relative risk is a direct and interpretable measure for comparing event probabilities in two groups when both group denominators are available. It should always be presented with the event definition, numerator and reference groups, four observed counts and both underlying risks.

In the worked example, 158 of 226 MS students and 391 of 423 GP students reached G3 ≥ 10. The MS-to-GP relative risk was 0.756, 95% CI [0.691, 0.827]. The observed MS pass risk was therefore about 24.4% lower on a relative scale and 22.52 percentage points lower on an absolute scale.

The association is unadjusted and does not establish a causal school effect. A strong report combines the relative and absolute effects, distinguishes risk from odds, considers clustering and confounding, and uses regression or stratified methods when adjustment is required.

Final reporting line: The probability of G3 ≥ 10 was lower in MS than GP, RR = 0.756, 95% CI [0.691, 0.827], with an absolute difference of −22.52 percentage points.
AdvertisementGoogle AdSense bottom placement reserved here

Back to top

Need help applying this to your own data?

Salar Cafe can help interpret output, clean datasets, review assumptions, build dashboards and explain statistical results ethically.

Need help interpreting your data analysis results?

Contact Salar Cafe
Engr. Muhammad Yar Saqib author profile photo

Engr. Muhammad Yar Saqib

WhatsApp Get Data Analysis Help