Presentation is loading. Please wait.

Presentation is loading. Please wait.

Early Warning Signals Workshop Chris Boulton

Similar presentations


Presentation on theme: "Early Warning Signals Workshop Chris Boulton"— Presentation transcript:

1 Early Warning Signals Workshop Chris Boulton C.A.Boulton@exeter.ac.uk

2 Overview Creating a time series which exhibits a tipping point. Testing generic indicators on this time series (AR(1) and variance). Using the Early Warning Signals toolbox created by Vasilis Dakos.

3 Setting Up R Once R is open, you need to open a new script file Click File -> New Script This should open a new window where you can create a script full of commands.

4 Creating the Tipping Point Change in x (time series) is dependent on a potential U of the system. This U contains m which changes over time. When m, reaches critical value μ, system reaches tipping point.

5 Creating the Tipping Point In R, you can use either = or <- to assign values to variables. Time runs from 1 to 1000 in steps of 2. This sets up the value for μ and m which is going to reach the critical value at time t=900.

6 Creating the Tipping Point Highlight the lines typed out in the script and press Crtl+R to copy and paste them into the console. In the console you can type a variable out to see its value.

7 Creating the Tipping Point We need to create an array to store time series x. These lines repeat NA a number of times equal to the length of t (500). Then assigns the first value to -1 as this is near the equilibrium of the state which will lose stability.

8 Creating the Tipping Point Now we loop through using a forward Euler scheme, with a time step of ½ (not to be confused with jumping up in steps of 2 when creating t. Add a noise term on, rnorm is a random-normal value with mean=0 and sd=1. Also note we are using –U not U.

9 Creating the Tipping Point Now we have a time series for x which we can plot it

10 Preparing for Using EWS Now we have a time series which exhibits a tipping point and we want to use EWS on it. We only want to use information prior to the tipping point in our analysis. Can work out where tipping point is from graph and then checking values individually.

11 Preparing for Using EWS We cut and check our time series now doesnt include a tip. Note that x[1:a] will select values 1 to a of x.

12 Preparing for Using EWS We want to know the length l of our time series for the analysis. To start with we will chose a window length (WL) equal to half this (floor function rounds number down) We also use a Kernal smoother with a bandwidth (BW) equal to 30.

13 Using AR(1) Coefficient Estimation We need to detrend the time series with the Kernal smoother (ksmooth). ksmooth takes x and y values, a bandwidth and points to calculate the smoothing function on (supplied in this order in the code). We also need to create an array to store our AR(1) estimation over time. This will have length equal to l-wl+1.

14 Using AR(1) Coefficient Estimation Now we use the sliding window to test AR(1) over time. We do the analysis in a for loop which moves the sliding window up once each time. ar.ols fits a model of the form x(t+1) = a*x(t) + e. a is an object called ar embedded in arfit which is found with arfit$ar.

15 Plotting AR(1) We can now plot our AR(1) coefficient estimation. Plotting at the end of your window length makes sense for early warning. Knowing the plotting commands is not essential.

16 Using Variance We can also use the same for loop to look how variance changes on a sliding window length. This is more simple as we do not need to use the ar.ols model fit before. It also has less inputs (i.e. no aic=FALSE or order.max=1).

17 Plotting AR(1) and Variance We can now plot both AR(1) and variance indicators together.

18 Kendall Tau Correlation Coefficient We now want to know how strong the trends in our indicators are. This is done with Kendall Tau Correlation Coefficient which measures tendency. We can load a package which calculates this for us called Kendall (may need to use install.packages line).

19 Kendall Tau Correlation Coefficient Tau measures the number of concordant pairs (both x and y greater or both less than their previous values) against the number of discordant (where this does not hold), over all pairs. We treat one variable as time which is always increasing to measure tendency.

20 Early Warning Signals Toolbox (Dakos) The early warning signals toolbox does these calculations amongst others. Like Kendall, we also need to install it. It has a lot of dependencies which will also download at the same time. Typing ??earlywarnings will give you a list of the functions included in the package.

21 Early Warning Signals Toolbox We will be using the generic_ews function. Inputs can be found by typing ?generic_ews. The example here uses the same time series as before, with the same window length and similar detrending (window length bandwidth has to be expressed as a percentage).

22 Early Warning Signals Toolbox Now we have an object called ews which contains all values of the indicators at any time so youre free to plot them or use them how you wish. You also get a plot of them all as an output. If youre feeling brave, type generic_ews to see how each indicator is calculated.


Download ppt "Early Warning Signals Workshop Chris Boulton"

Similar presentations


Ads by Google