Learn R Programming

nsRFA (version 0.5-8)

BayesianMCMC: Bayesian MCMC frequency analysis

Description

Bayesian Markov Chain Monte Carlo algorithm for flood frequency analysis with historical information.

Usage

BayesianMCMC (xcont, xhist=NA, infhist=NA, suphist=NA, nbans=NA, seuil=NA,
               nbpas=1000, nbchaines=3, confint=c(0.05, 0.95), dist="GEV",
               parameters0=NA, varparameters0=NA)
 ## S3 method for class 'BayesianMCMC':
plot(x, which=1, ask=FALSE, ...)
 ## S3 method for class 'BayesianMCMC':
print(x, ...)

Arguments

x
object of class BayesianMCMC, output of function BayesianMCMC
xcont
vector of systematic data
xhist
vector of historical data
infhist
inferior limit for historical data
suphist
superior limit for historical data
nbans
period (in years) over which the threshold has been exceeded by historical data
seuil
threshold exceeded by historical data
nbpas
number of iterations for the MCMC algorithm
nbchaines
number of chains for the MCMC algorithm
confint
confidence limits for the flood quantiles
dist
distribution: normal "NORM", log-normal with 2 parameters "LN", Exponential "EXP", Gumbel "GUMBEL", Generalized Extreme Value "GEV", Generalized Logistic "GENLOGIS", Generalized
parameters0
initial values of the parameters for the MCMC algorithm
varparameters0
initial values of the parameter variances for the MCMC algorithm
which
a number of a vector of numbers that defines the graph to plot (see details)
ask
if TRUE, the interactive mode is run
...
other arguments

Value

  • BayesianMCMC returns the following values:

    parameters matrix (nbpas)x(nbchaines) with the simulated sets of parameters with the MCMC algorithm;

    parametersML set of parameters correspondent to the maximum likelihood;

    returnperiods return periods for which quantilesML and intervals are calculated;

    quantilesML quantiles correspondent to returnperiods for the distribution whose parameters are parametersML;

    intervals confidence intervals for the quantiles quantilesML for limits confint;

    varparameters matrix (nbpas)x(nbchaines)x(number of parameters) with the simulated variances for the MCMC algorithm;

    vraisdist likelihoods for the sets parameters;

    plot.BayesianMCMC plots the following figures:

    1 data as plotting position, fitted distribution (maximum likelihood) and confidence intervals;

    2 diagnostic plot of the MCMC simulation (parameters);

    3 diagnostic plot of the MCMC simulation (likelyhood and MCMC acceptance rate);

    3 posterior distribution of parameters obtained with the MCMC simulation (cloud plots);

See Also

.

Examples

Run this code
set.seed(2988)
serie <- rand.GEV(120, xi=40, alfa=20, k=-0.4)
serie100 <- serie[1:100]
serie100[serie100 < 250] <- NA
serie20 <- serie[101:120]
serie <- c(serie100, serie20)


plot(serie, type="h", ylim=c(0, 600), xlab="", ylab="Annual flood peaks [m3/s]", lwd=3)
abline(h=0)
points(serie100, col=2)

# Using only sistematic data
only_sist <- BayesianMCMC (xcont=serie20, xhist=NA, infhist=NA, suphist=NA, 
                           nbans=NA, seuil=NA,
                           nbpas=5000, nbchaines=3, 
                           confint=c(0.05, 0.95), dist="GEV")
plot(only_sist, which=c(1:3), ask=TRUE, ylim=c(1,600))



# Adding the information that the threshold 250 m3/s was exceeded 3 times in the past 100 years
with_hist_thresh <- BayesianMCMC (xcont=serie20, xhist=NA, infhist=rep(250,3), suphist=NA, 
                                  nbans=100, seuil=250,
                                  nbpas=5000, nbchaines=3, 
                                  confint=c(0.05, 0.95), dist="GEV")
plot(with_hist_thresh, which=c(1:3), ask=TRUE, ylim=c(1,600))



# Assuming that the 3 historical events are known with high uncertainty
with_hist_limits <- BayesianMCMC (xcont=serie20, xhist=NA, infhist=c(320,320,250), suphist=c(360,400,270), 
                                  nbans=100, seuil=250,
                                  nbpas=5000, nbchaines=3, 
                                  confint=c(0.05, 0.95), dist="GEV")
plot(with_hist_limits, which=c(1:3), ask=TRUE, ylim=c(1,600))



# Assuming that the 3 historical events are perfectly known
with_hist_known <- BayesianMCMC (xcont=serie20, xhist=serie100[!is.na(serie100)], infhist=NA, suphist=NA, 
                                 nbans=100, seuil=250,
                                 nbpas=5000, nbchaines=3, 
                                 confint=c(0.05, 0.95), dist="GEV")
plot(with_hist_known, which=c(1:3), ask=TRUE, ylim=c(1,600))

Run the code above in your browser using DataLab