Skip to main content

Recap Statistics

Probability

For equally likely outcomes, the probability of an event \(A\) is the fraction of all possible outcomes (the sample space \(\Omega\)) that belong to \(A\):

\[P(A) = \frac{\text{Count of } A}{\text{Count of } \Omega}\]

Example: The probability of getting a six when rolling a die once is \(P(6) = 1/6\).

If \(A\) and \(B\) are mutually exclusive, the probability that \(A\) or \(B\) occurs is the sum of their individual probabilities:

\[P(A \cup B) = P(A) + P(B)\]

Example: The probability of getting a six or a three when rolling a die once is \(P(6 \cup 3) = P(6) + P(3) = 1/6 + 1/6 = 1/3\).

The joint probability that \(A\) and \(B\) both occur is, if the events are independent, the product of their individual probabilities:

\[P(A \cap B) = P(A) \cdot P(B)\]

Example: Let \(6_1\) and \(6_2\) be a six on the first and on the second roll of a die. The probability of getting two sixes is \(P(6_1 \cap 6_2) = P(6_1) \cdot P(6_2) = 1/6 \cdot 1/6 = 1/36\).

Conditional probability

So far, we have looked at probabilities of single events and at how to combine them. Often, however, we already know something about the outcome, and this knowledge changes how likely other events are. A conditional probability is the probability of an event given that another event has occurred.

We use the following notation for two events \(A\) and \(B\):

  • \(P(A)\): the probability of \(A\)
  • \(P(A \cap B)\): the joint probability that \(A\) and \(B\) occur
  • \(P(A|B)\): the conditional probability of \(A\) given \(B\), read as “the probability of \(A\) given \(B\)”. The vertical bar means “given” or “conditional on”.

The conditional probability of \(A\) given \(B\) is the joint probability of \(A\) and \(B\), divided by the probability of \(B\):

\[P(A|B) = \frac{P(A \cap B)}{P(B)}\]

Multiplying both sides by \(P(B)\) gives the product rule for joint probabilities:

\[P(A \cap B) = P(A|B) \cdot P(B)\]

The joint probability does not depend on the order of the two events, \(P(A \cap B) = P(B \cap A)\). We can therefore just as well condition on \(A\) instead of \(B\), and write the product rule in two ways:

\[P(A \cap B) = P(A|B) \cdot P(B) = P(B|A) \cdot P(A)\]

The product rule holds for any two events:

  • If \(A\) and \(B\) are dependent, knowing \(B\) changes the probability of \(A\), so \(P(A|B) \neq P(A)\). To calculate the joint probability, we need the conditional probability \(P(A|B)\).
  • If \(A\) and \(B\) are independent, knowing \(B\) tells us nothing about \(A\), so \(P(A|B) = P(A)\). The rule then reduces to \(P(A \cap B) = P(A) \cdot P(B)\), the multiplication rule for independent events above.

Note that \(P(A|B)\) and \(P(B|A)\) are generally not the same. How the two are related is the subject of Bayes’ rule.

Note

It helps to picture events as sets of outcomes: knowing that \(B\) has occurred restricts the possible outcomes to those in \(B\), and \(P(A|B)\) is the share of these outcomes that also belongs to \(A\). In this picture, and in the urn example below, \(A\) and \(B\) are interchangeable: both are simply events, and we can condition either one on the other. In Bayesian inference, the two will play different roles.

Urn example

Assume we have 30 balls: 10 made of metal (\(M\)) and 20 of wood (\(W\)). We paint each ball either red (\(R\)) or yellow (\(Y\)), but not evenly across the materials: we paint 6 of the 10 metal balls red, but only 6 of the 20 wooden balls. Then we put all balls into an urn. Color and material are thus dependent: we choose the color of each ball depending on its material.

We can represent all possible outcomes in a contingency table:

Red Yellow Sum
Metal 6 4 10
Wood 6 14 20
Sum 12 18 30

Dividing the counts by the total number of balls gives the joint probabilities (inner cells) and the marginal probabilities (margins):

Red Yellow Sum
Metal \(P(R \cap M)=\frac{6}{30}\) \(P(Y \cap M)=\frac{4}{30}\) \(P(M)=\frac{10}{30}\)
Wood \(P(R \cap W)=\frac{6}{30}\) \(P(Y \cap W)=\frac{14}{30}\) \(P(W)=\frac{20}{30}\)
Sum \(P(R)=\frac{12}{30}\) \(P(Y)=\frac{18}{30}\)

For example, the probability of drawing a red ball is \(P(R) = \frac{12}{30} = 0.4\), and the probability of drawing a red metal ball is \(P(R \cap M) = \frac{6}{30} = 0.2\).

Conditional probability. What is the probability that a metal ball is red? We know the answer from how we painted the balls: we painted 6 of the 10 metal balls red, so the probability is \(\frac{6}{10} = 0.6\). To see that the definition of conditional probability works, we can also calculate it from the joint and marginal probabilities in the table:

\[P(R|M) = \frac{P(R \cap M)}{P(M)} = \frac{\frac{6}{30}}{\frac{10}{30}} = 0.6\]

For a wooden ball, the probability of red is

\[P(R|W) = \frac{P(R \cap W)}{P(W)} = \frac{\frac{6}{30}}{\frac{20}{30}} = 0.3\]

Both differ from \(P(R) = 0.4\), which reflects the dependence between color and material.

Joint probability. Because color and material are dependent, we cannot calculate the joint probability by multiplying the marginal probabilities: \(P(R) \cdot P(M) = 0.4 \cdot \frac{1}{3} = \frac{4}{30}\) is too low, because it assumes \(P(R|M) = P(R)\). The product rule gives the correct value. It does not need the table: we know \(P(M) = \frac{1}{3}\) from the number of metal balls and \(P(R|M) = 0.6\) from how we painted them.

\[P(R \cap M) = P(R|M) \cdot P(M) = 0.6 \cdot \frac{1}{3} = \frac{6}{30}\]

Total probability. The probability of drawing a red ball does not need the table either. A red ball is either metal or wood, so \(P(R)\) is the sum of the two joint probabilities, each calculated with the product rule:

\[ \begin{aligned} P(R) &= P(R \cap M) + P(R \cap W) = P(R|M) \cdot P(M) + P(R|W) \cdot P(W) \\ &= 0.6 \cdot \frac{1}{3} + 0.3 \cdot \frac{2}{3} = 0.4 \end{aligned} \]

This works because the materials are mutually exclusive and one of them must occur: every ball is either metal or wood.

Reverse conditional probability. What is the probability that a red ball is made of metal? Of the 12 red balls, 6 are metal, so

\[P(M|R) = \frac{P(R \cap M)}{P(R)} = \frac{\frac{6}{30}}{\frac{12}{30}} = 0.5\]

This differs from \(P(R|M) = 0.6\), the probability that a metal ball is red. The two conditional probabilities answer different questions: \(P(R|M)\) refers to the 10 metal balls, \(P(M|R)\) to the 12 red balls. Bayes’ rule gives \(P(M|R)\) from \(P(R|M)\) without the table (see From conditional probability to Bayes’ rule).

Observations

Random variables

A random variable assigns a numerical value to each outcome of a random process. Its possible values have probabilities or, for continuous variables, probabilities over intervals.

Example: The random variable ‘age’ can take any value between 0 and \(\infty\), though picking a random person, it is more likely she is 35 than 110.

Sample

Simply speaking, a sample consists of a set of realisations of a random variable. The size of a sample is termed \(n\).

Example: If I pick one person (\(n = 1\)) in this class, a realisation of the random variable ‘age’ might be \(S = \{26\}\). If I pick three persons (\(n = 3\)), the realizations might be \(S = \{22, 28, 32\}\).

Sampling

Drawing a sample from a population requires a defined procedure:

  • Simple random sampling
  • Systematic sampling
  • Stratified sampling
  • Clustered sampling

All those procedures have in common that each data point has a well-defined probability of being included in the sample. We then speak of a probability sampling design. There are also non-probability sampling designs.

Pinewood data

Suppose, we randomly selected 150 trees in the fictitious land of Pinewood. Our sample then has size \(n\)=150. The sampling units are trees. And for each tree (sampling unit) we collect some data/variables. For example, for each tree we measured the diameter at breast height (DBH) in cm.

View up into the crowns of tall pine trees against a blue sky

Descriptive statistics

Descriptive statistics summarize the characteristics of a dataset like the central location around which the majority of the observations cluster (e.g., mean and median) and the spread of the observations (e.g., variance and standard deviation). Below are the summary statistics of the Pinewood tree sample (Table 1).

Table 1: Descriptive statistics of the tree dataset.
Statistic Value
Mean 56.5
Median 57.0
Mode 67.0
Variance 255.4
Standard deviation 16.0
Coefficient of variation 0.3
Interquartile range 21.0
Skewness 0.1
Kurtosis 2.6

We can inspect the distribution of tree DBH in Pinewood by means of a histogram (Fig. 1). When drawing a histogram the choice of binning can have a substantial effect on the resulting visualization. There are a number of formulas for estimating meaningful width or number of bins. For example, the number of bins \(k\) might be estimated with Sturges’ rule: \(k=1+\log_{2}(n) = 1+\log_{2}(150) = 9\).

Fig. 1 Frequency distribution of trees collected in Pinewood forest.

From frequency to probability

The frequency distribution of the tree sample tells us which DBH classes are more frequent and which are rare. The DBH classes are here represented by the bins in the histogram (Fig. 1). If we added a new tree to our sample, it is more likely that it falls in the frequent DBH classes (bins) than in the rare classes. Thus, we can infer from the frequency distribution of the sample the probability that a tree in Pinewood has a certain DBH value. The notion that we infer from the frequency distribution of a sample the probability of an outcome/event in the underlying population is the basis of a many statistical methods.

Statistical inference is the process of using a sample to infer the properties of a population.

Figure 2 below shows a histogram of the absolute frequency (left) and the relative frequency (middle). We can use the relative frequency (proportions) to estimate the probability of a random tree in the Pinewood forest (the population) to fall into that bin, i.e., the diameter range described by that bin. The tallest bin has 35 observations (out of 150). So, the proportion of trees in that bin is \(0.23\) (\(\frac{35}{150}\)). Hence, we estimate the probability that a tree is in that bin’s diameter range to be 0.23.

Figure 2. Frequency, proportions, and density distribution of trees.

The histogram is an effective tool for visualizing distributions of samples but too crude for estimating probabilities. A better way for estimating the probability distribution of a population is provided by the concept of density. The density concept describes the probability distribution of a population as a continuous function: the probability density function (pdf). Since there are an infinite number of real numbers infinitely close on that function, we cannot estimate the probability of a single point \(x\) falling onto that function. For a continuous random variable, the probability at any single point is zero, i.e., \(P(X=x)=0\). However, we can estimate the probability that \(X\) falls into an interval around \(x\).

To illustrate the density concept, we can turn our frequency histogram into a density histogram (Figure 2). Recall that the tree proportion of the tallest bin was \(0.23\). Since the width of the bin is 10 \(cm\), the density is \(0.023\). Conversely, the area in that bin is \(0.023 \times 10 =0.23\). The area under the density function described by an interval \((a,b)\) is the probability that a tree \(x\) falls into that interval: \(P(a < X < b)\). Thus, the area under the entire curve sums to 1.

The density histogram is illustrative but it is still crude and blocky. For continuous variables, we’d expect a smoother probability distribution function (at least for large populations). The histogram is crude, because it is based on a comparably small sample which may not include all values of the population. For example, we did not measure a tree with a DBH of 24 and 83, but it is likely that such trees exist in the population. A smoother density estimate can be obtained using kernel density methods (red line, Figure 2). But, typically we use well-known probability distributions to estimate the density distribution of a population.

Probability distributions

Probability distributions describe the probabilities of outcomes of a random variable. Continuous distributions are described by probability density functions (pdfs); discrete distributions are described by probability mass functions (pmfs). For a continuous distribution:

  • The pdf is nonnegative and its total area is 1
  • The integral of the pdf between \(a\) and \(b\) is \(P(a < X < b)\)
  • The cumulative distribution function (cdf) gives \(P(X \leq x)\); for continuous variables it is the integral of the pdf up to \(x\)

The most important distributions are:

  • Normal distribution
  • Binomial distribution
  • Poisson distribution
  • Log-normal distribution
  • t-distribution
  • F-distribution

Though there are many more used in our field…

To learn how to work with these distribution functions in R, see Probability distributions in R.

Normal distribution

The normal (or Gaussian) distribution is the most widely used distribution for continuous variables. It is symmetric and bell-shaped around its mean \(\mu\), and its standard deviation \(\sigma\) sets the spread: about 68% of values lie within one standard deviation of the mean, and about 95% within two. Many variables are approximately normally distributed, e.g., tree heights or measurement errors, because they result from many small, independent effects that add up. For the same reason, means of samples tend to be normally distributed even if the variable itself is not (central limit theorem). Many statistical methods, such as linear regression and the t-test, assume normally distributed data or errors. The normal distribution with \(\mu = 0\) and \(\sigma = 1\) is called the standard normal distribution.

\[ N(x) = P(X=x \vert \mu, \sigma) = \frac{1}{\sigma \sqrt{2\pi}}e^{\frac{-(x-\mu)^2}{2*\sigma^2}} \]

Parameter of the normal distribution:

  • Domain: \(x \in \mathbb{R} = (- \infty,\infty)\)
  • Mean: \(\mu\)
  • Variance: \(\sigma^2\)

Binomial distribution

The binomial distribution describes the number of successes \(k\) in \(n\) independent trials, where each trial has only two possible outcomes (success or failure) and the same probability of success \(p\). Typical examples are heads in a series of coin flips, the number of plots in which a species is present, or the number of seedlings that survive. For example, if each of 40 seedlings survives with probability \(p = 0.7\), the binomial distribution gives the probability that exactly \(k\) of them survive. The binomial coefficient \(\begin{pmatrix} n \\ k \end{pmatrix}\) counts the number of ways in which \(k\) successes can be arranged among the \(n\) trials.

\[ Binom(k) = P(X=k \mid p,n) = \begin{pmatrix} n \\ k \end{pmatrix} p^{k}(1-p)^{n-k} \]

Parameter of the binomial distribution:

  • Domain: \(k \in \mathbb{N}_{0} = \{0,1,2,3,...\}\)
  • Mean: \(np\)
  • Variance: \(np(1-p)\)

Poisson distribution

The Poisson distribution describes the number of events \(k\) that occur in a fixed interval of time or space, when events occur independently of each other and at a constant average rate \(\lambda\). Typical examples are the number of trees in a plot, the number of birds counted at a point during ten minutes, or the number of storms per year. Unlike the binomial distribution, there is no fixed number of trials, so the counts have no upper limit. The single parameter \(\lambda\) is both the mean and the variance: the higher the average count, the more the counts vary.

\[ Pois(k) = P(X=k \mid \lambda) = \frac{\lambda^{k}e^{-\lambda}}{k!} \]

Parameter of the poisson distribution:

  • Domain: \(k \in \mathbb{N}_{0} = \{0,1,2,3,...\}\)
  • Mean: \(\lambda\)
  • Variance: \(\lambda\)

Log-normal distribution

A variable is log-normally distributed if its logarithm is normally distributed: if \(\ln(X) \sim N(\mu, \sigma)\), then \(X\) follows a log-normal distribution. It describes continuous variables that are strictly positive and right-skewed, i.e., most values are small, with a long tail of large values. Typical examples are tree biomass, species abundances, or concentrations of pollutants. Such variables often arise when many factors act multiplicatively rather than additively, e.g., in growth processes. Note that \(\mu\) and \(\sigma\) are the mean and standard deviation of \(\ln(X)\), not of \(X\) itself.

\[ f(x) = \frac{1}{x \sigma \sqrt{2\pi}}e^{-\frac{(\ln x-\mu)^2}{2\sigma^2}}, \quad x>0 \]

Parameter of the log-normal distribution:

  • Domain: \(x \in \mathbb{R}_{0}^{+} = (0,\infty)\)
  • Mean: \(e^{\mu+\sigma^{2}/2}\)
  • Variance: \((e^{\sigma^{2}}-1)e^{2\mu+\sigma^{2}}\)

t-distribution

The t-distribution (or Student’s t-distribution) is symmetric and bell-shaped like the standard normal distribution, but has heavier tails. It describes the distribution of a sample mean, standardized with the standard deviation estimated from the sample instead of the unknown true standard deviation. The extra uncertainty from estimating the standard deviation makes extreme values more likely, especially for small samples. The shape depends on the degrees of freedom \(v\), which grow with the sample size. As \(v\) increases, the t-distribution approaches the standard normal distribution. It is the basis of the t-test and of confidence intervals for means.

\[ f(x) = \frac{\Gamma(\frac{v+1}{2})}{\sqrt{v\pi}\,\Gamma(\frac{v}{2})}\left(1+\frac{x^{2}}{v}\right)^{-\frac{v+1}{2}} \]

where \(v\) is the degrees of freedom and \(\Gamma\) is the gamma function.

F-distribution

The F-distribution describes the ratio of two variances, each estimated from a sample of a normally distributed population with the same true variance. Since variances are positive, it is defined only for positive values and is right-skewed. Its shape depends on two degrees of freedom, \(v_1\) for the numerator and \(v_2\) for the denominator. If both variances are equal, their ratio is close to 1, and large ratios become unlikely. It is the basis of the F-test and of the analysis of variance (ANOVA).

\[ f(x) = \frac{1}{xB(\frac{v_1}{2},\frac{v_2}{2})}\left(\frac{v_1x}{v_1x+v_2}\right)^{v_1/2}\left(\frac{v_2}{v_1x+v_2}\right)^{v_2/2}, \quad x>0 \]

Density estimation

Commonly, we use one of the known parametric distributions to estimate the probability distribution of a population. We do not know the true probability distribution function (\(pdf\)) of the population. We can only make an educated guess by inspecting histograms of the sample and based on experience. We must also keep in mind that \(pdf\)’s are models with which we describe populations. They are not intrinsic properties of populations. We may assume a population can be described with a normal distribution, but it is not a physical explanation.

Once we selected a distribution, we need to find the parameters of that distribution. We do not know the parameters, but we might estimate them from our sample. For example, assuming a process is normally distributed, we can estimate the parameter \(\mu\) and \(\sigma\) from the sample, i.e., be substituting \(\mu\) with the sample mean and \(\sigma\) with the sample standard deviation.

Going back to Pinewood, the normal distribution seems an appropriate choice to describe the diameter distribution. The estimated parameters (denoted by the hat symbol ^) are taken from the sample mean and standard deviation:

\[\hat{\mu} = \overline{x} = 56.5\]

\[\hat{\sigma} = s = 16\]

We can plot the estimated normal \(pdf\) on top of the sample distribution, and we can also plot the cumulative density function (\(cdf\)). We can then grab from the \(cdf\), the probability that a tree has a DBH of up to \(x\), i.e., \(P(X\leq x)\). For example, there is a 0.34 probability that a tree in Pinewood is less than or equal to 50 cm.

Sampling distribution

We just used a sample (of trees) to estimate the parameters \(\hat{\mu}\) and \(\hat{\sigma}\) of the probability density distribution of the tree population in Pinewood. Since a sample usually represents a fraction of the population, our estimates have uncertainties associated with them. We can illustrate this using the following theoretical construct: If we repeated the sampling, we would obtain a different estimate every time we collected a new sample. Let’s assume we repeatedly sampled 150 trees 5 times, 100 times, and 1000 times, respectively. We would get 5, 100, and 1000 sample means, respectively. The next figure shows the distribution of these sample means (NOT the distribution of individual trees). Such a distribution is called the sampling distribution (of the mean diameter). The more often we repeat the sampling the more closely the distribution of the means resembles a normal distribution (Central Limit Theorem). Hence, we can describe the sampling distribution itself with a normal distribution, with a mean and a standard deviation.

A sampling distribution is a probability distribution of a statistic that is obtained through repeated sampling of a specific population.

Usually, we do not and cannot repeat sampling. Then, why all this? The sampling distribution is an important concept that we can use to test if an estimated parameter is significantly different from some other expected value. The sampling distribution recognizes that there is in fact a range of possible outcomes for a parameter. In other words, the precision of our estimate is nonzero.

Sampling variance

Concept

The standard deviation of a sampling distribution describes the precision of an estimate; its square is the sampling variance. For the Pinewood forest, the mean and standard deviation of the sampling distribution of the mean were \(\bar{\hat{\mu}}=\) 54.95 and \(\sigma_{\hat{\mu}}=\) 1.27, respectively (see above figure with 1000 repeated samples). Recall with a normal distribution, about 68% and 95% of observations fall within 1 and 2 standard deviations of the mean, respectively. Thus, if we repeated the sampling, about 95% of sample means would fall between 52.41 and 57.49 cm, assuming the sampling distribution is approximately normal.

It is important to understand that we do not know the location of the true parameter, here the population mean. So, we cannot say how close our estimate is to the true value. We can describe the variability of our estimate across repeated samples. A precise estimate with a low sampling variance is not necessarily an accurate estimate. If the sample is biased, the true mean may lie outside the sampling distribution. Typically, we can reduce or eliminate bias through the choice of sampling and the choice of estimators. In Pinewood, we employed random sampling. The sample mean is an unbiased estimator of the population mean when the population has a finite mean; normality is not required.

Standard error

The standard error (\(SE\)) of a statistic (usually an estimate of a parameter) is the standard deviation of its sampling distribution or an estimate of that standard deviation. For the fictitious Pinewood forest, we already estimated the standard error by sampling the forest repeatedly 1000 times (\(SE=\sigma_{\hat{\mu}}=\) 1.27).

In practice, repeated sampling is not an option. However, the variation in sampling means is linked to the (population) variance and the sample size. So, usually, we infer the SE from the sample variance (standard deviation) and sample size using the following formula:

\[SE = \frac{s}{\sqrt{n}}\]

where \(s\) denotes the standard deviation of the tree sample (not! the sampling distribution) and \(n\) denotes the sample size. Plugging in the corresponding values of the Pinewood sample, we get:

\[SE = \frac{15.98}{\sqrt{150}} = 1.3\]

…which is pretty close to our previous SE estimate of 1.27 from repeated sampling. Note, increasing sample size increases precision, independent of the population size!

Confidence interval

The confidence interval (CI) provides a means to obtain a range of possible estimates based on a specified level of confidence. Note, the confidence interval does not describe the variability in the unknown parameter. Rather, it reflects the amount of random error in the sample. More specifically, a 95% confidence interval means, if we were to take 100 different samples and compute a 95% confidence interval for each sample, then approximately 95 of the 100 confidence intervals contain the true mean value (\(\mu\)).

In practice, we select one random sample and generate one confidence interval, which may or may not contain the true mean. We cannot say that the population mean has a 95% probability of being included in this one interval. We can say that we are 95% confident that our interval includes the population mean. The former (false) statement implies that the confidence interval is fixed and the population mean is variable. In fact, it is the other way around: the unknown population parameter is fixed and the confidence interval expresses uncertainty in the interval due to sampling.

For a sufficiently large sample, the sampling distribution of the sample mean is approximately normal by the central limit theorem. When the population standard deviation is unknown and estimated by the sample standard deviation, use a t critical value for a one-sample confidence interval:

\[CI_{95\%} = \overline{x} \pm t_{n-1,0.975} \times SE\]

with:

\(t_{n-1,0.975}\) denotes the 97.5th percentile of a t-distribution with \(n-1\) degrees of freedom. For large \(n\), this is close to 1.96, the 97.5th percentile of the standard normal distribution.

For our example, the 95% confidence interval is:

\[CI_{95\%} = 56.5 \pm t_{149,0.975} \times 1.3 = [54, 59.1]\]

Hence, the 95% confidence interval for mean DBH in Pinewood ranges from 54 to 59.1 cm.

Null hypothesis significance testing

Comparing samples

Suppose we have sampled another 150 trees in another forest. We can compare both samples using boxplots.

Null hypothesis

We might ask following question: Are the mean DBH values the same among both forests?

To test this, we formulate a precise null hypothesis \(H_{0}\): The mean DBH is equal among both samples, that is \[\overline{x}_{sp1} = \overline{x}_{sp2}\]

The principal idea behind NHST is to assess how likely our observed result, or one more extreme, would be if \(H_{0}\) were true. A sufficiently small p-value provides evidence against \(H_{0}\), but does not prove it false.

t-test

The NHST for two means is called a t-test (or Student’s t-test). The basic idea behind the t-test is that the difference between two sample means would be exact zero if they were the same. Hence, under the assumption of \(H_{0}\), a large difference is very unlikely. The t-test assumes that the samples are normally distributed and that the variances of the two samples are equal.

As measure of difference in sample means, which also incorporates the standard deviation, we make use of the empirical t-value:

\[t = \sqrt{\frac{n_{sp1}*n_{sp2}}{n_{sp1}+n_{sp2}}}*\frac{\overline{x}_{sp1}-\overline{x}_{sp2}}{S}\]

with \(\overline{x}\) being the sample means, \(n\) the sample size, and \(S\) the weighted paired standard deviation defined as:

\[S = \sqrt{\frac{(n_{sp1}-1)*s_{sp1}^{2}+(n_{sp2}-1)*s_{sp2}^{2}}{n_{sp1}+n_{sp2}-2}}\]

Under \(H_0\), the t-statistic follows a t-distribution with \(v=n_{sp1}+n_{sp2}-2\) degrees of freedom, assuming independent samples and equal population variances.

Lets calculate the t-value, degrees of freedom, and p-value for our example:

The sample means were 55.5 cm and 49.3 cm, respectively. Entering both in the equation for the t-value yields approximately \(t = 3.6\), with 298 degrees of freedom. For a two-sided test, the p-value is twice the upper-tail probability beyond \(|t|\), approximately \(p=0.0004\).

Hence, the difference in means we observed in our samples is very unlikely under the assumption of \(H_{0}\) being true. We thus might safely reject \(H_{0}\) and conclude that the mean DBH values are significantly different between both samples.

F-Test

The F-test aims at testing the difference in the variances between two samples. Like the t-test, the F-test assumes that the samples are normally distributed. The null hypothesis \(H_{0}\) is: The sample variances are equal \(s^{2}_{1} = s^{2}_{2}\).

The test statistic is the F-value, calculated as the ratio of the sample variances:

\[F = \frac{s_{sp2}^{2}}{s_{sp1}^{2}}.\]

Assuming that \(H_{0}\) is true, the F-value follows the F-distribution with two parameters:

\(v_{sp1}=n_{sp1}-1\) and \(v_{sp2}=n_{sp2}-1\).

The sample standard deviations in our example were 15.7 and 14.3, respectively. The ratio of the sample variances is approximately \(F=(14.3/15.7)^2=0.83\), with 149 degrees of freedom for both samples. For a two-sided test, the p-value is twice the smaller tail probability, approximately \(p=0.26\).

This result indicates that the observed variance ratio is not unusual under \(H_{0}\). We fail to reject \(H_{0}\); this is not evidence that the variances are equal.

p-value

The p-value is the most loved and hated value in science. Whole scientific disciplines build upon the p-value in drawing their conclusions from data, most often taking an arbitrary threshold of \(p<0.05\) as indication to reject \(H_{0}\).

Even though the p-value has a clear definition (\(P(D|H_{0})\)), it is very often misinterpreted. Here are the common pitfalls:

  • The p-value does NOT tell you anything about the probability of the hypothesis given your data (\(P(H_{0}|D)\))
  • The p-value is not a measure of effect size, that is it does NOT tell you anything about the strength of a difference
  • There is NO mathematical proof behind thresholds indicating significance (such as \(p<0.05\))
  • A smaller p-value is NO indication that a difference is more important than one with a larger p-value

If you’re interested in the misuse of p-values, please read Baker (2016).

Example of p-value misuse:

We sampled Nitrate concentrations in two catchments:

Both samples are taken from intensive measurement sites, with \(n =\) 100,000 and a sampling error of 0.3 \(mg L^{-1}\). Do you think the difference in Nitrate concentration is substantial?

Calculating the p-value we get \(p < 0.000001\), indicating a highly significant difference. The difference in means, however, is only 0.5 \(mg L^{-1}\), which is close to the measurement error.

Correlation

Scatterplots

With our first sample, we also measured tree height:

To quantify the strength of the relationship between DBH and height we make use of correlation analysis.

Correlation coefficient

The most commonly used correlation coefficient, the Pearson correlation coefficient, is defined as:

\[r_{xy} = \frac{Cov(x,y)}{\sigma(x) \sigma(y)} = \frac{\frac{1}{n}\sum_{i=1}^{n}(x_{i}-\overline{x})(y_{i}-\overline{y})}{\sqrt{\frac{1}{n} \sum_{i=1}^{n}(x_{i}-\overline{x})^2}*\sqrt{\frac{1}{n}\sum_{i=1}^{n}(y_{i}-\overline{y})^2}}\]

and measures the strength and direction of a linear association between \(X\) and \(Y\). It ranges from \(-1\) to \(+1\), where \(-1\) indicates a perfect negative linear association, values near zero indicate little linear association, and \(+1\) indicates a perfect positive linear association.

Calculating the Pearson correlation coefficient for our examples yields \(r_{xy}=0.8\), which indicates a strong positive relationship between DBH and height.

For ordinal data or when a rank-based measure is more appropriate, alternatives include Spearman’s rank correlation and Kendall’s tau.

References

Baker, M., 2016. Statisticians issue warning over misuse of P values. Nature 531, 151. https://doi.org/10.1038/nature.2016.19503