This handout introduces the principles of scientific inference and null hypothesis significance testing (NHST) for both categorical and continuous linguistic data, covering hypothesis formulation, test statistics, sampling distributions, \(p\)-values, Type I/II errors, statistical power and common misinterpretations of significance, with illustrative examples from linguistic research.
Science begins and ends with theory, and statistics acts as the “go-between”. Regardless of the discipline, solid research is characterised by a robust theoretical foundation that gives rise to substantive hypotheses, i.e., theory-driven predictions about a population of interest. From this substantive hypothesis, it should be possible to derive a statistical hypothesis that restates the prediction in more formal/mathematical terms. After checking it against real-world data, researchers can assess whether the data support or contradict their hypothesis, after which they may decide to amend (or even abandon) their theory – or keep it as is.
Null hypothesis significance testing (NHST)
The NHST framework offers researchers a convenient way of testing their theoretical assumptions. This chiefly involves setting up a set of (ideally) falsifiable statistical hypotheses, gathering evidence from the observed data and computing the (in)famous ‘\(p\)-value’ to determine “statistical significance” – a notion that is frequently misinterpreted in scientific studies.
Is this the only way of testing hypotheses?
The answer is a resounding no. Despite its immense popularity, NHST is problematic in many respects and hence subject to heavy criticism (cf. Dienes 2008: 76; Baguley 2012: 143–144). There are other statistical schools that can remedy many of its shortcomings and come with distinct advantages, such as those relying on likelihood-based inference and Bayesian principles. Although these are also becoming increasingly common in linguistics, they are still far less widespread than NHST, especially outside psycholinguistics and phonetics.
\(H_0\) vs. \(H_1\)
Statistical hypotheses always come in pairs: A null hypothesis is accompanied by an alternative hypothesis. They are set up before (!) seeing the data and justified by previous research. Note that these hypotheses “always make a statement about the population” (Casella and Berger 2002: 373).
The null hypothesis\(H_0\) describes the “default state of the world” (James et al. 2021: 555). It typically claims that there is no effect in the population (e.g., no difference between groups or no association between variables).
The alternative hypothesis\(H_1\) (or \(H_a\)) plainly states that \(H_0\) is false, suggesting that there is an effect of some kind.
Categorical data
We are interested in finding out whether the Type of an English genitive (‘s’ vs. ‘of’) depends on Possessor Animacy (‘animate’ vs. ‘inanimate’). Our hypotheses are:
\(H_0:\) Genitive Type and Possessor Animacy are independent.
\(H_1:\) Genitive Type and Possessor Animacy are not independent.
According to a \(\chi^2\)-test of independence, there is a statistically significant association between genitive type and possessor animacy (\(\chi^2(1) = 1453.36\), \(p < 0.001\)).
What does independence really mean?
The core idea is “that the probability distribution of the response variable is the same for each group” (Agresti and Kateri 2022: 177). Assume genitive Type is the dependent variable and Possessor Animacy the independent variable. Then independence would entail that the probabilities of the outcomes of the dependent variable Type = "s" and Type = "of" are not influenced by whether they occur in the groups Possessor Animacy = "animate" or Possessor Animacy = "inanimate".
If we consider two variables at the same time, such as \(X\) and \(Y\), they are said to have marginal probability functions, which we can call \(f_1(\text{Type})\) and \(f_2(\text{Animacy})\) here. If we condition the outcomes of both variables on each other, the following equivalence will hold if the variables are independent:
Thus, the null hypothesis assumes that the probabilities of each combination of values (such as Type and Possessor Animacy), denoted by \(\pi_{ij}\), have the relationship in Equation 1. This can be stated succinctly as
\[
H_0 : \pi_{ij} = P(X = j)P(Y = i),
\tag{2}\]
where \(P(X = j)\) denotes the probability that the random variable \(X\) takes the value \(j\) and \(P(Y = i)\) the probability that the random variable \(Y\) takes the value \(i\).
For illustration, consider the data below:
\(\text{Possessor Animacy}\)
\(\text{animate}\)
\(\text{inanimate}\)
\(\text{Genitive}\)
\(\text{s}\)
\(\pi_{11}\)
\(\pi_{12}\)
\(\text{of}\)
\(\pi_{21}\)
\(\pi_{22}\)
Independence would be given if the following relationships held for each cell:
As part of a phonetic study, we compare the first formant (F1) frequencies of vowels (in Hz) produced by male and female speakers of Apache. We put forward the following hypotheses about the population means:
\(H_0:\) mean F1 frequency of men \(=\) mean F1 frequency of women.
\(H_1:\) mean F1 frequency of men \(\ne\) mean F1 frequency of women.
According to a two-sample \(t\)-test, there is a significant difference between the mean F1 frequencies of male and female speakers of Apache (\(t(112.19) = 2.44\), \(p < 0.05\)).
Test statistics
To facilitate the decision-making process, we proceed to gather statistical evidence from the observed data, that is, the sample. Since NHST primarily revolves around \(H_0\) (and not \(H_1\)!), we need to assess how compatible the data are with \(H_0\). This is done via a test statistic\(T\) that characterises the sample at hand. Agresti & Kateri (2022: 163) describe test statistics as indicators of how strongly a point estimate (e.g., a mean or a proportion) deviates from its expected value under \(H_0\).
There are many possible test statistics out there:
For instance, if the data are discrete and nominal, the \(\chi^2\) statistic summarises the differences between observed and expected frequencies across all cells of a contingency table.
In the case of continuous data, it is common to rely on \(t\) for quantifying the difference between two sample means relative to its standard error.
Other common test statistics include \(z\), \(F\) and many others.
Assuming that \(H_0\) is true, test statistics follow characteristic probability distributions, which are known as sampling distributions (e.g., the \(\chi^2\)-distribution or the \(t\)-distribution). Recall that probability distributions are obtained by assigning probabilities to every outcome of a random variable.
Sampling distributions
A fundamental theoretical insight is that the mean (or sum) of many independent observations is approximately normally distributed, regardless of how the individual observations are distributed (provided their variance is finite). Once standardised, it approaches the standard normal distribution with \(\mu = 0\) and \(\sigma = 1\) as the sample size increases. This proven statement is known as the Central Limit Theorem(Heumann, Schomaker, and Shalabh 2022: 547). If the population standard deviation is unknown and has to be estimated from the sample, the standardised mean follows a Student \(t\) distribution instead (assuming normally distributed data). Its shape is determined by a single parameter \(\nu\), the degrees of freedom: The larger \(\nu\), the closer the \(t\) distribution is to the standard normal distribution.
\(t\) distribution
Show the code
library(ggplot2)# Define the degrees of freedomdf_t <-10# Create a sequence of x valuesx_t <-seq(-4, 4, length.out =1000)# Compute the t-distribution densityy_t <-dt(x_t, df = df_t)# Create a data framet_distribution_data <-data.frame(x = x_t, y = y_t)# Generate the plotggplot(t_distribution_data, aes(x = x, y = y)) +geom_line(color ="steelblue", linewidth =1) +# Line for the density curvelabs(title ="t-Distribution",subtitle ="Probability density function with 10 degrees of freedom",x ="t value",y ="Probability density" ) +theme_minimal() +coord_cartesian(ylim =c(0, 0.4), xlim =c(-4, 4)) +theme(plot.title =element_text(hjust =0.5),axis.title =element_text(size =12) )
The \(\chi^2\) distribution is closely related to the \(t\) distribution, sharing the degrees of freedom parameter \(\nu\). In essence, it is the distribution of a sum of \(\nu\) squared, independent, standard normally distributed random variables, i.e., \(Z_1^2 + Z_2^2 + \dots + Z_\nu^2\). For instance, if the \(x_i\) are normally distributed, the standardised sum of squares \(\sum_{i=1}^n \left(\frac{x_i - \mu}{\sigma}\right)^2\) follows a \(\chi^2\) distribution with \(n\) degrees of freedom.
\(\chi^2\) distribution
Show the code
# Load ggplot2library(ggplot2)# Define the degrees of freedomdf <-2# Create a sequence of x valuesx <-seq(0, 30, length.out =1000)# Compute the chi-squared densityy <-dchisq(x, df = df)# Create a data framechi_squared_data <-data.frame(x = x, y = y)# Generate the plotggplot(chi_squared_data, aes(x = x, y = y)) +geom_line(color ="steelblue", linewidth =1) +# Line for the density curvelabs(title ="Chi-Squared Distribution",subtitle ="Probability density function with 2 degrees of freedom",x ="Chi-squared value",y ="Probability density" ) +theme_minimal() +coord_cartesian(ylim =c(0, 0.5), xlim =c(0, 15)) +theme(plot.title =element_text(hjust =0.5),axis.title =element_text(size =12) )
Statistical significance
The decision whether to reject \(H_0\) is based on the significance probability\(p\) (the ‘\(p\)-value’). Due to the frequency and ferocity with which statistical significance is misinterpreted in the research literature, we will begin by reviewing its technical definition:
“The \(p\)-value is the probability, presuming that \(H_0\) is true, that the test statistic equals the observed value or a value even more extreme in the direction predicted by \(H_a\)” (Agresti and Kateri 2022: 163).
In compact notation, it is equivalent to the conditional probability
This formulation applies to test statistics for which large values count as ‘extreme’, such as \(\chi^2\). For two-sided \(t\)-tests, extreme values lie in both tails of the distribution, so that we consider \(|T| \geq |\text{observed value}|\) instead.
If \(p\) is lower than a pre-defined threshold (typically \(0.05\)), also known as the significance level\(\alpha\), we can reject \(H_0\). However, if \(p \geq \alpha\), this neither justifies rejecting nor accepting the null hypothesis (Baguley 2012: 121): We simply fail to reject it.
What could go wrong? Type I and Type II errors
There is always a chance that our decision is wrong; the four possible constellations are summarised in the table below (cf. Heumann, Schomaker, and Shalabh 2022: 223):
\(H_0\) is true
\(H_0\) is not true
\(H_0\)is not rejected
\(\color{green}{\text{Correct decision}}\)
\(\color{red}{\text{Type II } (\beta)\text{-error}}\)
\(H_0\)is rejected
\(\color{red}{\text{Type I } (\alpha)\text{-error}}\)
\(\color{green}{\text{Correct decision}}\)
For a given sample size and effect size, there is a trade-off between Type I and Type II errors (Agresti and Kateri 2022: 182–186):
If we lower the significance level \(\alpha\), \(P\)(Type I) will decrease and \(P\)(Type II) will increase.
Conversely, increasing \(\alpha\) reduces \(\beta\), but makes Type I errors more likely.
Increasing the sample size is one way of reducing \(\beta\) (and increasing power) without changing \(\alpha\).
Statistical power
It is recommended to compute the power\(1 - P(\text{Type II})\) of a test, i.e., the probability of correctly rejecting \(H_0\) if there is a true effect of a given size. Ideally, this is done before collecting the data in order to determine the required sample size. The pwr package provides a convenient interface:
library(pwr)# w = effect size (Cohen's w; 0.1 = small, 0.3 = medium, 0.5 = large)# df = degrees of freedom# sig.level = significance level alpha# power = 1 - betapwr.chisq.test(w =0.5, df =1, sig.level =0.05, power =0.95)
Chi squared power calculation
w = 0.5
N = 51.97884
df = 1
sig.level = 0.05
power = 0.95
NOTE: N is the number of observations
# We'd need a sample size of N = 52 to detect an effect of size w = 0.5 with alpha = 0.05, beta = 0.05 and 1 degree of freedom (e.g., a simple 2x2 contingency table).
Where does the \(p\)-value come from?
Let’s say that the statistical analysis of two discrete variables \(X\) and \(Y\) has returned a test statistic of \(\chi^2 = 6.5\) for 2 \(df\). In order to compute the corresponding \(p\)-value we need to consult the sampling distribution of this test statistic.
\(\chi^2\) distribution
Show the code
# Load ggplot2library(ggplot2)# Define the degrees of freedomdf <-2# Create a sequence of x valuesx <-seq(0, 30, length.out =1000)# Compute the chi-squared densityy <-dchisq(x, df = df)# Create a data framechi_squared_data <-data.frame(x = x, y = y)# Generate the plotggplot(chi_squared_data, aes(x = x, y = y)) +geom_line(color ="steelblue", linewidth =1) +labs(title ="Chi-Squared Distribution",subtitle ="Probability density function with 2 degrees of freedom",x ="Chi-squared value",y ="Probability density" ) +theme_minimal() +coord_cartesian(ylim =c(0, 0.5), xlim =c(0, 15)) +theme(plot.title =element_text(hjust =0.5),axis.title =element_text(size =12) )
Because the \(\chi^2\) distribution is a continuous probability distribution, it has infinitely many possible \(x\)-values. This also implies that the probability of any single \(x\)-value must be 0.1
1 The proof is given in Heumann et al. (2022: 544).
The sampling distribution thus has a probability density function (PDF), which we will call \(f(x)\), and probabilities can only be obtained for an interval \([a,b]\). The probability that a value \(X\) falls into the interval \(a < X < b\) is then equivalent to the area under the curve between \(a\) and \(b\) (cf. Equation 3).
\[
P(a < X < b) = \int_a^b f(x)dx.
\tag{3}\]
Recall the PDF \(f_{\chi^2}(x)\) of the \(\chi^2\)-distribution with 2 degrees of freedom. The \(p\)-value corresponds to the green area under the curve ranging from \(x = 6.5\) up to \(\infty\), which can be restated formally in Equation 4. This brings us back to the definition of the \(p\)-value: Assuming \(H_0\) is true, it is the probability that the \(\chi^2\) score is equal to 6.5 or higher, i.e., \(P(\chi^2 \geq 6.5)\).
In practice, statistical software computes this integral for us:
pchisq(6.5, df =2, lower.tail =FALSE)
[1] 0.03877421
Since \(p \approx 0.039 < 0.05\), we would reject \(H_0\) at a significance level of \(\alpha = 0.05\).
Practical considerations
Common pitfalls (cf. Agresti & Kateri 2022: 189-190)
Statistical significance is NOT an indication of a causal relationship between the variables of interest (correlation\(\neq\)causation).
\(p\)-values do NOT signify the strength of an effect (\(\neq\) effect size). They only indicate how compatible the data are with \(H_0\).
\(p\)-values are NOT the probability of the null hypothesis being true.
Statistical significance is only a starting point for further scientific inquiry, and by no means the end of it.
Can’t we just compute the probability that our hypothesis is true?
Not with NHST. Recall that the \(p\)-value is computed under the assumption that \(H_0\) is true. It therefore answers the question ‘How surprising would data like ours be if \(H_0\) were true?’, i.e., it is based on \(P(\text{data} \mid H_0)\).
What researchers often want to know, however, is the reverse: ‘How plausible is our hypothesis, given the data?’, i.e., \(P(H \mid \text{data})\). This is the question addressed by Bayesian inference. Using Bayes’ theorem, researchers state how plausible they consider a hypothesis before seeing the data (the prior) and then update this belief in the light of the observed data, which yields the posterior:
Since \(P(\text{data} \mid H_0)\) and \(P(H_0 \mid \text{data})\) are generally not the same, a \(p\)-value of 0.03 does not mean that \(H_0\) has a 3% chance of being true. For an accessible introduction to the Bayesian perspective, see Dienes (2008: Chapter 4).
Exercises
Tier 1
Exercise 1 A hypothesis test has returned a \(p\)-value of 0.03. Which of the following interpretations is correct? Explain briefly why the other options are incorrect.
The probability that \(H_0\) is true is 0.03.
Assuming \(H_0\) is true, the probability of observing a result at least as extreme as the observed one is 0.03.
There is a 97% chance that the alternative hypothesis is true.
Exercise 2 A study reports:
The result was not statistically significant.
Can we conclude there is no effect?
Can we conclude that the null hypothesis is true?
What can we conclude?
Tier 2
Exercise 3 For each of the research questions below, formulate a \(H_0\) and a \(H_1\):
Does the use of progressive aspect depend on text genre?
Do native speakers and learners differ in their average sentence length?
Is word frequency correlated with age of acquisition?
Exercise 4 A researcher conducts a study without planning for statistical power, which turns out to be only 0.20. Interpret what a power of 0.20 means in terms of long-run decision outcomes when \(H_1\) is true. Compare it to a study with a power of 0.80 – how does the reliability of conclusions change?
Tier 3
Exercise 5 Suppose a \(\chi^2\)-test produces a test statistic \(\chi^2 = 8.2\) for degrees of freedom \(df = 3\). Compute the corresponding \(p\)-value and verify that the result corresponds to the shaded tail area under the \(\chi^2\)-distribution. Explain why the integral begins at 8.2 and not at 0.
Hint
Adjust the sample code from the last section (degrees of freedom and observed test statistic) to match the values given in the task:
# Define the degrees of freedomdf <-2# Create a sequence of x valuesx <-seq(0, 30, length.out =1000)# Compute the chi-squared densityy <-dchisq(x, df = df)# Create a data framechi_squared_data <-data.frame(x = x, y = y)# Define the integral for highlightinghighlight_data <-subset(chi_squared_data, x >=6.5& x <=20)# Generate the plotggplot(chi_squared_data, aes(x = x, y = y)) +geom_line(color ="steelblue", linewidth =1) +geom_area(data = highlight_data, aes(x = x, y = y), fill ="darkgreen", alpha =0.5) +# integrallabs(title ="Chi-Squared Distribution",subtitle ="Probability density function with 2 degrees of freedom (y-axis zoomed in on the tail)",x ="Chi-squared value",y ="Probability density" ) +theme_minimal() +coord_cartesian(ylim =c(0, 0.05), xlim =c(0, 30)) +theme(plot.title =element_text(hjust =0.5),axis.title =element_text(size =12) )
References
Agresti, Alan, and Maria Kateri. 2022. Foundations of Statistics for Data Scientists: With r and Python. Boca Raton: CRC Press.
Baguley, Thomas. 2012. Serious Stats: AGuide to AdvancedStatistics for the BehavioralSciences. Houndmills, Basingstoke: Palgrave Macmillan.
Casella, George, and Roger L. Berger. 2002. Statistical Inference. 2nd ed. Pacific Grove, Calif.: Duxbury/Thomson Learning.
Dienes, Zoltán. 2008. Understanding Psychology as a Science: AnIntroduction to Scientific and StatisticalInference. Houndmills: Palgrave Macmillan.
Gries, Stefan Thomas. 2021. Statistics for Linguistics with r: A Practical Introduction. 3rd rev. ed. Berlin; Boston: De Gruyter Mouton.
Heumann, Christian, Michael Schomaker, and Shalabh. 2022. Introduction to Statistics and Data Analysis: With Exercises, Solutions and Applications in r. 2nd ed. Cham: Springer. https://doi.org/10.1007/978-3-031-11833-3.
James, Gareth, Daniela Witten, Trevor Hastie, and Robert Tibshirani. 2021. An Introduction to Statistical Learning: With Applications in r. New York: Springer. https://doi.org/10.1007/978-1-0716-1418-1.