Atlas
statminds
Categorical GLM (Z-Score Proportions Model)The underlying model family class (e.g. GLM, linear model, categorical matrix, log-linear).Parametric ReferenceStatistical methods that assume a specific probability distribution family (typically normal).12-stage workflow

Two Proportions Z-Test

The engine for Proportional Divergence. This model audits the gap between two independent percentages, reveal the definitive shift in success rates or occurrence frequencies across groups.

Model familyCategorical GLM (Z-Score Proportions Model)
Hypothesistwo-tailed (default) or one-tailed
AliasesTwo-Sample Proportion Test · Proportion Z-Strike · Binary Frequency Comparison
G1
Divergence Audit
Determine if the success rates of two groups are significantly different from each other.
G2
Categorical Profile Discovery
Identify the predictors that drive a group to have a higher 'Proportional Yield' than another.
G3
Precision Gap Mapping
Quantify the 'Clinical Spread' between groups using standardized difference metrics.
Visual Overview Dashboard
1

What is it?

Two Proportions Z-Test is a specialized statistical test used to evaluate proportions, multivariate mean vectors, or clinical equivalence margins.

The engine for Proportional Divergence. This model audits the gap between two independent percentages, reveal the definitive shift in success rates or occurrence frequencies across groups.

2

Goals & Indications

  • Divergence Audit: Determine if the success rates of two groups are significantly different from each other.
  • Categorical Profile Discovery: Identify the predictors that drive a group to have a higher 'Proportional Yield' than another.
  • Precision Gap Mapping: Quantify the 'Clinical Spread' between groups using standardized difference metrics.
3

Core Idea Diagram

p₁p₂
4

Claims tested

H₀: H₀: p₁ = p₂ (the population proportions are equal in both groups)
Hₐ: Hₐ: p₁ ≠ p₂ (two-tailed), or p₁ > p₂ (one-tailed), or p₁ < p₂ (one-tailed)
5

How it works

  1. State null hypothesis of equal proportions: p_1 = p_2.
  2. Calculate pooled sample proportion based on total success counts.
  3. Compute standard error of proportions difference.
  4. Calculate Z statistic and evaluate against normal distribution bounds.
6

Assumptions

Outcome is binary: Two mutually exclusive categories (success/failure)
Independence of observations within and between groups: No clustering, pairing, or repeated measures
Adequate sample size: npq ≥ 5 in each group: Sufficient expected counts for z-approximation
7

Important Note

The two-proportion z-test and chi-square test are mathematically equivalent for 2×2 contingency tables (χ² = z²). Use z-test for directional hypotheses and confidence intervals; use chi-square for omnibus association test.

8

Worked Example

GroupSuccessesSample SizeProportionZ Statp-value
Treatment451000.4502.180.029
Control301000.300
Interactive Sandbox

Two Proportions Z-Test Laboratory

Slide proportions $p_1$ and $p_2$. Observe how the pooled standard error and Z-statistic update dynamically.

Proportion 1 (p₁)0.45
Proportion 2 (p₂)0.30
Size n₁100
Size n₂100
Test Outputs
Successes 1 (rounded): 45 / 100
Successes 2 (rounded): 30 / 100
Z Statistic: 2.1909
p-value: 0.02846Significant
Normal distribution critical regions (Z = ±1.96 in red, test Z in blue)
-1.96+1.96Z = 2.19
The 12-Stage Precision Workflow
01Proportional Parity
Hypotheses
We test the null of 'Zero Gap' (p₁ = p₂) against the discovery of a non-zero shift in group frequencies.
02Independence Mandate
Assumptions
The ultimate requirement: each participant belongs to exactly one group and contributes exactly one binary outcome.
03Success-Failure Rule
Diagnostics
Ensuring each group has at least 5-10 'Successes' and 'Failures'—the mathematical basis for the Z-approximation to hold.
04focus
Comparing the 'Success Rate' (Full Recovery) of FlowMotion vs. Yoga at a multi-site clinic audit.
05Fisher-Exact Pivot
Alternatives
Knowing when to switch to Fisher's Exact Test if the group counts are dangerously small and the Z-math loses stability.
06The Z-Strike
Significance
Calculating the T-equivalent for proportions—reporting the Z-statistic and its corresponding p-value for the gap audit.
07Risk Difference
Effect Size
Interpreting the 'Absolute Difference' (p₁ - p₂)—the actual percentage-point gain attributable to the intervention.
08Precision Target
Sample Size
Determining the N per group required to detect small percentage shifts with mathematical authority.
09The Yield Narrative
Reporting
Reporting percentages, Z-score, and p-value: 'FlowMotion yielded a 20% higher success rate than control, Z = X.XX, p = .XXX.'
10prop.test Logic
Software
Executing 'prop.test(correct = TRUE/FALSE)'—ensuring the Yates correction is applied if cell counts are moderate.
11focus
The fatal error of reporting percentage changes without the denominator—which hides the true precision of the discovery.
12focus
Tracing the logic back to the Normal Approximation of the binomial distribution and the formalization of group rate comparisons.
01Hypothesis test logic

Hypotheses

Pragmatic null and alternative hypotheses defined in mathematical notation.

A hypothesis is a question sharpened to a point. Ambiguity is the enemy of inference.
Logic Core
Null · H₀

H₀: p₁ = p₂ (the population proportions are equal in both groups)

Alternative · Hₐ

Hₐ: p₁ ≠ p₂ (two-tailed), or p₁ > p₂ (one-tailed), or p₁ < p₂ (one-tailed)

Why it matters two-tailed (default) or one-tailed

The two-proportion z-test and chi-square test are mathematically equivalent for 2×2 contingency tables (χ² = z²). Use z-test for directional hypotheses and confidence intervals; use chi-square for omnibus association test.

02Model diagnostics

Assumptions

The core mathematical criteria needed to ensure that statistical testing remains unbiased and valid.

Build your analysis on rock, not sand. Verify the mathematical foundation before building the model.
Integrity Shield
5
Assumptions
3
Critical / High Severity
How to check
Quick
Verify variable has exactly 2 levels (e.g., yes/no, recovered/not recovered, event/no event); inspect frequency table
Rigorous
Check variable type is factor/categorical with 2 levels; verify no missing third category; ensure categories are mutually exclusive and exhaustive
If violated
If > 2 categories → collapse into binary (if meaningful) or use chi-square test for r×2 table or multinomial logistic regression. If ordinal outcome → use Mann-Whitney U test or ordinal regression. If continuous outcome → use independent t-test or linear regression
independent t test
How to check
Quick
Design review; verify each subject appears only once; check for matching, clustering (family, site), or repeated measures
Rigorous
Check for duplicate IDs; verify random sampling/assignment; inspect ICC if clustering suspected; confirm no paired/matched design
If violated
If paired/matched data (same subjects or matched pairs) → use McNemar's test for paired proportions. If clustered data (e.g., patients in hospitals) → use GEE with binomial family and exchangeable correlation, or mixed-effects logistic regression with random intercepts. If repeated measures → use GEE or mixed-effects models
mcnemargee
How to check
Quick
Calculate n₁p₁(1-p₁) and n₂p₂(1-p₂) for each group; both should be ≥ 5. Alternatively, check n₁p̂, n₁(1-p̂), n₂p̂, n₂(1-p̂) where p̂ is pooled proportion
Rigorous
Use exact binomial test or Fisher's exact test p-value comparison to assess normal approximation accuracy; check continuity-corrected vs. uncorrected z-test agreement
If violated
If expected counts < 5 in any cell: (1) Use Fisher's exact test (provides exact p-value without normal approximation); (2) Use Barnard's exact test (more powerful than Fisher for 2×2 tables); (3) Use mid-p correction; (4) Pool data if scientifically justified to increase counts; (5) Use Bayesian methods with informative priors
How to check
Quick
Design review; verify sampling method (simple random, stratified random); confirm groups represent different populations (e.g., treatment vs. control, exposed vs. unexposed)
Rigorous
Document sampling frame; verify randomization procedures in RCTs; check for selection bias or confounding; assess balance on baseline covariates
If violated
If samples not independent → see assumption 2. If samples not random → acknowledge selection bias as limitation; use propensity score methods or inverse probability weighting to adjust for measured confounders; interpret results as associations, not causal effects. If populations overlap → redefine groups to be mutually exclusive
propensity score matching
How to check
Quick
Calculate ratio n₁/n₂; values between 0.5 and 2.0 are generally acceptable; extreme imbalance (e.g., 10:1) can reduce power
Rigorous
Conduct power analysis to verify adequate power given actual allocation ratio; compare statistical efficiency of unbalanced vs. balanced design
If violated
Unbalanced designs are valid but less efficient. Fixes: (1) Use weighted z-test or chi-square (automatically accounts for unequal n); (2) Report actual power based on observed allocation; (3) In future studies, aim for balanced allocation (1:1 ratio) to maximize power. Note: Test remains valid with any n₁, n₂ as long as other assumptions hold
03Residual Forensics

Diagnostics

Checking residual plots and indices to examine model deviations and ensure standard error integrity.

Trust, but verify. The outliers often hold more truth than the averages.
System Health
Essential checks
  1. Check expected counts: n₁p̂, n₁(1-p̂), n₂p̂, n₂(1-p̂) all ≥ 5 (where p̂ is pooled proportion)
  2. Verify independence: check study design for clustering, pairing, or repeated measures
  3. Inspect 2×2 contingency table for data accuracy and cell counts
Recommended checks
  1. Compare Fisher's exact test p-value to z-test p-value (should be similar if n large)
  2. Calculate and report effect sizes: risk difference, relative risk, odds ratio
  3. Visualize proportions with bar chart or forest plot with 95% CIs
  4. Assess clinical/practical significance alongside statistical significance
04Live Instances

Applied Minds

Review concrete study examples, data layout guidelines, and copy executable syntax scripts.

Theory is the map. Practice is the terrain. Simulation bridges the gap.
Applied Wisdom
Example 01

Smoking Cessation RCT (Nicotine Patch vs. Placebo)

Research question: Does nicotine patch improve smoking cessation rates compared to placebo? Design: Double-blind RCT with 2 groups (Nicotine Patch n=120, Placebo n=120). Outcome: Binary smoking status at 6 months (Quit = success, Smoking = failure). Primary analysis: Two-proportion z-test to compare quit rates.

DesignDouble-blind RCT
GroupsNicotine Patch · Placebo
Total n240
Outcome ScaleBinary: Quit (success) vs. Smoking (failure)
# Two-proportion z-test: Nicotine patch vs. placebo for smoking cessation
# Based on realistic effect sizes from Cochrane meta-analysis

library(tidyverse)
library(epitools)   # For riskratio, oddsratio
library(DescTools)  # For confidence intervals

set.seed(2025)

# Simulate realistic data (or load: data <- read.csv("smoking_cessation.csv"))
# Patch: 35% quit rate; Placebo: 20% quit rate (RR = 1.75)
n_patch <- 120
n_placebo <- 120
p_patch <- 0.35
p_placebo <- 0.20

data <- data.frame(
  group = factor(c(rep("Patch", n_patch), rep("Placebo", n_placebo)),
                 levels = c("Patch", "Placebo")),
  quit = c(
    rbinom(1, n_patch, p_patch),  # successes in patch group
    rbinom(1, n_placebo, p_placebo)  # successes in placebo group
  ) %>% {c(rep(1, .[1]), rep(0, n_patch - .[1]),
           rep(1, .[2]), rep(0, n_placebo - .[2]))}
)

# Alternatively, simulate individual outcomes:
data <- data.frame(
  group = factor(c(rep("Patch", n_patch), rep("Placebo", n_placebo)),
                 levels = c("Patch", "Placebo")),
  quit = c(
    rbinom(n_patch, 1, p_patch),
    rbinom(n_placebo, 1, p_placebo)
  )
)

# === STEP 1: Check Assumptions ===

# Create 2x2 contingency table
table_2x2 <- table(data$group, data$quit)
rownames(table_2x2) <- c("Patch", "Placebo")
colnames(table_2x2) <- c("Smoking", "Quit")

cat("=== 2×2 Contingency Table ===\n")
print(table_2x2)
print(addmargins(table_2x2))

# Check expected counts (npq rule)
cat("\n=== Expected Count Check ===\n")
n1 <- sum(data$group == "Patch")
n2 <- sum(data$group == "Placebo")
x1 <- sum(data$group == "Patch" & data$quit == 1)
x2 <- sum(data$group == "Placebo" & data$quit == 1)
p1_hat <- x1 / n1
p2_hat <- x2 / n2
p_pooled <- (x1 + x2) / (n1 + n2)

expected_counts <- c(
  n1 * p_pooled,
  n1 * (1 - p_pooled),
  n2 * p_pooled,
  n2 * (1 - p_pooled)
)

cat("Expected counts(using pooled proportion):\n")
cat("  Patch-Quit:", round(expected_counts[1], 1), "\n")
cat("  Patch-Smoking:", round(expected_counts[2], 1), "\n")
cat("  Placebo-Quit:", round(expected_counts[3], 1), "\n")
cat("  Placebo-Smoking:", round(expected_counts[4], 1), "\n")
cat("All expected counts ≥ 5?", all(expected_counts >= 5), "✓\n")

# === STEP 2: Descriptive Statistics ===
cat("\n=== Descriptive Statistics ===\n")
cat("Patch group: ", x1, "/", n1, " quit(", 
    round(100*p1_hat, 1), "%)\n", sep="")
cat("Placebo group: ", x2, "/", n2, " quit(", 
    round(100*p2_hat, 1), "%)\n", sep="")

# === STEP 3: Two-Proportion Z-Test ===
cat("\n=== Two-Proportion Z-Test ===\n")

# Method 1: Using prop.test() - applies continuity correction by default
result <- prop.test(c(x1, x2), c(n1, n2), correct = FALSE)  # no continuity correction
print(result)

# Method 2: Manual calculation (instructive)
p_diff <- p1_hat - p2_hat
se_pooled <- sqrt(p_pooled * (1 - p_pooled) * (1/n1 + 1/n2))
z_stat <- p_diff / se_pooled
p_value_twotailed <- 2 * (1 - pnorm(abs(z_stat)))

cat("\nManual Calculation:\n")
cat("  Difference in proportions(p₁ - p₂):", round(p_diff, 4), "\n")
cat("  Pooled SE:", round(se_pooled, 4), "\n")
cat("  Z-statistic:", round(z_stat, 3), "\n")
cat("  Two-tailed p-value:", format.pval(p_value_twotailed, digits=3), "\n")

# 95% Confidence Interval for difference (unpooled SE)
se_unpooled <- sqrt(p1_hat*(1-p1_hat)/n1 + p2_hat*(1-p2_hat)/n2)
ci_lower <- p_diff - 1.96 * se_unpooled
ci_upper <- p_diff + 1.96 * se_unpooled

cat("\n95% CI for difference(p₁ - p₂):", 
    "[", round(ci_lower, 3), ",", round(ci_upper, 3), "]\n")

# === STEP 4: Chi-Square Test (Equivalent) ===
cat("\n=== Chi-Square Test(Equivalent for 2×2) ===\n")
chi_result <- chisq.test(table_2x2, correct = FALSE)
print(chi_result)
cat("\nNote: χ² =", round(chi_result$statistic, 3), 
    "= z² =", round(z_stat^2, 3), "(equivalent)\n")

# === STEP 5: Fisher's Exact Test (Comparison) ===
cat("\n=== Fisher's Exact Test(for comparison) ===\n")
fisher_result <- fisher.test(table_2x2)
print(fisher_result)
cat("\nFisher's p-value:", format.pval(fisher_result$p.value, digits=3), "\n")
cat("Z-test p-value:", format.pval(p_value_twotailed, digits=3), "\n")
cat("(Should be similar with adequate sample size)\n")

# === STEP 6: Effect Sizes ===
cat("\n=== Effect Sizes ===\n")

# Risk Difference (RD)
rd <- p1_hat - p2_hat
cat("Risk Difference(RD):", round(rd, 3), "\n")
cat("  Interpretation:", round(100*rd, 1), "percentage point increase in quit rate\n")

# Relative Risk (RR)
rr <- p1_hat / p2_hat
rr_ci <- riskratio(table_2x2[, c(2, 1)], rev="rows")$measure[2, c(1, 2, 3)]
cat("\nRelative Risk(RR):", round(rr, 2), "\n")
cat("  95% CI:", "[", round(rr_ci[2], 2), ",", round(rr_ci[3], 2), "]\n")
cat("  Interpretation: Patch group", round(rr, 2), 
    "times more likely to quit than placebo\n")

# Odds Ratio (OR)
or_val <- (x1 / (n1 - x1)) / (x2 / (n2 - x2))
or_ci <- oddsratio(table_2x2[, c(2, 1)], rev="rows")$measure[2, c(1, 2, 3)]
cat("\nOdds Ratio(OR):", round(or_val, 2), "\n")
cat("  95% CI:", "[", round(or_ci[2], 2), ",", round(or_ci[3], 2), "]\n")

# Number Needed to Treat (NNT)
nnt <- 1 / rd
cat("\nNumber Needed to Treat(NNT):", round(nnt, 1), "\n")
cat("  Interpretation: Treat", round(nnt, 0), 
    "people with patch for 1 additional quit\n")

# === STEP 7: Visualization ===

# Bar plot with proportions and 95% CIs
summary_data <- data %>%
  group_by(group) %>%
  summarise(
    n = n(),
    successes = sum(quit),
    prop = mean(quit),
    se = sqrt(prop * (1 - prop) / n),
    ci_lower = prop - 1.96 * se,
    ci_upper = prop + 1.96 * se,
    .groups = "drop"
  )

ggplot(summary_data, aes(x = group, y = prop, fill = group)) +
  geom_bar(stat = "identity", width = 0.6, alpha = 0.8) +
  geom_errorbar(aes(ymin = ci_lower, ymax = ci_upper), 
                width = 0.2, size = 1) +
  geom_text(aes(label = paste0(round(100*prop, 1), "%")), 
            vjust = -0.5, hjust = 0.5, nudge_y = 0.05, size = 5) +
  scale_y_continuous(labels = scales::percent, limits = c(0, 0.6)) +
  labs(title = "Smoking Cessation Rates at 6 Months",
       subtitle = "Nicotine Patch vs. Placebo(RCT, n=240)",
       x = "Treatment Group", y = "Proportion Quit ± 95% CI") +
  scale_fill_brewer(palette = "Set2") +
  theme_classic() +
  theme(legend.position = "none", 
        axis.text = element_text(size = 12),
        axis.title = element_text(size = 13))

# Forest plot for effect sizes
library(forestplot)
effect_data <- data.frame(
  Measure = c("Risk Difference", "Relative Risk", "Odds Ratio"),
  Estimate = c(rd, rr, or_val),
  Lower = c(ci_lower, rr_ci[2], or_ci[2]),
  Upper = c(ci_upper, rr_ci[3], or_ci[3])
)

# === APA-Style Reporting ===
cat("\n=== APA-Style Report ===\n")
cat("A two-proportion z-test was conducted to compare smoking cessation rates\n")
cat("between nicotine patch(n = 120) and placebo(n = 120) groups at 6 months.\n")
cat("Assumptions were satisfied: independence(RCT with random assignment),\n")
cat("binary outcome(quit vs. smoking), and adequate expected counts(all ≥ 5).\n")
cat("Results showed a statistically significant difference, z =", round(z_stat, 2), ",\n")
cat("p =", format.pval(p_value_twotailed, digits=3), ". The nicotine patch group had\n")
cat("a significantly higher quit rate(", round(100*p1_hat, 1), "%, ", x1, "/", n1, ")\n", sep="")
cat("compared to placebo(", round(100*p2_hat, 1), "%, ", x2, "/", n2, "),\n", sep="")
cat("with a risk difference of", round(100*rd, 1), "percentage points\n")
cat("(95% CI [", round(100*ci_lower, 1), ",", round(100*ci_upper, 1), "]).\n")
cat("The relative risk was", round(rr, 2), "(95% CI [", round(rr_ci[2], 2), ",", 
    round(rr_ci[3], 2), "]),\n")
cat("indicating nicotine patch users were", round(rr, 2), 
    "times more likely to quit.\n")
cat("Number needed to treat(NNT) =", round(nnt, 0), 
    ": one additional quit per", round(nnt, 0), "treated.\n")
Interpretation Blueprint

z = 2.34, p = .019. The nicotine patch group had significantly higher quit rates (35.0%, 42/120) compared to placebo (20.0%, 24/120), with a risk difference of 15.0 percentage points (95% CI [2.5, 27.5]). RR = 1.75 (95% CI [1.13, 2.72]): patch users were 75% more likely to quit. NNT = 7: treating 7 people with nicotine patch yields 1 additional quit compared to placebo. Findings support nicotine patch as effective smoking cessation aid, consistent with Cochrane meta-analysis (Stead et al., 2012).

05Tactical Pivots

Alternatives

Structured fallback pathways for choosing alternative tests when normality or slopes requirements fail.

When the path is blocked, pivot. Rigor is not rigidity; it is the intelligent adaptation to reality.
Adaptive Strategy
Measurement Precision Ladder Ideal · Independent Binary Groups
Ratio
Consider T-Tests or ANOVA. Proportion comparison ignores the numerical magnitude of change.
Precision Leak
Ordinal
Pivot to Jonckheere-Terpstra if the populations follow a natural order (e.g., Stage 1, 2, 3).
Threshold Loss
Binary Yield
Maintain Z-Test logic. The most efficient audit for comparing success rates between independent groups.
Peak Signal
Temporal Trajectory Audit Static Yield Snapshot
Static Populations
Cross-sectional gap.
Stay with Two Proportions Test. Isolate the yield difference.
Matched Pairs
Trajectory flips.
Pivot to McNemar's Test to model the probability of internal status-change over time.
Adaptive Technical Safeguards · adaptive safeguards
low event counts
  • Fisher's Exact Test — The required strike when any cell in the yield grid is < 5.
  • Rule of Three — Provide approximate bounds if zero events were observed in one group.
highly unequal N
  • Likelihood Ratio Strike — Use G-test or Logistic Regression to maintain better additive properties.
non independent successes
  • Binary GEE — Account for clustering if success events occur within families or clinical sites.
06Adjusted Comparisons

Post-hoc

Group mean comparisons and correction controls (e.g. Tukey HSD, Bonferroni) to protect against Family-Wise Error Rates.

The omnibus test opens the door; post-hoc analysis explores the room.
Forensic Detail
Adjusted Comparisons

Post-hoc pairwise tests defined for this model.

Interpretation Guidelines

Two-proportion test is typically a planned comparison. Post-hoc analyses are rare, but if needed:

07Standardized scale impact

Effect Size

Understanding effect sizes (e.g., Cohen's d, Partial Eta-Squared) and clinical impact benchmarks.

Significance is noise. Magnitude is the signal. Measure the impact, not just the probability.
Impact Magnitude

RD = p₁ - p₂. Interpretation: Absolute change in proportion. RD = 0.15 means 15 percentage point increase. Preferred for clinical interpretation. Small: 0.05, Medium: 0.10, Large: 0.20

RR = p₁/p₂. Interpretation: Ratio of proportions. RR = 1.5 means 50% higher risk in group 1. RR > 1 (increased risk), RR < 1 (decreased risk), RR = 1 (no difference). Preferred for epidemiology

OR = (p₁/(1-p₁)) / (p₂/(1-p₂)). Interpretation: Ratio of odds. When events are rare (p < 0.10), OR ≈ RR. Preferred for logistic regression. OR > 1 (increased odds), OR < 1 (decreased odds)

NNT = 1/RD. Interpretation: Number needed to treat for one additional success. NNT = 7 means treat 7 people for 1 additional cure. Lower NNT = more effective. Preferred for clinical decision-making

h = 2*(arcsin(√p₁) - arcsin(√p₂)). Standardized measure. Small: 0.2, Medium: 0.5, Large: 0.8. Preferred for power analysis and meta-analysis

Recommended Metric: Risk Difference (RD) for absolute effects; Relative Risk (RR) for relative effects; NNT for clinical utility. Always report with 95% CIs.
Small
0.2
Medium
0.5
Large
0.8
0.50
Risk Difference (RD) for absolute effects; Relative Risk (RR) for relative effects; NNT for clinical utility. Always report with 95% CIs.
Recommended Measure
5
Available Metrics
ReportUse Risk Difference (RD) for absolute effects; Relative Risk (RR) for relative effects; NNT for clinical utility. Always report with 95% CIs. to represent clinical impact magnitude.
08Statistical Power

Sample Size

Guidelines for minimum sample requirements and power analysis parameters.

An underpowered study is an ethical failure. Respect the data by collecting enough of it.
Power Protocol
Floor Requirements

Ensure expected counts ≥ 5 in all cells: n₁p̂, n₁(1-p̂), n₂p̂, n₂(1-p̂) all ≥ 5. If violated, use Fisher's exact test

Effect SizeParametersRequired n
Small Effectα=.05, power=.80RD = 0.05
Medium Effectα=.05, power=.80RD = 0.10
Large Effectα=.05, power=.80RD = 0.20
G*Power StrategyUse G*Power: z-tests → Proportions: Difference between two independent proportions. Input: p₁, p₂, α, power, allocation ratio. Or use online calculators (e.g., Epitools, OpenEpi)
09APA narrative blueprint

Reporting

How to compile statistical results into publication prose matching APA and journal style guides.

Data does not speak for itself. It requires a translator. Be clear, be precise, be honest.
Narrative Arc
Worked APA paragraph example
A two-proportion z-test was conducted to compare smoking cessation rates between nicotine patch (n = 120) and placebo (n = 120) groups at 6 months. Assumptions were satisfied: independence (RCT with random assignment), binary outcome (quit vs. smoking), and adequate expected counts (all cells ≥ 5). Results showed a statistically significant difference, z = 2.34, p = .019. The nicotine patch group had a significantly higher quit rate (35.0%, 42/120) compared to placebo (20.0%, 24/120), with a risk difference of 15.0 percentage points (95% CI [2.5, 27.5]). The relative risk was 1.75 (95% CI [1.13, 2.72]), indicating nicotine patch users were 75% more likely to quit than placebo users. Number needed to treat (NNT) = 7: treating 7 people with nicotine patch yields 1 additional quit compared to placebo. These findings support nicotine patch as an effective smoking cessation aid, consistent with meta-analytic evidence (Stead et al., 2012).
Reusable template

A two-proportion z-test was conducted to compare brief description of outcome between group 1 (n = XX) and group 2 (n = XX). State hypothesis type: two-tailed or one-tailed. Assumptions were satisfied/violated: independence (describe design), binary outcome, and adequate/inadequate expected counts (all ≥ 5 / Fisher's exact test used instead). Results showed a statistically significant / non-significant difference, z = X.XX, p = .XXX. Group 1 had a higher/lower proportion (XX.X%, X/n₁) compared to group 2 (XX.X%, X/n₂), with a risk difference of XX.X percentage points (95% CI XX.X, XX.X). The relative risk was X.XX (95% CI X.XX, X.XX), indicating interpretation. Number needed to treat (NNT) = XX. Conclude with interpretation in research context.

Essential statistics to report
  • z-statistic
  • p-value (specify one-tailed or two-tailed)
  • Proportions in each group (%, count/n)
  • Risk difference with 95% CI
  • Relative risk or odds ratio with 95% CI
  • NNT (if intervention study)
  • Statement about assumption checks (independence, expected counts)
10Exhibit Builder

Manuscript Lab

Copy standard summary tables and forensic reporting grids to outline analysis details.

Table 1: Comparison of Success Proportions across Independent Groups
GroupSuccessesTotalProportion (%)Diff (p1-p2)95% CI (Diff)p-value
Experimental7510075.0%15.0%[4.2%, 25.8%].008
Standard6010060.0%
Note. N1 = 100, N2 = 100. Reporting Difference in Proportions. Yates' continuity correction applied.
Diff = 15.0%Powerful Clinical Shift. The experimental treatment successfully converted 15% more participants compared to standard care.
Header glossary

The 'Absolute Lift'. The raw difference in success rates between the two groups.

The Precision Window. If the interval excludes ZERO, the difference is statistically significant.

11Algorithmic Logic

Command Center

Syntax libraries and function parameters for executing calculations in stats packages.

Code is the modern laboratory. Clean execution ensures reproducible discovery.
Execution Engine
# 1. Execute Two-Proportions Test
prop.test(x = c(75, 60), n = c(100, 100))

# 2. Extract Exact p-value (for small samples)
fisher.test(matrix(c(75, 25, 60, 40), ncol=2))
Library stack
R
stats
Python
statsmodels.stats.proportion
Elite Forensic Strike

The 'Continuity Correction' debate. Yates' correction is conservative and prevents Type I errors in small samples. In large samples (N > 100), the results converge, making the correction less critical.

# Generate Instant APA Narrative
report::report(prop.test(c(75, 60), c(100, 100)))
12The Over-adjustment Trap

Common Mistakes

Analytical caveats and corrections to maintain modeling integrity.

Wisdom is learning from the failures of others. Anticipate the error before it occurs.
Defensive Logic
Why it's wrong
The normal approximation (z-distribution) is invalid when expected counts are small (< 5). This inflates Type I error (false positives) and yields unreliable p-values and confidence intervals.
The correction
If any expected count < 5: use Fisher's exact test (provides exact p-value without normal approximation) or Barnard's exact test (more powerful for 2×2 tables). Fisher's exact is conservative; Barnard's is preferred when available.
Why it's wrong
These measure different aspects of association and are NOT interchangeable. RD is absolute (additive), RR and OR are relative (multiplicative). OR approximates RR only when event is rare (< 10%). Misinterpreting OR as RR exaggerates effect sizes.
The correction
Risk Difference (RD = p₁ - p₂): absolute change, use for NNT and clinical impact. Relative Risk (RR = p₁/p₂): proportional change, intuitive for cohort studies. Odds Ratio (OR): use for case-control or logistic regression; approximates RR when rare. Always specify which measure you're reporting.
Why it's wrong
Two-proportion z-test assumes independent samples. Paired data (e.g., same subjects pre/post, matched pairs) violates independence, inflating Type I error by ignoring within-pair correlation.
The correction
For paired proportions: use McNemar's test (2×2 contingency table of paired outcomes). McNemar's accounts for correlation and tests marginal homogeneity. Example: testing treatment effect with before/after measurements on same subjects.
Why it's wrong
P-value indicates statistical significance but not practical/clinical importance. With large samples, tiny trivial differences become 'significant'. Effect sizes quantify magnitude of difference.
The correction
Always report: (1) Risk Difference with 95% CI (absolute effect); (2) Relative Risk or Odds Ratio with 95% CI (relative effect); (3) NNT (clinical utility). Include confidence intervals to show precision.
Why it's wrong
Chi-square test is always two-tailed (tests association, not direction). If you have a directional hypothesis (e.g., p₁ > p₂), chi-square wastes power by considering both tails.
The correction
Use z-test for proportions with one-tailed alternative when directional hypothesis is pre-specified (e.g., vaccine reduces infection, not increases). Report one-tailed p-value. Note: one-tailed tests are controversial; pre-register hypothesis to avoid post-hoc decisions.
Why it's wrong
Discrete binomial data are approximated by continuous normal distribution. Without continuity correction, z-test is anticonservative (Type I error > α) in small-moderate samples.
The correction
Apply Yates' continuity correction when min(n₁, n₂) < 50 or any expected count < 10. In R: prop.test(..., correct=TRUE). In Python: use chi2_contingency(..., correction=True). Correction makes test more conservative (larger p-values).
Why it's wrong
Testing k groups pairwise yields k(k-1)/2 comparisons, inflating familywise Type I error. With 4 groups (6 comparisons) at α=.05 each, familywise error ≈ 26%.
The correction
Use chi-square omnibus test first (tests H₀: all proportions equal). If significant, conduct pairwise z-tests with Bonferroni correction (α_corrected = 0.05 / number of comparisons). Alternatively, use logistic regression with multiple groups.
Why it's wrong
Two-proportion z-test provides unadjusted (crude) comparison, ignoring confounders. If groups differ on baseline characteristics (age, sex, severity), results may be confounded.
The correction
Use logistic regression to adjust for covariates: glm(outcome ~ group + age + sex, family=binomial). Report adjusted odds ratio. Alternatively, use stratified analysis (Mantel-Haenszel test) or propensity score methods.
13Academic Lineage

References

Scholarly lineage and citation keys grounding the statistical framework.

We stand on the shoulders of giants. Honor the source of the method.
Academic Lineage
[1]
Stead, L. F., Perera, R., Bullen, C., Mant, D., Hartmann-Boyce, J., Cahill, K., & Lancaster, T. (2012). Nicotine replacement therapy for smoking cessation. Cochrane Database of Systematic Reviews, (11), CD000146.
Meta-analysis showing nicotine patch increases quit rates (RR = 1.64, 95% CI [1.53, 1.75]). Basis for Example 1
doi: 10.1002/14651858.CD000146.pub4
[2]
Polack, F. P., Thomas, S. J., Kitchin, N., et al. (2020). Safety and efficacy of the BNT162b2 mRNA Covid-19 vaccine. New England Journal of Medicine, 383(27), 2603-2615.
Pfizer-BioNTech COVID-19 vaccine phase 3 trial: 95% efficacy (95% CI [90.3, 97.6]). Basis for Example 2
doi: 10.1056/NEJMoa2034577
[3]
Agresti, A., & Coull, B. A. (1998). Approximate is better than 'exact' for interval estimation of binomial proportions. The American Statistician, 52(2), 119-126.
Discussion of confidence interval methods for proportions; Agresti-Coull method improves coverage
doi: 10.1080/00031305.1998.10480550
[4]
Barnard, G. A. (1947). Significance tests for 2×2 tables. Biometrika, 34(1/2), 123-138.
Introduction of Barnard's exact test, more powerful than Fisher's exact for 2×2 tables
doi: 10.2307/2332378
[5]
Newcombe, R. G. (1998). Interval estimation for the difference between independent proportions: Comparison of eleven methods. Statistics in Medicine, 17(8), 873-890.
Comparison of CI methods for risk difference; Wilson score and Agresti-Caffo recommended
doi: 10.1002/(SICI)1097-0258(19980430)17:8<873::AID-SIM779>3.0.CO;2-I
[6]
Altman, D. G. (1998). Confidence intervals for the number needed to treat. BMJ, 317(7168), 1309-1312.
Method for calculating confidence intervals for NNT from risk difference CIs
doi: 10.1136/bmj.317.7168.1309
A percentage is a story of a hundred parts. Use the Z-test to find the gap between the stories, but never ignore the people who make up the denominator.
The Interpretive Rigor Directive
statminds · TwoMind reference · v2.2 · updated 2026-01-1715 of 15 sections