introduction to r and extremesericg/rintro.pdf · quantiles from model simulated data 1regression...

72
Introduction to R and extRemes Eric Gilleland Research Applications Laboratory 21 July 2014, Trieste, Italy

Upload: others

Post on 25-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Introduction to R and extRemes

Eric Gilleland Research Applications Laboratory

21 July 2014, Trieste, Italy

Page 2: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Part I: Intro to R

Page 3: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

R-Project website

•  Documentation •  Access to packages via CRAN •  Search engines (including one specific to R) •  other •  http://www.R-project.org

Page 4: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Advanced

•  Reading and Writing Net CDF files http://www.image.ucar.edu/Software/Netcdf/

•  A climate related precipitation example http://www.image.ucar.edu/~nychka/FrontrangePrecip/

Page 5: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

.RData •  All work conducted within a “dot” file

called .RData, which is referred to as the workspace and exists in the working directory

•  save.image() •  getwd() •  setwd() •  citation() •  q() •  Functions exist to export results outside of the

workspace

Page 6: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Accessing Help Files •  ?save.image •  ?getwd •  ?setwd •  ?citation •  ?q •  To write to a file outside of .Rdata working

directory §  ?write (text, csv, etc.) §  ?write.table (text, csv, etc.)

Page 7: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Object Oriented

•  plot •  methods(plot) •  methods(class=“lm”) •  print •  summary •  predict •  length

Page 8: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Logical Operators

•  &, && (and) •  |, || (or) •  == •  >=, >, <, <= •  is.na, is.finite, is.numeric, is.logical,

is.element

Page 9: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Logical Operators: Accessing Help Files

•  ?”&”, ?”&&” •  ?”|” •  ?”==“ •  ?is.na

Page 10: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Arithmetic Operators

•  + •  - •  * •  / •  ^, ** •  %*% (matrix multiplication)

Page 11: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Assignment Operators

•  <- §  x <- 1:10

•  -> §  1:10 -> x

•  = §  x = 1:10 §  1:10 = x

•  ?assign

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Page 12: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Functions •  help, ? •  plot •  Sys.time •  Sys.time() •  x <- Sys.time()

§  x is the result of the Sys.time call •  y <- Sys.time

§  y is a copy of the function Sys.time •  args(plot)

Page 13: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Some of my terminology

•  x “gets” 1 to 10 §  x <- 1:10 §  x <- seq(1,10,1) §  x <- seq(1, 10, , 10)

•  plot x §  plot(x)

•  x “at” 3 §  x[ 3 ]

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Page 14: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Some of my terminology •  open paren

§  ( •  close paren

§  ) •  square brackets

§  open [ §  close ]

•  curly brackets / braces §  open { §  close }

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Page 15: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Packages •  Thousands of users have written packages.

Most are freely available in the same place, and accessible (installation) from within an R session (provided you are connected to the internet).

•  Must first install the package you want (need only do once), and load the library for each new R session.

•  ?install.packages •  ?update.packages •  ?library •  citation(“pkgname”)

Page 16: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Installing / Updating a package

•  Need be done only once (per update) •  Install extRemes

§  install.packages(“extRemes”) §  Select a mirror §  Installs extRemes and dependencies

•  Updating already installed packages (all at once) §  update.packages() § will prompt you for a mirror and may ask for

confirmation to update each package. UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Page 17: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Loading a package

•  Must be done for every new R session (if you want to use the package)

•  Load extRemes §  library(“extRemes”) §  loads all dependent packages as well

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Page 18: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Citing R packages

•  citation(“pkgname”) •  Example: to cite extRemes:

§  citation(“extRemes”)

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Page 19: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Some Atmospheric Science Oriented Packages

•  Spatial Statistics §  fields §  spatstat, §  sp §  maps §  Many More! (See the Spatial Data Task View on the R-Project web site)

•  Extreme Value Analysis §  extRemes §  SpatialExtremes §  texmex §  Many More! (http://www.ral.ucar.edu/staff/ericg/softextreme.php)

•  Forecast Verification / Model Evaluation §  verification §  SpatialVx

•  RadioSonde •  ncdf, netCDF •  smoothie

Page 20: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Formulas in R

Left as an exercise. Should get somewhat familiar with these because they are used for modeling nonstationary EV models in extRemes (≥ 2.0). ?formula

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Page 21: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Types of R objects

•  functions •  vectors, matrices, arrays

§  numeric, integer, etc. §  character §  factor

•  data frames •  lists •  other

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Page 22: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

vectors, matrices, arrays

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

x <- cbind(c(1,2,3), c(4,5,6))!y <- matrix(1:6, ncol = 2)!x!y!x == y!any(x != y)!x[, 1]!x[2, ] <- NA!is.na(x)!x – y!x[1:2, 3]!x[, -1]!

Page 23: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

vectors, matrices, arrays

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

x <- rnorm(100)!!class(x)!!is.vector(x)!!is.matrix(x)!!x[ 1:10 ]!!plot(x)!

Page 24: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

vectors, matrices, arrays

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

x <- array(1:24, dim = c(2, 3, 4))!!x!!x[, , 1] <- 0!!x!!apply(x, 1:2, sum)!

Page 25: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

data frames

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

x <- data.frame(obs = 1:10, x = runif(10),! y = rnorm(10))!!x!!x[, “x”]!!x[, 2]!!plot(x)!!class(x)!!is.list(x)!

Page 26: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

lists

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

x <- list(f = function(x) return(x ^2),! x = rnorm(10), y = 1:6)!!x!!x$f(3)!!x$x!!class(x)!

Page 27: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Conclusion of Part I: Intro to R

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Page 28: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Part II: Extreme Value Analysis with extRemes ≥ 2.0

Midwest flood 1993 (NCAR Digital Image Library, DI00578)

Block Maxima

“Il est impossible que l’improbable n’arrive jamais” --Emil Gumbel

Page 29: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Tutorial

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

http://www.ral.ucar.edu/staff/ericg/extRemes/extRemes2.pdf

Page 30: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Generalized Extreme Value Distribution

library(extRemes)!!Zmax <- matrix(rnorm(100 * 1000), ! 1000, 100)!!dim(Zmax)!!Zmax <- apply(Zmax, 2, max)!!dim(Zmax)!

Simulate a sample of size 100 of maxima of standard normal distributed samples

Page 31: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Generalized Extreme Value Distribution

length(Zmax)!!plot(Zmax, type = “h”, col = “darkblue”)!

Simulate a sample of size 100 of maxima of standard normal distributed samples

Page 32: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Generalized Extreme Value Distribution

fit <- fevd(Zmax)!!fit!!plot(fit)!!ci(fit, type = “parameter”)!!distill(fit)!

Fit a GEV distribution to the simulated sample

Page 33: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Generalized Extreme Value Distribution

data(SEPTsp)!!?SEPTsp!!par(mfrow = c(2, 2))!!!

Plot maximum winter temperature (°C) in Sept-Iles, Québec

Page 34: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Generalized Extreme Value Distribution

plot(TMX1~ Year, data = SEPTsp,! type = "h", col = "darkblue")!!plot(TMX1~ AOindex, data = SEPTsp,! pch = 21, col = "darkblue", ! bg = "lightblue")!!plot(TMX1~ MDTR, data = SEPTsp,! pch = 21, col = "darkblue", ! bg = "lightblue")!!

Plot maximum winter temperature (°C) in Sept-Iles, Québec

Page 35: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Generalized Extreme Value Distribution Maximum winter temperature in Sept-Iles, Québec

1950 1960 1970 1980 1990

1520

25

Year

TMX1

●●

●●

●●

● ●

●●

−1 0 1 2 3

1520

25

AOindex

TMX1

●●

● ●

●●

● ●

●●

7 8 9 10 11

1520

25

MDTR

TMX1

Page 36: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Generalized Extreme Value Distribution

fit0 <- fevd(TMX1, data = SEPTsp, ! units = "deg C")!!fit0!!plot(fit0)!!ci(fit0, type = "parameter")!!ci(fit0)!!

Fit a GEV distribution to maximum winter temperature in Sept-Iles, Québec

Page 37: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Generalized Extreme Value Distribution Fit a GEV distribution to maximum winter temperature in Sept-Iles, Québec

●●

●●●●●●●●●●●●●

●●●●●●●●

●●●●●●●

●●●●●●●●●●●

●●●

●●● ●

14 16 18 20 22 24 26 28

1520

25

Model Quantiles

Empi

rical

Qua

ntile

s

●● ●

● ●●●●●●●●●●

● ●●●●●●

●●● ●●●●●●●●● ●●

●●●● ●●●

●●

●●

15 20 25

1015

2025

30

TMX1 Empirical Quantiles

Qua

ntile

s fro

m M

odel

Sim

ulat

ed D

ata

1−1 lineregression line95% confidence bands

10 15 20 25 30

0.00

0.04

0.08

N = 51 Bandwidth = 1.448

Den

sity

EmpiricalModeled

2 5 10 50 200 1000

2025

3035

40

Return Period (years)

Ret

urn

Leve

l (de

g C

)

●●●

●●●●●●●●●●●●●●●

●●●●●●●●●●●●●

●●●●●●●●●

●●●●●●

●● ● ●

fevd(x = TMX1, data = SEPTsp, units = "deg C")

Page 38: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Generalized Extreme Value Distribution

fit1 <- fevd(TMX1, data = SEPTsp, ! location.fun = ~AOindex, ! units = "deg C")!!fit1!!plot(fit1)!!lr.test(fit0, fit1)!!

Fit a GEV distribution to maximum winter temperature in Sept-Iles, Québec

Inclusion of AOindex in location parameter is not significant.

Page 39: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Generalized Extreme Value Distribution Fit a GEV distribution to maximum winter temperature in Sept-Iles, Québec

●●

●●●●●●●●

●●●●●●●●●●

●●●●●

●●●●●●●●●●●●

●●●●

●●●

●● ● ●

−1 0 1 2 3 4−1

01

23

4

(Gumbel Scale)

(Standardized) Model Quantiles

Empi

rical

Res

idua

l Qua

ntile

s●

●●●

●● ●●●●●●●●●●

●●●

●●●●

●●● ●●

●●●●●●

● ●●●●

●● ● ●●

● ●●

●●

15 20 25

1520

25

TMX1 Empirical Quantiles

Qua

ntile

s fro

m M

odel

Sim

ulat

ed D

ata

1−1 lineregression line95% confidence bands

−2 0 2 4 6

0.00

0.10

0.20

0.30

Transformed Data

N = 51 Bandwidth = 0.5314

Den

sity

EmpiricalModeled

0 10 20 30 40 5015

2025

3035

index

Ret

urn

Leve

l (de

g C

) 2−year level20−year level100−year level

fevd(x = TMX1, data = SEPTsp, location.fun = ~STDTMAX, units = "deg C")

Page 40: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Generalized Extreme Value Distribution Fit a GEV distribution to maximum winter temperature in Sept-Iles, Québec

fit2 <- fevd(TMX1, data = SEPTsp, ! scale.fun = ~STDTMAX, ! use.phi = TRUE, units = "deg C")!!fit2!!plot(fit2)!!lr.test(fit0, fit2)!!

Addition of AOindex to scale parameter is not statistically significant.

Page 41: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Generalized Extreme Value Distribution

Addition from previous slide is a function of the following form. log(σ(AO index)) = φ0 + φ1 × AO index

Because: use.phi = TRUE !

Page 42: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Generalized Extreme Value Distribution

par(mfrow = c(2, 2))!!plot(TMN0~ Year, data = SEPTsp,! type = "h", col = "darkblue")!!plot(TMN0~ AOindex, data = SEPTsp,! pch = 21, col = "darkblue", ! bg = "lightblue")!!plot(TMN0~ MDTR, data = SEPTsp,! pch = 21, col = "darkblue", ! bg = "lightblue")!!!

Plot minimum winter temperature (°C) in Sept-Iles, Québec

Page 43: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Generalized Extreme Value Distribution Fit GEV to (negative) minimum winter temperature (°C) in Sept-Iles, Québec

fit0 <- fevd(-TMN0 ~ 1, data = SEPTsp, ! units = “neg. deg. C”)!!fit0 !!plot(fit0)!!!The rest of the analysis of (negative) minimum

temperature is left as an exercise.

Page 44: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Part III: Extreme Value Analysis Frequency of extremes

photo from Wikipedia: http://en.wikipedia.org/wiki/Coligny_calendar

Page 45: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Frequency of Extremes

Number of days that maximum daily temperature (°F) in Fort Collins, Colorado exceeds 95 °F.

data(FCwx)!!?FCwx!!tempGT95 <- aggregate(FCwx$MxT, ! by = list(FCwx$Year), ! function(x) sum(x > 95, ! na.rm = TRUE))!! class(tempGT95)!

Page 46: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Frequency of Extremes

Number of days that maximum daily temperature (°F) in Fort Collins, Colorado exceeds 95 °F.

names(tempGT95)!!names(tempGT95) <- c(“Year”, “MxT”)!!tempGT95!

Page 47: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Frequency of Extremes

Fit Poisson distribution to number of days that maximum daily temperature (°F) in Fort Collins, Colorado exceeds 95 °F.

plot(MxT ~ Year, data = tempGT95,! type = “h”, col = “darkblue”,! ylab = !“Number of days MxT > 95 deg. F”)!!fpois(tempGT95$MxT)!

Test for equality of mean and variance says that the two are statistically significantly different.

Page 48: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Frequency of Extremes

Plot of number of days that maximum daily temperature (°F) in Fort Collins, Colorado exceeds 95 °F.

1900 1920 1940 1960 1980 2000

02

46

8

Year

Num

ber o

f day

s M

xT >

95

deg.

F

Page 49: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Frequency of Extremes

Fit Poisson to number of days that maximum daily temperature (°F) in Fort Collins, Colorado exceeds 95 degrees F.

fit <- glm(tempGT95~yr, family = poisson())!!summary(fit)!! !

Page 50: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Part IV: Extreme Value Analysis

Threshold Excesses

V.F.D. Pareto

Page 51: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Generalized Pareto

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

par(mfrow = c(2, 2), oma = c(0,0,2,0))!!plot(Prec ~ Year, data = Denversp, ! type = "h", col = "darkblue", ! lwd = 2, cex.lab = 1.5, ! cex.axis = 1.5, ylab = "")!!plot(Prec ~ Day, data = Denversp, ! type = "h", col = "darkblue", ! lwd = 2, cex.lab = 1.5, ! cex.axis = 1.5, ylab = "")!!

Example: Denver, Colorado July hourly Precipitation (mm)

Page 52: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Generalized Pareto

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

plot(Prec ~ Hour, data = Denversp,! type = "h", col = "darkblue", lwd = 2,! cex.lab = 1.5, cex.axis = 1.5, ! ylab = "")!!mtext("Precipitation (mm)\nDenver, Colorado", ! side = 3, outer = TRUE)!!

Example: Denver, Colorado July hourly Precipitation (mm)

Page 53: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Generalized Pareto

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Example: Denver, Colorado July hourly Precipitation (mm)

50 60 70 80 90

0.0

0.5

1.0

1.5

Year0 5 10 20 30

0.0

0.5

1.0

1.5

Day

5 10 15 20

0.0

0.5

1.0

1.5

Hour

Precipitation (mm)Denver, Colorado

Page 54: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Generalized Pareto

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Example: Denver, Colorado July hourly Precipitation (mm)

threshrange.plot(Denversp$Prec, ! r = c(0.1, 0.95))!!extremalindex(Denversp$Prec, threshold=0.5)!

A threshold of about 0.5 mm seems appropriate for these data. Threshold excesses appear to be independent with this threshold.

Page 55: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Generalized Pareto

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Example: Denver, Colorado July hourly Precipitation (mm)

● ● ● ● ● ● ● ●

0.2 0.4 0.6 0.8

−2.0

−0.5

0.5

1.5

threshrange.plot(x = Denversp$Prec, r = c(0.1, 0.95))

repa

ram

eter

ized

scal

e

●●

● ● ● ● ● ●

0.2 0.4 0.6 0.8

−1.0

0.0

1.0

2.0

Threshold

shap

e

Page 56: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Generalized Pareto

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Example: Denver, Colorado July hourly Precipitation (mm)

fitGP <- fevd(Prec, Denversp, threshold=0.5, ! type="GP", units="mm",! time.units="744/year”)!!fitGP!!plot(fitGP)!!

Page 57: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Generalized Pareto

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Example: Denver, Colorado July hourly Precipitation (mm)

●●●●●●●●●

●●●●●

●●●●●●

● ● ● ●●

0.6 0.8 1.0 1.2

0.6

0.8

1.0

1.2

1.4

1.6

Model Quantiles

Empi

rical

Qua

ntile

s

●●●●●●

●●● ● ● ●●

●●●●

●●●

●●●●

0.6 0.8 1.0 1.2 1.4 1.6

0.5

1.0

1.5

2.0

Prec( > 0.5) Empirical Quantiles

Qua

ntile

s fro

m M

odel

Sim

ulat

ed D

ata

1−1 lineregression line95% confidence bands

0.0 0.5 1.0

0.0

1.0

2.0

3.0

N = 27 Bandwidth = 0.1129

Den

sity

EmpiricalModeled

2 5 10 50 200 500

0.5

1.0

1.5

2.0

2.5

Return Period (years)

Ret

urn

Leve

l (m

m)

●●●●●●●●●●●●●●●●●

●●●

●●●● ●

fevd(x = Prec, data = Denversp, threshold = 0.5, type = "GP", units = "mm", time.units = "744/year", verbose = TRUE)

Page 58: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Generalized Pareto

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Example: Denver, Colorado July hourly Precipitation (mm)

ci(fitGP, type = "parameter")!!ci(fitGP)!

95% lower CI Estimate 95% upper CI σ(u = 0.5 mm) 0.16 0.32 0.47 ξ -0.48 -0.15 0.19 100-year return level (mm) 1.04 1.49 1.93

Page 59: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Part V: Extreme Value Analysis Point Process

2 4 6 8 10

24

68

time

value

A

Siméon Denis Poisson

Page 60: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Point Process

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

fitPP <- fevd(Prec, Denversp, threshold=0.5, ! type="PP", units="mm”,! time.units="744/year")!!fitPP!!plot(fitPP)!

Page 61: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Point Process

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

●●●●●●●

●●●●●●●●● ●

●● ●

● ● ● ●●

0.6 0.8 1.0 1.2

0.6

1.0

1.4

Model Quantiles

Empi

rical

Qua

ntile

s

●●●●●●●●● ● ● ●●

●●●● ● ●●

●●

●●

0.6 0.8 1.0 1.2 1.4 1.6

0.5

1.0

1.5

2.0

Prec( > 0.5) Empirical Quantiles

Qua

ntile

s fro

m M

odel

Sim

ulat

ed D

ata

1−1 lineregression line95% confidence bands

0.0 0.5 1.0 1.5 2.0

0.0

0.4

0.8

1.2

N = 42 Bandwidth = 0.1264

Dens

ity

Empirical (year maxima)Modeled

0 1 2 3 4

0.0

1.0

2.0

3.0

Z plot

Expected ValuesUnder exponential(1)

Obs

erve

d Z_

k Va

lues

●●●●●●

●●●●●●●● ●

● ● ●● ● ●

1−1 lineregression line95% confidence bands

2 5 10 20 50 100 500

0.5

1.5

2.5

Return Levels based on approx.equivalent GEV

Return Period (years)

Retu

rn L

evel

(mm

)

● ●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●●

●●●● ● ● ●

fevd(x = Prec, data = Denversp, threshold = 0.5, type = "PP", units = "mm", time.units = "744/year")

Page 62: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Point Process

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

ci(fitPP, type = “parameter”)!!ci(fitPP)!

95% lower CI Estimate 95% upper CI µ (mm) 0.21 0.36 0.51 σ (mm) 0.13 0.34 0.55 ξ -0.48 -0.15 0.19 100-year return level (mm) 1.09 1.48 1.88

Page 63: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Point Process

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Also vary the threshold by hour? And incorporate a diurnal cycle in the location parameter?

u <- numeric(dim(Denversp)[1])!u[ Denversp$Hour < 14 ] <- 0.001!u[ Denversp$Hour >= 14 ] <- 0.5!!fitPP3 <- fevd(Prec, Denversp, ! threshold = u, location.fun = ~Hour, ! type="PP", units="mm",! time.units = "744/year")!!fitPP3!plot(fitPP3)!

Ok, maybe not!

Page 64: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Declustering

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Example: Sky Harbor airport, Phoenix, Arizona July to August maximum temperatures (°F) data(Tphap)!!plot(MaxT ~ Year, data = Tphap, pch = 21, ! col = "darkblue", bg = "lightblue", ! lwd = 2, cex.lab = 1.5, cex.axis = 1.5, ! ylab = "")!!!

Page 65: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Declustering

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

●●●●●

●●

●●

●●

●●

●●●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●●

●●●

●●

●●●●

●●

●●

●●●●

●●●

●●●●

●●●

●●

●●

●●

●●●●

●●

●●●

●●

●●

●●●

●●

●●

●●●●●

●●

●●●

●●

●●

●●●

●●●●

●●●●

●●●●

●●

●●

●●●●●

●●●●

●●

●●

●●●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●●

●●

●●●

●●●●●

●●

●●

●●

●●●●●

●●

●●

●●

●●

●●

●●

●●●

●●●●

●●

●●●

●●●

●●●

●●

●●

●●●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●●

●●

●●●

●●●

●●

●●●●

●●

●●●

●●

●●●

●●

●●

●●

●●●

●●●

●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●●●

●●

●●

●●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●●

●●

●●●●

●●

●●

●●

●●

●●●

●●●

●●

●●●●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●●

●●

●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●●

●●●●

●●●●

●●●

●●

●●●

●●

●●●

●●●●

●●●●●

●●

●●

●●●●

●●

●●

●●

●●●●

●●

●●

●●●

●●●

●●●

●●●

●●●

●●●

●●

●●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●

●●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●●●

●●

●●●●

●●

●●●

●●

●●

●●

●●●●

●●●

●●

●●

●●●●●

●●

●●

●●●●●

●●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●●

●●

●●●

●●●●●

●●●

●●

●●

●●

●●

●●

●●●●

●●

●●●●●●

●●●

●●

●●

●●●●

●●

●●

●●

●●●

●●●●●

●●●

●●

●●

●●

●●●

●●

●●●●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●●●●

●●●

●●●

●●

●●●

●●●

●●

●●●

●●●●●

●●

●●●

●●

●●

●●●●●

●●

●●●●●

●●

●●

●●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●●

●●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●●

●●●●●

●●

●●

●●●

●●

●●

●●

●●

●●●●●

●●●●

●●

●●●

●●●●●

●●●●

●●●●●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●●

●●

●●

●●●

●●

●●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●●●

●●●

●●●

●●

●●

●●●

●●

●●●

●●

●●

●●

●●●●●

●●

●●●

●●

●●●●

● ●

●●

●●

●●●●●

●●

●●●

●●

●●●●

●●●

●●

●●

●●

●●●

●●●

●●

●●

●●

●●●

●●

●●●

●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●●●

●●

●●●●●

●●

●●

●●

●●●

●●

●●●●

●●●●

●●●●●

●●

●●●

●●●●

●●

●●

●●

●●●

●●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●●●

●●●

●●

●●

●●●●●●

●●

●●

●●●

●●

●●

●●

●●

●●●●

●●

●●●

●●

●●

●●

●●●

●●●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●●

●●●

●●●

50 60 70 80 90

8090

100

110

Year

Example: Sky Harbor airport, Phoenix, Arizona July to August maximum temperatures (°F)

Page 66: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Declustering

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

threshrange.plot(Tphap$MaxT, ! r = c(105, 110), type = "PP")!

Example: Sky Harbor airport, Phoenix, Arizona July to August maximum temperatures (°F)

Page 67: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Declustering

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Example: Sky Harbor airport, Phoenix, Arizona July to August maximum temperatures (°F)

●● ●

●● ●

●●

●●

● ●

●●

105 106 107 108 109 110

115.0

116.0

threshrange.plot(x = Tphap$MaxT, r = c(105, 110), type = "PP", nint = 20)

location

●●

●●

●●

●●

105 106 107 108 109 110

0.8

1.2

1.6

scale

●●

●●

105 106 107 108 109 110

−0.4

−0.2

0.0

Threshold

shape

Page 68: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Declustering

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Example: Sky Harbor airport, Phoenix, Arizona July to August maximum temperatures (°F) extremalindex(Tphap$MaxT, threshold = 105)!

θ Number of Clusters Run Length 0.21 234 2

Page 69: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Declustering

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Example: Sky Harbor airport, Phoenix, Arizona July to August maximum temperatures (°F) y <- decluster(Tphap$MaxT, threshold = 105, ! r = 2)!!y!!plot(y)!

Page 70: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Declustering

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Example: Sky Harbor airport, Phoenix, Arizona July to August maximum temperatures (°F)

●●●●●

●●

●●

●●

●●

●●●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●●

●●●

●●

●●●●

●●

●●

●●●●

●●●

●●●●

●●●

●●

●●

●●

●●●●

●●

●●●

●●

●●

●●●

●●

●●

●●●●●

●●

●●●

●●

●●

●●●

●●●●

●●●●

●●●●

●●

●●

●●●●●

●●●●

●●

●●

●●●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●●

●●

●●●

●●●●●

●●

●●

●●

●●●●●

●●

●●

●●

●●

●●

●●

●●●

●●●●

●●

●●●

●●●

●●●

●●

●●

●●●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●

●●●

●●

●●●

●●

●●●

●●●

●●

●●●●

●●

●●●

●●

●●●

●●

●●

●●

●●●

●●●

●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●●●

●●

●●

●●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●●

●●

●●●●

●●

●●

●●

●●

●●●

●●●

●●

●●●●●

●●

●●

●●●

●●

●●

●●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●●

●●

●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●●

●●●●

●●●●

●●●

●●

●●●

●●

●●●

●●●●

●●●●●

●●

●●

●●●●

●●

●●

●●

●●●●

●●

●●

●●●

●●●

●●●

●●●

●●●

●●●

●●

●●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●

●●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●●●

●●

●●●●

●●

●●●

●●

●●

●●

●●●●

●●●

●●

●●

●●●●●

●●

●●

●●●●●

●●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●

●●●

●●

●●●

●●●●●

●●●

●●

●●

●●

●●

●●

●●●●

●●

●●●●●●

●●●

●●

●●

●●●●

●●

●●

●●

●●●

●●●●●

●●●

●●

●●

●●

●●●

●●

●●●●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●●●●

●●●

●●●

●●

●●●

●●●

●●

●●●

●●●●●

●●

●●●

●●

●●

●●●●●

●●

●●●●●

●●

●●

●●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●●

●●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●

●●●

●●●●●

●●

●●

●●●

●●

●●

●●

●●

●●●●●

●●●●

●●

●●●

●●●●●

●●●●

●●●●●●

●●

●●

●●

●●

●●

●●●●

●●

●●

●●●

●●

●●

●●●

●●

●●●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●●●

●●●

●●●

●●

●●

●●●

●●

●●●

●●

●●

●●

●●●●●

●●

●●●

●●

●●●●

●●

●●

●●

●●●●●

●●

●●●

●●

●●●●

●●●

●●

●●

●●

●●●

●●●

●●

●●

●●

●●●

●●

●●●

●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●●●

●●

●●●●●

●●

●●

●●

●●●

●●

●●●●

●●●●

●●●●●

●●

●●●

●●●●

●●

●●

●●

●●●

●●●

●●

●●●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●

●●●●

●●●

●●

●●

●●●●●●

●●

●●

●●●

●●

●●

●●

●●

●●●●

●●

●●●

●●

●●

●●

●●●

●●●●

●●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●●●

●●●

●●●

0 500 1000 1500 2000 2500

8090

100

110

decluster.runs(x = Tphap$MaxT, threshold = 105, r = 2)

index

Tphap$MaxT

●●●●●●●●●●●●●●

●●●●

●●

●●●●●

●●

●●●●●●●●●●●

●●●●●●●

●●●

●●

●●

●●●

●●

●●

●●●

●●●●●

●●●

●●●

●●

●●●●

●●

●●●●●●●

●●

●●●

●●

●●●●

●●●

●●

●●

●●●

●●

●●●●●●●●●●●

●●●●●●

●●●●●

●●●●●●●●●●●●●●●●●

●●●

●●

●●●

●●●

●●●

●●●●

●●

●●

●●

●●●●●●●

●●●●

●●

●●●●●●

●●●

●●●●

●●

●●

●●

●●●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●●●

●●

●●●●

●●

●●●

●●

●●

●●●

●●●

●●

●●

●●

●●●

●●●

●●

●●●

●●●●●

●●

●●

●●●●●

●●

●●

●●

●●

●●

●●

●●●

●●●●

●●

●●●

●●

●●●

●●●

●●●

●●

●●

●●●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●●

●●

●●●

●●

●●●

●●●

●●

●●●●●●●●●●

●●●●●●

●●●

●●

●●

●●●

●●●

●●

●●●

●●●●●

●●●●●

●●●

●●●

●●

●●

●●●

●●●

●●

●●●●

●●

●●

●●●●

●●●●●

●●●●

●●

●●

●●

●●

●●●

●●

●●

●●●●

●●

●●●●●●●●●●●●●

●●●

●●

●●●

●●●

●●

●●●●●

●●

●●

●●●●●●

●●

●●

●●

●●

●●●●

●●●●●●●●

●●●●●●●

●●

●●

●●●●

●●●

●●●●

●●

●●●●●●●●●●●●

●●●

●●●

●●

●●●

●●

●●

●●

●●●●

●●

●●●●

●●

●●●

●●

●●

●●●

●●●●●●

●●●●

●●●●●●●

●●●●●●

●●

●●

●●●

●●●

●●

●●●●●

●●●●●●●●●●●

●●●

●●

●●

●●

●●

●●●●●●●●

●●●

●●●●

●●●●●

●●●

●●

●●●●

●●

●●

●●●●

●●

●●

●●●

●●●●

●●●

●●

●●●●●●●●

●●

●●●

●●

●●

●●●

●●●

●●

●●

●●

●●

●●●●●●

●●

●●

●●

●●

●●●●●●●●

●●

●●●

●●

●●●●

●●

●●●●

●●●●●●●

●●●●

●●●●●●

●●

●●●●

●●

●●

●●

●●●●●

●●

●●●●●●●●●●●●●

●●●●

●●●●●●●●●●●●●●●●●●●●

●●●

●●

●●

●●

●●●

●●

●●●●●●

●●●

●●●●●●●

●●●

●●

●●●●●●

●●●●

●●●●

●●

●●●●●●

●●

●●●

●●

●●●●●●●●●

●●●●

●●●●

●●

●●●●

●●

●●●●●

●●●●●●●●●●

●●●●

●●●

●●●●●

●●●

●●

●●

●●

●●●

●●●●●●●

●●

●●●●●●

●●●

●●●●

●●●●●●●●●●●

●●●●

●●●●●●●

●●●

●●●●

●●●●●●

●●

●●●●●

●●

●●●●●●

●●

●●●

●●●

●●

●●

●●

●●●

●●●

●●

●●

●●

●●●

●●

●●●

●●

●●●●●●●●●●

●●●●●●●●●●●

●●●●

●●●

●●

●●

●●

●●●●●●●●●●●●●●●●●●●●●

●●●

●●

●●

●●

●●

●●●●●

●●●●●

●●

●●●

●●●●●●

●●●●●●●●●●●

●●●●●●●●●

●●●●●●●

●●●●●●●●●●●●●●

●●

●●

●●●

●●

●●●●

●●

●●●

●●●●●●●●●●●●●●

●●●●

●●

●●●

●●●●●

●●

●●

●●

●●●●●

●●●●

●●●●●

●●

●●

●●●●

●●

●●●●

●●

●●●●●●●

●●

●●●●●●●●●●●

●●●

●●

●●●●●●●

●●

●●●●●●●●●●●

●●●

●●●

●●

●●●

●●●●●●●●●

●●

●●●●●

●●

●●

●●

●●●●●●●●

●●

●●●●●●●●●●●

●●●●●

●●

●●

●●

●●●●●●●

●●●

●●

●●●●

●●●

●●

●●

●●

●●

●●

●●●●

●●●●●●●●●●●●●

●●

●●●●●

●●

●●

●●●●●

●●

●●●

●●

●●

●●●●●●

●●

●●●●

●●●●

●●●●●●●

●●●●●●●

●●●●●●

●●●●

●●

●●●●●●●●●●●●●

●●●●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●●●●●●●●●●●●●

●●●●

●●●●

●●●●●●

●●

●●

●●●●●●●●

●●●●●

●●

●●

●●●●

●●●

●●●●●●

●●●●●●●

●●●●●●●●

●●●

●●●●

●●●

●●●●

●●

●●●

●●●●

●●●

●●

●●●

●●

●●●●

●●●

●●●

●●

●●●●

●●●

●●●

Page 71: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Declustering

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Example: Sky Harbor airport, Phoenix, Arizona July to August maximum temperatures (°F) Tphap2 <- Tphap!Tphap2$MaxT.dc <- c(y)!!fit <- fevd(MaxT.dc, threshold = 105, ! data = Tphap2, type = "PP",! time.units = "62/year", units = ! "deg F")!!fit!!plot(fit)!!

Page 72: Introduction to R and extRemesericg/Rintro.pdf · Quantiles from Model Simulated Data 1regression line−1 line 95% confidence bands −2 0 2 4 6 0.00 0.10 0.20 0.30 Transformed Data

Declustering

UCAR Confidential and Proprietary. © 2014, University Corporation for Atmospheric Research. All rights reserved.

Example: Sky Harbor airport, Phoenix, Arizona July to August maximum temperatures (°F)

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●

●●●●

● ●

106 108 110 112 114 116 118

106

110

114

118

Model Quantiles

Empi

rical

Qua

ntile

s

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●● ●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●● ●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●● ●●●●●●●●

●●●●●●●●●●● ●●●●●●●

●●●●●●●●●●●●●●●●●●●●● ●●●●●●●

●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●● ●●●●●●

●●●●●●●●●● ●●●●

●●●●●●●●●●●●● ●●

●● ●

106 108 110 112 114 116 118

106

110

114

118

MaxT.dc( > 105) Empirical Quantiles

Qua

ntile

s fro

m M

odel

Sim

ulat

ed D

ata

1−1 lineregression line95% confidence bands

105 110 115 120

0.00

0.10

N = 43 Bandwidth = 0.9037

Dens

ity

Empirical (year maxima)Modeled

0 1 2 3 4 5 6

12

34

5

Z plot

Expected ValuesUnder exponential(1)

Obs

erve

d Z_

k Va

lues

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●●

●●●●●●●●●●●●● ●

● ●●

●●

●●

1−1 lineregression line95% confidence bands

2 5 10 20 50 100 500

113

115

117

119

Return Levels based on approx.equivalent GEV

Return Period (years)

Retu

rn L

evel

(deg

F)

●●●

●●

●●●●●●●●●

●●●●●●●●●●

●●●●●

●●●●●●●

● ● ●

● ●

fevd(x = MaxT.dc, data = Tphap2, threshold = 105, type = "PP", units = "deg F", time.units = "62/year")