CRONBACH_ALPHA
This function estimates internal consistency reliability across multiple items intended to measure the same latent construct.
For k items with item variances \sigma_i^2 and total score variance \sigma_T^2, Cronbach’s alpha is:
\alpha = \frac{k}{k-1}\left(1 - \frac{\sum_{i=1}^{k}\sigma_i^2}{\sigma_T^2}\right)
Higher values indicate stronger internal consistency among items, subject to assumptions about dimensionality and measurement scale.
Excel Usage
=CRONBACH_ALPHA(data, items, scores, subject, cronbach_nan_policy)
data(list[list], required): Input table as a 2D range with a header row followed by data rows.items(str, optional, default: null): Optional item identifier column for long-format data.scores(str, optional, default: null): Optional score/value column for long-format data.subject(str, optional, default: null): Optional subject identifier column for long-format data.cronbach_nan_policy(str, optional, default: “pairwise”): Missing value handling strategy.
Returns (float): Cronbach’s alpha coefficient.
Example 1: Cronbach alpha from wide-format item matrix
Inputs:
| data | ||
|---|---|---|
| i_one | i_two | i_three |
| 3 | 4 | 3 |
| 4 | 4 | 5 |
| 2 | 3 | 2 |
| 5 | 5 | 4 |
| 4 | 3 | 4 |
Excel formula:
=CRONBACH_ALPHA({"i_one","i_two","i_three";3,4,3;4,4,5;2,3,2;5,5,4;4,3,4})
Expected output:
0.84
Example 2: Pairwise handling with missing cell in wide data
Inputs:
| data | cronbach_nan_policy | ||
|---|---|---|---|
| i_one | i_two | i_three | pairwise |
| 3 | 4 | 3 | |
| 4 | 5 | ||
| 2 | 3 | 2 | |
| 5 | 5 | 4 | |
| 4 | 3 | 4 |
Excel formula:
=CRONBACH_ALPHA({"i_one","i_two","i_three";3,4,3;4,,5;2,3,2;5,5,4;4,3,4}, "pairwise")
Expected output:
0.850103
Example 3: Long-format table using subject, items, and scores
Inputs:
| data | items | scores | subject | ||
|---|---|---|---|---|---|
| subj | item | score | item | score | subj |
| 1 | A | 3 | |||
| 1 | B | 4 | |||
| 1 | C | 3 | |||
| 2 | A | 4 | |||
| 2 | B | 4 | |||
| 2 | C | 5 | |||
| 3 | A | 2 | |||
| 3 | B | 3 | |||
| 3 | C | 2 | |||
| 4 | A | 5 | |||
| 4 | B | 5 | |||
| 4 | C | 4 |
Excel formula:
=CRONBACH_ALPHA({"subj","item","score";1,"A",3;1,"B",4;1,"C",3;2,"A",4;2,"B",4;2,"C",5;3,"A",2;3,"B",3;3,"C",2;4,"A",5;4,"B",5;4,"C",4}, "item", "score", "subj")
Expected output:
0.9
Example 4: Long-format reliability with listwise policy
Inputs:
| data | items | scores | subject | cronbach_nan_policy | ||
|---|---|---|---|---|---|---|
| subj | item | score | item | score | subj | listwise |
| 1 | A | 3 | ||||
| 1 | B | 4 | ||||
| 1 | C | 3 | ||||
| 2 | A | 4 | ||||
| 2 | B | |||||
| 2 | C | 5 | ||||
| 3 | A | 2 | ||||
| 3 | B | 3 | ||||
| 3 | C | 2 | ||||
| 4 | A | 5 | ||||
| 4 | B | 5 | ||||
| 4 | C | 4 |
Excel formula:
=CRONBACH_ALPHA({"subj","item","score";1,"A",3;1,"B",4;1,"C",3;2,"A",4;2,"B",;2,"C",5;3,"A",2;3,"B",3;3,"C",2;4,"A",5;4,"B",5;4,"C",4}, "item", "score", "subj", "listwise")
Expected output:
0.972973
Python Code
import pandas as pd
import pingouin as pg
def cronbach_alpha(data, items=None, scores=None, subject=None, cronbach_nan_policy='pairwise'):
"""
Compute Cronbach's alpha reliability coefficient for a set of items.
See: https://pingouin-stats.org/generated/pingouin.cronbach_alpha.html
This example function is provided as-is without any representation of accuracy.
Args:
data (list[list]): Input table as a 2D range with a header row followed by data rows.
items (str, optional): Optional item identifier column for long-format data. Default is None.
scores (str, optional): Optional score/value column for long-format data. Default is None.
subject (str, optional): Optional subject identifier column for long-format data. Default is None.
cronbach_nan_policy (str, optional): Missing value handling strategy. Valid options: Pairwise, Listwise. Default is 'pairwise'.
Returns:
float: Cronbach's alpha coefficient.
"""
try:
def to2d(value):
return [[value]] if not isinstance(value, list) else value
matrix = to2d(data)
if not isinstance(matrix, list) or len(matrix) < 2 or not all(isinstance(row, list) for row in matrix):
return "Error: Invalid input - data must be a 2D list with header and rows"
headers = [str(col).strip() for col in matrix[0]]
if len(headers) == 0 or any(col == "" for col in headers):
return "Error: Invalid input - header row must contain non-empty column names"
width = len(headers)
records = []
for row in matrix[1:]:
values = list(row)
if len(values) < width:
values = values + [None] * (width - len(values))
elif len(values) > width:
values = values[:width]
records.append(values)
frame = pd.DataFrame(records, columns=headers)
items_arg = None if items is None or str(items).strip() == "" else str(items)
scores_arg = None if scores is None or str(scores).strip() == "" else str(scores)
subject_arg = None if subject is None or str(subject).strip() == "" else str(subject)
if (items_arg is None) != (scores_arg is None) or (items_arg is None) != (subject_arg is None):
return "Error: Invalid input - items, scores, and subject must be provided together for long-format data"
alpha_result = pg.cronbach_alpha(
data=frame,
items=items_arg,
scores=scores_arg,
subject=subject_arg,
nan_policy=str(cronbach_nan_policy),
)
alpha_value = alpha_result[0] if isinstance(alpha_result, (list, tuple)) else alpha_result
return float(alpha_value)
except Exception as e:
return f"Error: {str(e)}"Online Calculator
Input table as a 2D range with a header row followed by data rows.
Optional item identifier column for long-format data.
Optional score/value column for long-format data.
Optional subject identifier column for long-format data.
Missing value handling strategy.