This calculator helps you compare two related measurements from the same subjects to determine if there's a statistically significant difference. Whether you have wide format data (two columns side by side) or long format data (subject ID, condition, and value columns), this calculator handles both formats. Perfect for before-and-after studies (weight loss, test scores, blood pressure), repeated measurements (twins, siblings, matched controls), or any situation where you have matched pairs of data.
Ready to analyze your paired data? or to see how it works, or upload your own data to begin your analysis.
Paired T-Test is a statistical test used to compare two related/dependent samples to determine if there is a significant difference between their means. It's particularly useful when measurements are taken from the same subject before and after a treatment, or when subjects are matched pairs.
Test Statistic:
Degrees of freedom:
Confidence Intervals:
Two-sided confidence interval:
One-sided confidence intervals:
Where:
Testing the effectiveness of a weight loss program by measuring participants' weights before and after the program:
Given Data:
Hypotheses:
Null Hypothesis (): (no difference between before and after)
Alternative Hypothesis (): (there is a difference)
Step-by-Step Calculation:
Conclusion:
, we reject the null hypothesis. There is sufficient evidence to conclude that the weight loss program resulted in a significant change in participants' weights (). We are 95% confident that the true mean difference lies between -3.2 and -2.4 kg.
Cohen's d for paired samples:
Interpretation guidelines:
Required sample size (n) for desired power (1-β):
Where:
Reject if:
Standard format for scientific reporting:
library(tidyverse)
library(car)
library(effsize)
set.seed(42)
n <- 30
baseline <- rnorm(n, mean = 100, sd = 15)
followup <- baseline + rnorm(n, mean = -5, sd = 5) # Average decrease of 5 units
# Create data frame
data <- tibble(
subject = 1:n,
baseline = baseline,
followup = followup,
difference = followup - baseline
)
# Basic summary
summary_stats <- data %>%
summarise(
mean_diff = mean(difference),
sd_diff = sd(difference),
n = n()
)
# Paired t-test
t_test_result <- t.test(data$followup, data$baseline, paired = TRUE)
# Effect size
cohens_d <- mean(data$difference) / sd(data$difference)
# Visualization
ggplot(data) +
geom_point(aes(x = baseline, y = followup)) +
geom_abline(intercept = 0, slope = 1, linetype = "dashed") +
theme_minimal() +
labs(title = "Baseline vs Follow-up Measurements",
subtitle = paste("Mean difference:", round(mean(data$difference), 2)))import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
import seaborn as sns
from statsmodels.stats.power import TTestPower
# Generate example data
np.random.seed(42)
n = 30
baseline = np.random.normal(100, 15, n)
followup = baseline + np.random.normal(-5, 5, n)
differences = followup - baseline
# Basic statistics
mean_diff = np.mean(differences)
sd_diff = np.std(differences, ddof=1)
se_diff = sd_diff / np.sqrt(n)
# Paired t-test
t_stat, p_value = stats.ttest_rel(followup, baseline)
# Effect size
cohens_d = mean_diff / sd_diff
# Power analysis
analysis = TTestPower()
power = analysis.power(effect_size=cohens_d,
nobs=n,
alpha=0.05)
# Visualization
plt.figure(figsize=(12, 5))
# Scatterplot
plt.subplot(1, 2, 1)
plt.scatter(baseline, followup)
min_val = min(baseline.min(), followup.min())
max_val = max(baseline.max(), followup.max())
plt.plot([min_val, max_val], [min_val, max_val], '--', color='red')
plt.xlabel('Baseline')
plt.ylabel('Follow-up')
plt.title('Baseline vs Follow-up')
# Differences histogram
plt.subplot(1, 2, 2)
sns.histplot(differences, kde=True)
plt.axvline(mean_diff, color='red', linestyle='--')
plt.xlabel('Differences (Follow-up - Baseline)')
plt.title('Distribution of Differences')
plt.tight_layout()
plt.show()
print(f"Mean difference: {mean_diff:.2f}")
print(f"Standard deviation of differences: {sd_diff:.2f}")
print(f"t-statistic: {t_stat:.2f}")
print(f"p-value: {p_value:.4f}")
print(f"Cohen's d: {cohens_d:.2f}")
print(f"Statistical Power: {power:.4f}")Consider these alternatives when assumptions are violated:
This calculator helps you compare two related measurements from the same subjects to determine if there's a statistically significant difference. Whether you have wide format data (two columns side by side) or long format data (subject ID, condition, and value columns), this calculator handles both formats. Perfect for before-and-after studies (weight loss, test scores, blood pressure), repeated measurements (twins, siblings, matched controls), or any situation where you have matched pairs of data.
Ready to analyze your paired data? or to see how it works, or upload your own data to begin your analysis.
Paired T-Test is a statistical test used to compare two related/dependent samples to determine if there is a significant difference between their means. It's particularly useful when measurements are taken from the same subject before and after a treatment, or when subjects are matched pairs.
Test Statistic:
Degrees of freedom:
Confidence Intervals:
Two-sided confidence interval:
One-sided confidence intervals:
Where:
Testing the effectiveness of a weight loss program by measuring participants' weights before and after the program:
Given Data:
Hypotheses:
Null Hypothesis (): (no difference between before and after)
Alternative Hypothesis (): (there is a difference)
Step-by-Step Calculation:
Conclusion:
, we reject the null hypothesis. There is sufficient evidence to conclude that the weight loss program resulted in a significant change in participants' weights (). We are 95% confident that the true mean difference lies between -3.2 and -2.4 kg.
Cohen's d for paired samples:
Interpretation guidelines:
Required sample size (n) for desired power (1-β):
Where:
Reject if:
Standard format for scientific reporting:
library(tidyverse)
library(car)
library(effsize)
set.seed(42)
n <- 30
baseline <- rnorm(n, mean = 100, sd = 15)
followup <- baseline + rnorm(n, mean = -5, sd = 5) # Average decrease of 5 units
# Create data frame
data <- tibble(
subject = 1:n,
baseline = baseline,
followup = followup,
difference = followup - baseline
)
# Basic summary
summary_stats <- data %>%
summarise(
mean_diff = mean(difference),
sd_diff = sd(difference),
n = n()
)
# Paired t-test
t_test_result <- t.test(data$followup, data$baseline, paired = TRUE)
# Effect size
cohens_d <- mean(data$difference) / sd(data$difference)
# Visualization
ggplot(data) +
geom_point(aes(x = baseline, y = followup)) +
geom_abline(intercept = 0, slope = 1, linetype = "dashed") +
theme_minimal() +
labs(title = "Baseline vs Follow-up Measurements",
subtitle = paste("Mean difference:", round(mean(data$difference), 2)))import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
import seaborn as sns
from statsmodels.stats.power import TTestPower
# Generate example data
np.random.seed(42)
n = 30
baseline = np.random.normal(100, 15, n)
followup = baseline + np.random.normal(-5, 5, n)
differences = followup - baseline
# Basic statistics
mean_diff = np.mean(differences)
sd_diff = np.std(differences, ddof=1)
se_diff = sd_diff / np.sqrt(n)
# Paired t-test
t_stat, p_value = stats.ttest_rel(followup, baseline)
# Effect size
cohens_d = mean_diff / sd_diff
# Power analysis
analysis = TTestPower()
power = analysis.power(effect_size=cohens_d,
nobs=n,
alpha=0.05)
# Visualization
plt.figure(figsize=(12, 5))
# Scatterplot
plt.subplot(1, 2, 1)
plt.scatter(baseline, followup)
min_val = min(baseline.min(), followup.min())
max_val = max(baseline.max(), followup.max())
plt.plot([min_val, max_val], [min_val, max_val], '--', color='red')
plt.xlabel('Baseline')
plt.ylabel('Follow-up')
plt.title('Baseline vs Follow-up')
# Differences histogram
plt.subplot(1, 2, 2)
sns.histplot(differences, kde=True)
plt.axvline(mean_diff, color='red', linestyle='--')
plt.xlabel('Differences (Follow-up - Baseline)')
plt.title('Distribution of Differences')
plt.tight_layout()
plt.show()
print(f"Mean difference: {mean_diff:.2f}")
print(f"Standard deviation of differences: {sd_diff:.2f}")
print(f"t-statistic: {t_stat:.2f}")
print(f"p-value: {p_value:.4f}")
print(f"Cohen's d: {cohens_d:.2f}")
print(f"Statistical Power: {power:.4f}")Consider these alternatives when assumptions are violated: