P Value from Confidence Interval: How to Calculate
The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.
This calculator derives a two-sided p-value from a confidence interval and sample size. Enter the lower and upper confidence limits, the confidence level (as a percentage), and the sample size; you get back the estimated standard error and the p-value for the null hypothesis that the true effect is zero.
Formula
For a confidence interval [L, U] at confidence level C (e.g., 95%), the standard error (SE) is estimated as:
SE = (U − L) / (2 × zC)
where zC is the critical value of the standard normal distribution for that confidence level (1.96 for 95%, 2.576 for 99%, 1.645 for 90%). The point estimate is the midpoint: M = (L + U) / 2. The z-score for testing whether the true value is zero is:
z = M / SE
The two-sided p-value is then:
p = 2 × (1 − Φ(|z|))
where Φ is the cumulative distribution function of the standard normal distribution. In the calculator, Φ is computed using the error function (erf).
Worked Example
Using the defaults: lower limit = 0.5, upper limit = 2.5, confidence level = 95%, sample size = 30.
- Find the critical value: for 95% confidence, zC = 1.96.
- Compute the standard error: SE = (2.5 − 0.5) / (2 × 1.96) = 2.0 / 3.92 = 0.5102.
- Compute the midpoint: M = (0.5 + 2.5) / 2 = 1.5.
- Compute the z-score: z = 1.5 / 0.5102 = 2.94.
- Compute the two-sided p-value: p = 2 × (1 − Φ(2.94)) ≈ 2 × (1 − 0.99836) = 0.0033.
The calculator displays p ≈ 0.0033, meaning the result is statistically significant at the 0.05 level.
When to Use This Method
This approach is useful when a paper or report gives a confidence interval but not the p-value. It works for estimates that follow a normal distribution (or are approximately normal), such as means, differences in means, regression coefficients, and odds ratios on the log scale. It assumes the interval is symmetric on the scale you are using. For ratios (like odds ratios or hazard ratios), the interval is usually symmetric on the log scale, so you must first take the natural logarithm of the limits before applying the formula.
How to Interpret the Result
The p-value tells you the probability of observing a result as extreme as yours if the true effect were zero. A small p-value (typically less than 0.05) suggests the effect is unlikely to be due to chance alone. However, the p-value does not tell you the size of the effect or its practical importance. The confidence interval itself gives a range of plausible values for the true effect, which is often more informative than the p-value alone.
Common Mistakes and Pitfalls
- Using the wrong confidence level: If the interval is 90% or 99%, you must use the corresponding critical value (1.645 or 2.576), not 1.96.
- Ignoring the log scale: For odds ratios, hazard ratios, and risk ratios, the interval is computed on the log scale. Convert the limits to natural logs before applying the formula, then exponentiate the result if needed.
- Assuming a one-sided test: The formula above gives a two-sided p-value. If you need a one-sided p-value, halve the result.
- Small sample sizes: The method relies on the normal approximation. For small samples (e.g., n < 30) or when the original data are not normally distributed, the approximation may be inaccurate. In such cases, a t-distribution-based approach is better, but that requires the original data or the t-statistic.
Limitations of the Approximation
This method is an approximation. It assumes the confidence interval was constructed using a normal distribution (or a t-distribution with a large enough sample size that the normal approximation holds). It also assumes the interval is symmetric and that the sample size is known. If the interval was derived from a non-parametric method (e.g., bootstrap) or from a skewed distribution, the p-value may be inaccurate. Additionally, the sample size is used only to check the plausibility of the normal approximation; it does not enter the calculation directly. For a more precise p-value, you would need the original data or the test statistic.
Frequently Asked Questions
Can I calculate a p-value from a confidence interval without the sample size?
Yes, the formula for the p-value does not require the sample size directly. The sample size only matters for assessing whether the normal approximation is valid. If you omit it, the calculator still gives a p-value, but you should be cautious if the sample size is small.
What if my confidence interval is for an odds ratio?
For odds ratios, the interval is typically computed on the log scale. Take the natural logarithm of the lower and upper limits, then apply the formula using those log-transformed values. The resulting p-value tests whether the true odds ratio is 1 (no effect).
How do I convert a one-sided p-value to a two-sided p-value?
Multiply the one-sided p-value by 2 to get the two-sided p-value. Conversely, divide a two-sided p-value by 2 to get a one-sided p-value (assuming the effect is in the expected direction).
Does this method work for confidence intervals from t-tests?
It works approximately if the sample size is reasonably large (e.g., n > 30). For smaller samples, the t-distribution has heavier tails, so the normal-based p-value will be slightly too small. If you have the degrees of freedom and the t-statistic, you can compute a more accurate p-value using the t-distribution.
What if the confidence interval includes zero?
If the interval includes zero, the p-value will be greater than 0.05 (for a 95% interval). Specifically, if the interval is [−1, 2], the midpoint is 0.5, the SE is (2 − (−1)) / (2 × 1.96) = 0.765, z = 0.5 / 0.765 = 0.654, and p ≈ 0.51. This indicates the result is not statistically significant.
Related
Formula used
in lo | Lower limit | - | 0.5 | 0 in hi | Upper limit | - | 2.5 | 0 in cl | Confidence level (%) | % | 95 | 0 in n | Sample size | - | 30 | 1 out se | Standard error | - | (hi - lo) / (2 * 1.96) | 4 out z | z-score | - | ((hi + lo) / 2) / se | 4 out p | p-value (two-sided) | - | 2 * (1 - 0.5 * (1 + erf(abs(z) / sqrt(2)))) | 4
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.