BEE 4850/5850 · Environmental Data Analysis and Simulation

Is the Surge Rising?

A p-value is how often a world with no trend would produce a slope at least as large as the one in our record. Play against simulated worlds, then decide which cities should pay for protection.

Which Record Is Real?

The San Francisco tide gauge has recorded the water level every hour since 1897. Subtract from each hourly level the average of the fifteen days around it, which removes sea-level rise and the seasons and leaves high tide plus storm surge. The highest of these in each year from 1898 to 2022 gives 125 annual maxima, in metres.

One panel below is the real record. The other 19 are the same 125 values in a random order. If the real record has a trend, its order should give it away. Click the panel you think is real.

A lineup is a hypothesis test (Buja et al. 2009). If the order of the years carried no information (no trend, and nothing shared between neighbouring years), every order would be equally likely, and you would pick the real record by luck 1 time in 20. One correct pick is a p-value of 0.05 against that null. Playing again doesn't give a second, independent test: once you have seen the real record, you can recognize it.

Simulate the Null

What your eye picked up on is hard to describe and harder to repeat. A test replaces it with a number computed the same way every time, and replaces the 19 decoys with as many simulated records as we like. The null model here is the one behind the \(t\)-test: independent Gaussian years. The shuffled records from the lineup return in the next section.

  1. Statistic. The least-squares slope of the record: 0.41 mm per year.
  2. Null model. Each year is an independent Gaussian draw with the record's mean (1.29 m) and standard deviation (0.074 m). There is no trend.
  3. Simulate. Draw a 125-year record from the null model and fit its slope. Repeat.
  4. Compare. Place the observed slope among the simulated ones.
  5. p-value. The share of simulated slopes at least as large as the observed one.
With \(x_i\) the year and \(y_i\) its maximum, \(i = 1, \ldots, n\) and \(n = 125\): \[\hat\beta_1 = \frac{\sum_i (x_i - \bar x)(y_i - \bar y)}{\sum_i (x_i - \bar x)^2}, \qquad y^{*}_i \sim \mathcal{N}(\bar y, s^2) \text{ independently}, \qquad p = \mathbb{P}\left(\hat\beta^{*}_1 \geq \hat\beta_1 \mid \mathcal{H}_0\right) \approx \frac{\#\{k : \hat\beta^{*}_{1,k} \geq \hat\beta_1\}}{N}\] where \(s\) is the record's standard deviation and \(N\) the number of simulated records. The Monte Carlo standard error of the estimate is \(\sqrt{p(1-p)/N}\).

Before you simulate

If there were no trend, how often would a 125-year record show a slope of at least 0.41 mm per year?

Alternative

Latest simulated record

Slopes of the simulated records

The alternative sets the tail. The alternative hypothesis is the trend the question is about. Here it is a rise, which predicts a positive slope, so only simulated slopes at least as large as 0.41 count. If a trend in either direction would count, slopes at least 0.41 from zero on either side count, and p roughly doubles. The tail is chosen from the question before looking at the data: choosing it after seeing where the slope fell would halve p after the fact.

A p-value is computed from data, so it is random too: another century of storms would give another p. The size of the trend is read from the slope, 0.41 mm per year, not from p.

Which Statistic and Which Null?

A named test is a particular choice of statistic and null model. Besides the slope, try the Mann–Kendall statistic S, which adds +1 for each pair of years in which the later year is higher and −1 for each in which it is lower. Pick a statistic and a null model and simulate; the table keeps the p-value of each combination you try.

Statistic
Null model

Null modelSlopeS
Gaussian––
Resampled years––
Shuffled years––
Formula–
\(t\)-test
–
Mann–Kendall

One-sided p-values (a rise).

Two of the combinations also have formulas, in the table's last row. The \(t\)-test is the Gaussian null applied to the \(t\)-statistic, the slope divided by its standard error, worked out with mathematics instead of simulation; with 125 years its p-value is close to the simulated one. The Mann–Kendall test is the shuffled null applied to S, worked out with a Gaussian approximation. The \(t\)-test assumes independent Gaussian years with constant variance; Mann–Kendall assumes only that the years are exchangeable, and its variance formula assumes no two years tie.

\[t = \frac{\hat\beta_1}{\widehat{\text{se}}(\hat\beta_1)} \sim t_{n-2} \text{ under the Gaussian null}, \qquad S = \sum_{i 0\), where the 1 is a continuity correction because \(S\) moves in steps of 2. This record has no ties.

The three nulls give nearly the same p because each keeps the record's spread and treats the years as exchangeable, meaning any year could trade places with any other, and because the slope is a weighted sum of 125 values, so the shape of each null's distribution barely matters. Exchangeable years are a reasonable assumption for these maxima: the correlation between one year's maximum and the next, the lag-1 correlation, is 0.07.

How Much Do Neighbours Matter?

The Pacific Decadal Oscillation (PDO) index summarizes sea-surface temperatures in the North Pacific, in standardized units. Its annual means from 1900 to 2022 have a slope of −0.05 per decade, and the lag-1 correlation between one year's value and the next is 0.52. The PDO has no expected direction, so a trend either way counts.

Find the real PDO record among seven decoys. With the first option the decoys are shuffles of its values. With the second they are simulated records in which neighbouring years are alike, built as described below the lineup.

Decoys

If you can pick the data out of a null's records by something other than a trend, as you can by the PDO's runs, the null is missing a feature of the data, and its p-value reflects that feature as well as any trend. Two nulls keep neighbouring years together:

  • Blocks of years. Cut the record into blocks of consecutive years and shuffle the blocks, keeping each block's order.
  • AR(1), an autoregressive model of order 1. Each simulated year is the previous year times the record's lag-1 correlation \(\rho\), plus independent Gaussian noise. The noise variance, \(s^2(1-\rho^2)\), keeps each year's variance at the record's \(s^2\). The simulated series is centred at zero; adding a constant doesn't change a slope.
\[\text{AR(1)}: \quad y^{*}_t = \rho\, y^{*}_{t-1} + \varepsilon_t, \qquad \varepsilon_t \sim \mathcal{N}\!\left(0,\ s^2(1-\rho^2)\right), \qquad y^{*}_1 \sim \mathcal{N}(0, s^2)\]
Record
Null model

The record and one simulated record

Slopes of the simulated records

For the PDO, shuffling single years gives p of about 0.03, 5-year blocks about 0.15, and an AR(1) null about 0.22. Runs of warm or cool years near one end of the record tilt the fitted line, and a null that breaks the runs apart makes large slopes look rarer than they are. For San Francisco, 5-year blocks move p modestly, from 0.014 to 0.030, both below 0.05, where the PDO's p rose five-fold.

The block length is a modelling choice, and longer is not simply safer. With 15-year blocks only about eight blocks are left to shuffle, and each keeps its own piece of any trend, so the null keeps part of the trend it is meant to rule out. Where the blocks start matters too: each shuffle above draws the first block's length at random, and fixing it instead gives the PDO p-values from 0.11 to 0.19, and San Francisco from 0.012 to 0.050, depending on the length chosen.

Would We Detect a Real Rise?

A p-value is computed from the null model alone. To ask whether the test would detect a rise, simulate records with a known true rise and the record's scatter, and count how often the fitted slope clears the critical value: the slope that only 5% of Gaussian records with no trend and the record's spread exceed, 0.30 mm per year in the course deck's simulation. A slope beyond the critical value is the same as a one-sided p-value below 0.05 under the Gaussian null. The share of records that clear it is the power of the test against that rise, and one minus the power is the Type II error rate.

For a true trend \(b\), record scatter \(\sigma\) and critical value \(c\), the fitted slope is Gaussian with mean \(b\) and standard deviation \(\sigma/\sqrt{\sum_i (x_i - \bar x)^2}\), so \[\text{power}(b) = 1 - \Phi\!\left(\frac{(c - b)\sqrt{\sum_i (x_i - \bar x)^2}}{\sigma}\right).\] The simulation gives the same answer without the formula.

Before you simulate

Give the records a true rise of 5 cm per century (0.5 mm per year). The full 125-year record detects it most of the time. How often would the last 40 years alone detect it?

True trend (mm per year)
0.50
Record

Slopes with and without the true trend

Power against each true trend

Against a rise of 5 cm per century, the 125-year record has power of about 0.86 and the last 40 years about 0.12. A 40-year record that shows no significant trend says little about whether the maxima are rising: it would miss a rise that size nearly nine times in ten. With no true trend, the power equals the test's level, 0.05. The dotted line marks a power of 0.8, a common target when deciding how long a record has to be. Each point on the curves comes from 1,000 simulated records, so the curves wiggle.

Which Cities Should Pay for Protection?

You advise twelve coastal cities. Each city's storm-surge maxima are rising by 5 cm per century with probability 0.3, independently of the others, and otherwise have no trend; you don't know which cities are which. Each city has a record of 40 or 125 years, with equal chance, and the same scatter as San Francisco's. You see its slope and its one-sided p-value from the \(t\)-test.

Protection costs 1 unit and prevents all damage. A city that waits pays nothing if its maxima aren't rising and 4 units if they are. Damages are revealed at the end. Keep the total low.

City 1 of 12

A Thousand Cities

The same question for 1,000 simulated cities, with a fixed rule: a city whose p-value is below a threshold raises an alarm and gets protection. Each mark is a city: circles are rising, squares are not, and filled marks raised an alarm.

Share of cities rising
0.30
Raise an alarm when p is below
0.050
Record length
Damage if a rising city waits
4.0

Cost per city for each threshold

A p-value below 0.05 does not mean a 5% chance that a city's maxima aren't rising. The p-value is the probability of a slope at least this large if there were no rise. The share of alarms that come from cities with no rise also depends on the share of cities that are rising, \(\pi\), and on the power of the test at the threshold \(\alpha\), and the p-value uses neither:

\[\text{share of alarms with no rise} = \frac{(1-\pi)\,\alpha}{(1-\pi)\,\alpha + \pi \times \text{power}}\]

Protection is worth its cost when the chance that a city is rising, given its record, is above 1 in 4: 1 unit against 4. So the cheapest threshold depends on the costs and on how many cities are rising. With three in ten rising and damage four times the cost of protection, the cheapest rule protects cities whose p-values are well above 0.05; with one city in twenty rising, it can be below 0.05.