The usual bootstrapping method doesn't preserve the ordering of time series data, and it is, therefore, unsuitable for trend estimation. In the block bootstrapping approach, we split data into non-overlapping blocks of equal size and use those blocks to generate new samples. In this recipe, we will apply a very naive and easy-to-implement linear model with annual temperature data. The procedure for this recipe is as follows:
Split the data into blocks and generate new data samples.
Fit the data to a line or calculate the first differences of the new data.
Repeat the previous step to build a list of slopes or medians of the first differences.
The imports are as follows:
import dautil as dl import random import matplotlib.pyplot as plt import pandas as pd import numpy as np import seaborn as sns import ch6util from IPython.display import HTML
Define the following function to bootstrap the data:
def shuffle(temp, blocks): random.shuffle(blocks...