Chi-square test#

The chi-square test tests the null hypothesis that a given set of categorical data has the given frequencies.

In [1], bird foraging behavior was investigated in an old-growth forest of Oregon. In the forest, 44% of the canopy volume was Douglas fir, 24% was ponderosa pine, 29% was grand fir, and 3% was western larch. The authors observed the behavior of several species of birds, one of which was the red-breasted nuthatch. They made 189 observations of this species foraging, recording 43 (“23%”) of observations in Douglas fir, 52 (“28%”) in ponderosa pine, 54 (“29%”) in grand fir, and 40 (“21%”) in western larch.

Using a chi-square test, we can test the null hypothesis that the proportions of foraging events are equal to the proportions of canopy volume. The authors of the paper considered a p-value less than 1% to be significant.

Using the above proportions of canopy volume and observed events, we can infer expected frequencies.

import numpy as np
f_exp = np.array([44, 24, 29, 3]) / 100 * 189

The observed frequencies of foraging were:

f_obs = np.array([43, 52, 54, 40])

We can now compare the observed frequencies with the expected frequencies.

from scipy.stats import chisquare
chisquare(f_obs=f_obs, f_exp=f_exp)
Power_divergenceResult(statistic=np.float64(228.23515947653874), pvalue=np.float64(3.3295585338846486e-49))

The p-value is well below the chosen significance level. Hence, the authors considered the difference to be significant and concluded that the relative proportions of foraging events were not the same as the relative proportions of tree canopy volume.

References#