Extreme Value Analysis revised

Dear all,

I have slightly revised parts of the code used in my posts on Extreme Value Analysis. While they were correct with respect to the results, some parts of the code written by former me more than two years ago were plainly ugly. I have also removed some redundancies and packages unnecessary for the task at hand, and tried to improve overall workflow.

Changes include:

  • The package RCurl can be avoided for fetching data from the web by simply using read.csv(url("http://ehyd.gv.at/...")) instead.
  • The whole procedure of data import has been put into a function read_ehyd(), which is described in a separate post: Reading data from eHYD using R.
  • I have integrated the use of xts (eXtensible Time Series) objects, since they provide a lot of convenient functionality. For instance, I solved deriving the annual maxima series in the original version by using a classical do.call() statement on the whole data frame:
    # derive AMS for maximum precipitation
    ams_df <- do.call("rbind", by(eHYD_df, format(df$date, "%Y"),
                      function(x) x[which.max(x$precipitation), ]))
    ams_val <- ams_df$precipitation

    This can be solved in a nicer way using dplyr:

    ams_tbl <- eHYD_df %>% 
      mutate(year = format(date, "%Y")) %>%
      group_by(year) %>%
      summarise(ams = max(precipitation)) %>%

    or even shorter using xts:

    ams <- apply.yearly(precipitation_xts, max)
  • A final remark (since I have received several questions regarding this topic): I use a custom function based on plot.fevd() for plotting fevd objects. To be honest, this is a somewhat hacky modification of the original code in order to make the plots more appealing. I intend to publish my modifications in the future once I have reworked the code. Right now, this is probably barely understandable to due to the inefficient programming style of extRemes (just have a look at the behemoth plot.fevd.mle).

Best regards,

About This Author

Matthias studied Environmental Information Management at the University of Natural Resources and Life Sciences Vienna and holds a PhD in environmental statistics. The focus of his thesis was on the statistical modelling of rare (extreme) events as a basis for vulnerability assessment of critical infrastructure. He is working at the Austrian national weather and geophysical service (ZAMG) and at the Institute of Mountain Risk Engineering at BOKU University. He currently focuses the (statistical) assessment of adverse weather events and natural hazards, and disaster risk reduction. His main interests are statistical modelling of environmental phenomena as well as open source tools for data science, geoinformation and remote sensing.

Post A Reply