Giter Site home page Giter Site logo

brffa's Introduction

Bayesian regional flood frequency analysis (FFA)

This tutorial describes the data and analysis considered for Bayesian hierachical model for Regional flood frequency analysis.

Installation

First, you need to install the SpatGEVBMA package from NorskRegnesentral GitHub respository

# install.packages("devtools")
devtools::install_github("NorskRegnesentral/SpatGEVBMA")

Then load the data and functions used for the analysis.

# Load yearly flood time series and covariates
load('data/norwayFlood.RData')

# Load functions 
source('scripts/functions.R')

We start by exploring some descriptive plots of the covariates. Considering first histograms of the record length, catchment area, percentage of lake, average rain in April and August and percentage of flood contributed to rain vs. snowmelt.

Now we plot the time series of some selected stations.

Then we plot the percentage of flood contributed to rain vs. snowmelt according to longitude and latitude of the each considered station, to reveal the spatial distribution of this covariate.

Main analysis

The main analysis is carried by running 100 000 MCMC simulation by the SpatGEV package. The flood data is structured as a list of time series, one for each station, to allow for difference serie lengths. The covariates are centered and scaled before analysis.

First, the SpatGEVBMA package is loaded. We run the package with the options to to non-spationally distributed error, to have the regression model for the scale parameter on a log scale and to print an output for every 5000 MCMC run.

library(SpatGEVBMA)
nsim <- 100
res <- spatial.gev.bma(datalist,covMat,S,nsim,prior.user=prior.user,
                       nonspatial = TRUE, log.kappa=TRUE,print.every=5000)
res$cov.names <- colnames(covariates)

The result can be analysed by first removing a suitable range of burn-in samples, we seletion 20 000 or 20% of the total MCMC runs. The calculated the inclustion probabilities for each of the covariates within the location (μ), scale (logκ), and shape (ξ) parameter of the GEV distribution.

#>                     mu kappa  xi
#> Constant           100   100 100
#> latitude           100   100   0
#> pct.eff.lake        86   100   0
#> inflow              32    78   0
#> avg.frac.rain        9    78  26
#> area.total           0    81   5
#> avg.rain.april      96     0  28
#> avg.rain.august    100   100   0
#> avg.snowmelt.march   0    12   0
#> gradient           100   100   0
#> pct.bedrock        100    88   0
#> relative.area        0   100  30

Then we plot the resulting distribution according to the quantiles or return values, e.g for 1000 year flood, we calculated the 1 − 1/1000 = 0.999 quantile. The random effects for each MCMC run are simulated from a Gaussian distribution with the corresponding variance 1/α(r), separately for each distribution parameter.

#Plot return values plots
plotReturnLevel(return.level = return.level,floodData = floodData,
                floodCov = covariates,
                T=T,writeToFile=FALSE,ymin=-0.01,ymax=NULL)
#> [1] "200011" "200013"

brffa's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.