DEV Community

Alan Matthew
Alan Matthew

Posted on

Cronbach’s Alpha Explained: Formula, Worked Example, and Python Code

If you've ever built a survey with several questions meant to measure the same thing (job satisfaction, anxiety, product usability), someone has probably asked: "What's the Cronbach's alpha?"

Alpha is the most commonly reported reliability number for multi-item scales, and also one of the most misread. This post covers what it measures, where the formula comes from, a worked example you can reproduce by hand, code in Python and R, and the mistakes that quietly wreck your result.

What Cronbach's alpha actually measures

Suppose you measure "study motivation" with five Likert items (1 to 5). Each item is a noisy measurement. If the items really tap the same underlying trait, respondents who score high on one should tend to score high on the others. Alpha quantifies that agreement, called internal consistency.

It runs from 0 to 1 in practice (it can go negative, which is a red flag, not a feature). Higher means the items move together more.

What alpha does not tell you:

  • That the scale measures what you think it measures. That's validity.
  • That the scale is one-dimensional. More on this below.
  • That your instrument is "reliable" in general. Alpha describes the scores from your sample, not the questionnaire itself.

The formula

α = ( k / (k − 1) ) × ( 1 − Σ σ²ᵢ / σ²ₓ )
Enter fullscreen mode Exit fullscreen mode
  • k = number of items
  • σ²ᵢ = variance of item i
  • σ²ₓ = variance of the total score (the sum of all items per respondent)

The intuition: the total-score variance equals the sum of the item variances plus twice the sum of all pairwise covariances.

σ²ₓ = Σ σ²ᵢ + 2 Σ Cov(yᵢ, yⱼ)
Enter fullscreen mode Exit fullscreen mode

If items are unrelated, covariances are about 0, so σ²ₓ ≈ Σ σ²ᵢ, the fraction is about 1, and alpha is about 0. If items correlate strongly, covariances are large, the total variance far exceeds the item variances, the fraction shrinks, and alpha moves toward 1. The k/(k−1) factor rescales the result so a perfectly consistent scale can reach 1.

There's also a standardized alpha, based on the mean inter-item correlation r̄:

α_standardized = k·r̄ / (1 + (k − 1)·r̄)
Enter fullscreen mode Exit fullscreen mode

Use it when items are on very different scales (say, a 5-point item next to a 100-point slider), since high-variance items would otherwise dominate the raw version.

A worked example (with a trap in it)

Eight respondents answered five items on a 1 to 5 agreement scale. Item 5 is reverse-worded ("I feel anxious when studying"), while items 1 to 4 are positively worded.

Respondent Item 1 Item 2 Item 3 Item 4 Item 5 (raw)
1 4 5 4 4 2
2 3 3 4 3 3
3 5 5 5 4 1
4 2 3 2 3 4
5 4 4 5 4 2
6 3 2 3 3 3
7 5 4 5 5 1
8 2 2 3 2 4

Attempt 1: forget to recode

With the raw data as is:

  • Sum of item variances = 6.4107
  • Variance of the total scores = 8.6964
α = (5/4) × (1 − 6.4107 / 8.6964)
  = 1.25 × (1 − 0.7372)
  = 1.25 × 0.2628
  ≈ 0.329
Enter fullscreen mode Exit fullscreen mode

An alpha of .33 would tell you the scale is garbage. But look at the data: item 5 runs opposite to the other four. Its corrected item-total correlation is about −0.98. That negative covariance is eating the total variance.

Attempt 2: recode first

For a scale running 1 to M, a reverse-scored item is recoded as (M + 1) − x. Here, 6 − x. After recoding item 5:

  • Sum of item variances = 6.4107 (unchanged, since recoding only flips direction)
  • Variance of the total scores = 27.8393
α = (5/4) × (1 − 6.4107 / 27.8393)
  = 1.25 × (1 − 0.2303)
  = 1.25 × 0.7697
  ≈ 0.962
Enter fullscreen mode Exit fullscreen mode

Same respondents, same answers, same item variances. The only change is direction, and alpha goes from .33 to .96. Forgetting to recode reverse-worded items is the single most common reason people get a mysteriously terrible alpha.

(Eight respondents is a toy dataset to keep the arithmetic readable. Real reliability estimates need far more people, as discussed below.)

Item diagnostics: which questions pull their weight?

Two columns matter on most software output:

  • Corrected item-total correlation: how strongly an item correlates with the sum of the other items. Values below about .30 flag items that don't track the rest of the scale.
  • Alpha if item deleted: what alpha would be if you dropped that item.

For the recoded data:

Item Mean Variance Corrected item-total r α if deleted
1 3.50 1.4286 .976 .939
2 3.50 1.4286 .797 .970
3 3.875 1.2679 .860 .958
4 3.50 0.8571 .887 .957
5 (recoded) 3.50 1.4286 .976 .939

Item 2 is the weakest: dropping it nudges alpha up slightly, from .962 to .970. That's a signal to look at the item, not an order to delete it. If it covers a facet of the construct you care about, keep it. Delete items for conceptual reasons first, statistical ones second.

Compute it in code

Python (NumPy only):

import numpy as np

def cronbach_alpha(items):
    items = np.asarray(items, dtype=float)
    k = items.shape[1]
    item_vars = items.var(axis=0, ddof=1)        # sample variance per item
    total_var = items.sum(axis=1).var(ddof=1)    # variance of total scores
    return k / (k - 1) * (1 - item_vars.sum() / total_var)

X = np.array([
    [4, 5, 4, 4, 2],
    [3, 3, 4, 3, 3],
    [5, 5, 5, 4, 1],
    [2, 3, 2, 3, 4],
    [4, 4, 5, 4, 2],
    [3, 2, 3, 3, 3],
    [5, 4, 5, 5, 1],
    [2, 2, 3, 2, 4],
])

print(round(cronbach_alpha(X), 4))   # 0.3285  (item 5 not recoded)

X[:, 4] = 6 - X[:, 4]                # reverse-score item 5
print(round(cronbach_alpha(X), 4))   # 0.9622

# alpha if each item is deleted
for j in range(X.shape[1]):
    print(j + 1, round(cronbach_alpha(np.delete(X, j, axis=1)), 4))
Enter fullscreen mode Exit fullscreen mode

Note ddof=1. Using population variance for items but sample variance for totals (or vice versa) is a classic source of tiny mismatches between tools. As long as you're consistent, the n terms cancel.

Python (pingouin) wraps this and also gives a confidence interval:

import pandas as pd
import pingouin as pg

alpha, ci = pg.cronbach_alpha(data=pd.DataFrame(X))
Enter fullscreen mode Exit fullscreen mode

R (psych):

library(psych)
alpha(df, check.keys = TRUE)   # warns about and flips negatively correlated items
Enter fullscreen mode Exit fullscreen mode

check.keys = TRUE is handy, but treat it as a diagnostic. Recode on purpose, using your item wording, not whatever the correlation matrix suggests.

How to read the number

You'll see tables like this everywhere:

α Common label
≥ .90 Excellent
.80 to .89 Good
.70 to .79 Acceptable
.60 to .69 Questionable
< .60 Poor

These are rules of thumb, not laws. The .70 cutoff mostly traces back to Nunnally's classic psychometrics text and has been repeated so often it feels like a theorem. Some context that matters more than the label:

  • Purpose. Exploratory research tolerates lower values. Screening or diagnostic instruments that drive decisions about individuals need much higher.
  • Scale length. Alpha climbs as you add items, even if the average inter-item correlation stays modest. A 3-item scale at .68 and a 30-item scale at .68 mean very different things.
  • Too high can be bad. Values above roughly .95 often mean redundant items, the same question asked five ways. That's longer surveys and tired respondents without extra information. (Our recoded toy example at .96 is a hint that these eight rows are cleaner than real data.)

Assumptions people skip

  1. Essential tau-equivalence. Alpha assumes every item loads equally on the underlying trait. When loadings differ (the usual case, called a congeneric model), alpha tends to underestimate true reliability. McDonald's omega relaxes that assumption and is increasingly reported alongside alpha.
  2. Uncorrelated errors. If two items share similar wording or a method artifact, their errors correlate and alpha is inflated.
  3. Unidimensionality. Alpha measures how much items covary, not whether they share a single factor. Two unrelated subscales, each with many items, can still produce a respectable overall alpha. Check structure with factor analysis, and compute alpha per subscale if the structure is multi-factor.

Mistakes that quietly wreck your result

  • Not reverse-coding negatively worded items (see above).
  • Tiny samples. With a few dozen respondents, alpha is volatile. Report a confidence interval, via a bootstrap or Feldt's F-based approach, instead of a bare point estimate.
  • Mixing constructs in one scale, then reporting a single alpha.
  • Treating alpha as a property of the questionnaire. It's a property of the scores in your sample. A scale that hit .88 in a published validation can come in lower in your population.
  • Handling missing data silently. Listwise deletion, mean imputation, and pairwise methods can each give a different alpha. State what you did.
  • Deleting items purely to chase a higher alpha, at the cost of construct coverage.

Reporting it in APA style

APA 7 drops the leading zero for values that can't exceed 1:

The 5-item study motivation scale showed excellent internal consistency (Cronbach's α = .96, 95% CI [.89, .99], N = 240).

(That CI is illustrative. Report your own computed interval.) If you revised the scale, say which items were removed and report alpha before and after. Report omega too if your reviewers are psychometrically inclined.

Skip the setup: a free calculator

If you don't want to open a notebook for a quick check, I maintain a free Cronbach's Alpha Calculator. You can paste in a respondent-by-item matrix or enter summary statistics (item count, sum of item variances, total variance). It reports raw and standardized alpha, an item-total table with alpha-if-deleted, and the step-by-step working.

A good way to test any reliability tool, mine included: paste in the eight-row matrix from this post. You should get α ≈ .33 for the raw data and α ≈ .96 once item 5 is recoded. If a tool disagrees with the numbers above, check the recoding first, then the variance formula (n vs n − 1).

(I also wrote about confidence intervals for the mean here: PASTE_CI_POST_URL_HERE.)

FAQ

Is a negative alpha possible?
Yes. It means average covariance among items is negative, which almost always signals un-recoded reverse items or items that don't belong together.

What's a good alpha for a short scale?
Short scales mechanically produce lower alpha. For 3 to 4 items, look at the mean inter-item correlation (a range of roughly .15 to .50 is often cited as sensible) alongside alpha, not just the headline value.

Alpha or omega?
If you can fit a factor model, report omega too. Alpha remains the default because it's simple, familiar, and requires nothing but item variances.

Does a high alpha prove my scale is valid?
No. Reliability is necessary but not sufficient for validity.

How many respondents do I need?
There's no single magic number, but very small samples give very wide intervals around alpha. Plan for a few hundred if you want a tight estimate, and always show the CI.


Got a reliability horror story, or an alpha you couldn't reproduce across tools? Drop it in the comments.

Top comments (0)