Last data update: 2014.03.03
R: Posterior Distribution with GEV, where xi=0
posterior.gumbel R Documentation
Posterior Distribution with GEV, where xi=0
Description
MCMC runs of posterior distribution of data with parameters of Generalized Extreme Value (GEV) density, in the particular case where xi=0 with parameters mu,sigma.
Usage
posterior.gumbel(data, block, int)
Arguments
data
data vector
block
the block size. A numeric value is interpreted as the number of data values in
each successive block. All the data is used, so the last block may not contain
block observations.
int
number of iteractions selected in MCMC. The program selects
1 in each 10 iteraction, then thin=10. The first thin*int/3 iteractions
is used as burn-in. After that, is runned thin*int iteraction, in which
1 of thin is selected for the final MCMC chain, resulting the number of int
iteractions.
Value
The program has as result a matrix with dimensions int x 2, where the first
represents points of posterior points of mu parameter of GEV, and
the second column is posterior points of sigma parameter. The
non-informative prior distribution of these parameters are Normal(0,1000)
for the parameter mu and Gamma(0.001,0.001) for the parameter sigma. During the MCMC runs, screen shows the proportion of iteractions made.
Examples
# Obtaining posterior distribution of a vector of simulated points
x=rgev(200,xi=0.0001,mu=10,sigma=5)
# Obtaning 600 points of posterior distribution
ajuste=posterior.gumbel(x,1,600)
# Histogram of posterior distribution of the parameters,with 95% credibility intervals
par(mfrow=c(1,2))
hist(ajuste[,1],freq=FALSE,main="mu")
abline(v=quantile(ajuste[,1],0.025),lwd=2)
abline(v=quantile(ajuste[,1],0.975),lwd=2)
hist(ajuste[,2],freq=FALSE,main="sigma")
abline(v=quantile(ajuste[,2],0.025),lwd=2)
abline(v=quantile(ajuste[,2],0.975),lwd=2)
# Maxima of each month in river nidd data
data(nidd.annual)
out=posterior.gumbel(nidd.annual,1,500)
# Predictive distribution for 15 day maxima ibovespa returns
data(ibovespa)
postibv=posterior.gumbel(ibovespa[,4],15,500)
datai=gev(ibovespa[,4],15)$data
predictive.gumbel(postibv,datai)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(MCMC4Extremes)
Loading required package: evir
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/MCMC4Extremes/posterior.gumbel.Rd_%03d_medium.png", width=480, height=480)
> ### Name: posterior.gumbel
> ### Title: Posterior Distribution with GEV, where xi=0
> ### Aliases: posterior.gumbel
>
> ### ** Examples
>
> # Obtaining posterior distribution of a vector of simulated points
> x=rgev(200,xi=0.0001,mu=10,sigma=5)
> # Obtaning 600 points of posterior distribution
> ajuste=posterior.gumbel(x,1,600)
[1] 0.01111111
[1] 0.02222222
[1] 0.03333333
[1] 0.04444444
[1] 0.05555556
[1] 0.06666667
[1] 0.07777778
[1] 0.08888889
[1] 0.1
[1] 0.1111111
[1] 0.1222222
[1] 0.1333333
[1] 0.1444444
[1] 0.1555556
[1] 0.1666667
[1] 0.1777778
[1] 0.1888889
[1] 0.2
[1] 0.2111111
[1] 0.2222222
[1] 0.2333333
[1] 0.2444444
[1] 0.2555556
[1] 0.2666667
[1] 0.2777778
[1] 0.2888889
[1] 0.3
[1] 0.3111111
[1] 0.3222222
[1] 0.3333333
[1] 0.3444444
[1] 0.3555556
[1] 0.3666667
[1] 0.3777778
[1] 0.3888889
[1] 0.4
[1] 0.4111111
[1] 0.4222222
[1] 0.4333333
[1] 0.4444444
[1] 0.4555556
[1] 0.4666667
[1] 0.4777778
[1] 0.4888889
[1] 0.5
[1] 0.5111111
[1] 0.5222222
[1] 0.5333333
[1] 0.5444444
[1] 0.5555556
[1] 0.5666667
[1] 0.5777778
[1] 0.5888889
[1] 0.6
[1] 0.6111111
[1] 0.6222222
[1] 0.6333333
[1] 0.6444444
[1] 0.6555556
[1] 0.6666667
[1] 0.6777778
[1] 0.6888889
[1] 0.7
[1] 0.7111111
[1] 0.7222222
[1] 0.7333333
[1] 0.7444444
[1] 0.7555556
[1] 0.7666667
[1] 0.7777778
[1] 0.7888889
[1] 0.8
[1] 0.8111111
[1] 0.8222222
[1] 0.8333333
[1] 0.8444444
[1] 0.8555556
[1] 0.8666667
[1] 0.8777778
[1] 0.8888889
[1] 0.9
[1] 0.9111111
[1] 0.9222222
[1] 0.9333333
[1] 0.9444444
[1] 0.9555556
[1] 0.9666667
[1] 0.9777778
[1] 0.9888889
[1] 1
> # Histogram of posterior distribution of the parameters,with 95% credibility intervals
> par(mfrow=c(1,2))
> hist(ajuste[,1],freq=FALSE,main="mu")
> abline(v=quantile(ajuste[,1],0.025),lwd=2)
> abline(v=quantile(ajuste[,1],0.975),lwd=2)
> hist(ajuste[,2],freq=FALSE,main="sigma")
> abline(v=quantile(ajuste[,2],0.025),lwd=2)
> abline(v=quantile(ajuste[,2],0.975),lwd=2)
> # Maxima of each month in river nidd data
> data(nidd.annual)
> out=posterior.gumbel(nidd.annual,1,500)
[1] 0.01333333
[1] 0.02666667
[1] 0.04
[1] 0.05333333
[1] 0.06666667
[1] 0.08
[1] 0.09333333
[1] 0.1066667
[1] 0.12
[1] 0.1333333
[1] 0.1466667
[1] 0.16
[1] 0.1733333
[1] 0.1866667
[1] 0.2
[1] 0.2133333
[1] 0.2266667
[1] 0.24
[1] 0.2533333
[1] 0.2666667
[1] 0.28
[1] 0.2933333
[1] 0.3066667
[1] 0.32
[1] 0.3333333
[1] 0.3466667
[1] 0.36
[1] 0.3733333
[1] 0.3866667
[1] 0.4
[1] 0.4133333
[1] 0.4266667
[1] 0.44
[1] 0.4533333
[1] 0.4666667
[1] 0.48
[1] 0.4933333
[1] 0.5066667
[1] 0.52
[1] 0.5333333
[1] 0.5466667
[1] 0.56
[1] 0.5733333
[1] 0.5866667
[1] 0.6
[1] 0.6133333
[1] 0.6266667
[1] 0.64
[1] 0.6533333
[1] 0.6666667
[1] 0.68
[1] 0.6933333
[1] 0.7066667
[1] 0.72
[1] 0.7333333
[1] 0.7466667
[1] 0.76
[1] 0.7733333
[1] 0.7866667
[1] 0.8
[1] 0.8133333
[1] 0.8266667
[1] 0.84
[1] 0.8533333
[1] 0.8666667
[1] 0.88
[1] 0.8933333
[1] 0.9066667
[1] 0.92
[1] 0.9333333
[1] 0.9466667
[1] 0.96
[1] 0.9733333
[1] 0.9866667
[1] 1
> # Predictive distribution for 15 day maxima ibovespa returns
> data(ibovespa)
> postibv=posterior.gumbel(ibovespa[,4],15,500)
[1] 0.01333333
[1] 0.02666667
[1] 0.04
[1] 0.05333333
[1] 0.06666667
[1] 0.08
[1] 0.09333333
[1] 0.1066667
[1] 0.12
[1] 0.1333333
[1] 0.1466667
[1] 0.16
[1] 0.1733333
[1] 0.1866667
[1] 0.2
[1] 0.2133333
[1] 0.2266667
[1] 0.24
[1] 0.2533333
[1] 0.2666667
[1] 0.28
[1] 0.2933333
[1] 0.3066667
[1] 0.32
[1] 0.3333333
[1] 0.3466667
[1] 0.36
[1] 0.3733333
[1] 0.3866667
[1] 0.4
[1] 0.4133333
[1] 0.4266667
[1] 0.44
[1] 0.4533333
[1] 0.4666667
[1] 0.48
[1] 0.4933333
[1] 0.5066667
[1] 0.52
[1] 0.5333333
[1] 0.5466667
[1] 0.56
[1] 0.5733333
[1] 0.5866667
[1] 0.6
[1] 0.6133333
[1] 0.6266667
[1] 0.64
[1] 0.6533333
[1] 0.6666667
[1] 0.68
[1] 0.6933333
[1] 0.7066667
[1] 0.72
[1] 0.7333333
[1] 0.7466667
[1] 0.76
[1] 0.7733333
[1] 0.7866667
[1] 0.8
[1] 0.8133333
[1] 0.8266667
[1] 0.84
[1] 0.8533333
[1] 0.8666667
[1] 0.88
[1] 0.8933333
[1] 0.9066667
[1] 0.92
[1] 0.9333333
[1] 0.9466667
[1] 0.96
[1] 0.9733333
[1] 0.9866667
[1] 1
> datai=gev(ibovespa[,4],15)$data
> predictive.gumbel(postibv,datai)
[1] 4.889710e-03 7.579767e-03 1.158679e-02 1.746824e-02 2.597531e-02
[6] 3.810192e-02 5.513922e-02 7.873367e-02 1.109457e-01 1.543051e-01
[11] 2.118588e-01 2.872048e-01 3.845073e-01 5.084876e-01 6.643849e-01
[16] 8.578846e-01 1.095012e+00 1.381991e+00 1.725074e+00 2.130342e+00
[21] 2.603489e+00 3.149599e+00 3.772919e+00 4.476657e+00 5.262785e+00
[26] 6.131898e+00 7.083096e+00 8.113925e+00 9.220364e+00 1.039686e+01
[31] 1.163643e+01 1.293077e+01 1.427044e+01 1.564508e+01 1.704361e+01
[36] 1.845447e+01 1.986587e+01 2.126602e+01 2.264334e+01 2.398671e+01
[41] 2.528560e+01 2.653025e+01 2.771182e+01 2.882244e+01 2.985532e+01
[46] 3.080478e+01 3.166626e+01 3.243632e+01 3.311259e+01 3.369375e+01
[51] 3.417945e+01 3.457026e+01 3.486756e+01 3.507346e+01 3.519072e+01
[56] 3.522268e+01 3.517311e+01 3.504619e+01 3.484638e+01 3.457838e+01
[61] 3.424702e+01 3.385725e+01 3.341400e+01 3.292223e+01 3.238679e+01
[66] 3.181244e+01 3.120380e+01 3.056531e+01 2.990124e+01 2.921564e+01
[71] 2.851235e+01 2.779496e+01 2.706688e+01 2.633122e+01 2.559091e+01
[76] 2.484863e+01 2.410683e+01 2.336775e+01 2.263342e+01 2.190565e+01
[81] 2.118609e+01 2.047618e+01 1.977720e+01 1.909026e+01 1.841633e+01
[86] 1.775622e+01 1.711064e+01 1.648015e+01 1.586522e+01 1.526619e+01
[91] 1.468334e+01 1.411685e+01 1.356683e+01 1.303330e+01 1.251624e+01
[96] 1.201559e+01 1.153119e+01 1.106289e+01 1.061047e+01 1.017369e+01
[101] 9.752279e+00 9.345945e+00 8.954370e+00 8.577223e+00 8.214158e+00
[106] 7.864819e+00 7.528842e+00 7.205856e+00 6.895486e+00 6.597357e+00
[111] 6.311091e+00 6.036313e+00 5.772650e+00 5.519731e+00 5.277193e+00
[116] 5.044674e+00 4.821821e+00 4.608286e+00 4.403731e+00 4.207821e+00
[121] 4.020234e+00 3.840652e+00 3.668768e+00 3.504283e+00 3.346906e+00
[126] 3.196355e+00 3.052357e+00 2.914649e+00 2.782974e+00 2.657085e+00
[131] 2.536744e+00 2.421720e+00 2.311791e+00 2.206744e+00 2.106371e+00
[136] 2.010476e+00 1.918866e+00 1.831358e+00 1.747776e+00 1.667949e+00
[141] 1.591716e+00 1.518919e+00 1.449409e+00 1.383041e+00 1.319678e+00
[146] 1.259186e+00 1.201440e+00 1.146316e+00 1.093700e+00 1.043479e+00
[151] 9.955455e-01 9.497983e-01 9.061392e-01 8.644743e-01 8.247140e-01
[156] 7.867725e-01 7.505678e-01 7.160213e-01 6.830581e-01 6.516065e-01
[161] 6.215978e-01 5.929666e-01 5.656502e-01 5.395888e-01 5.147251e-01
[166] 4.910047e-01 4.683752e-01 4.467869e-01 4.261922e-01 4.065456e-01
[171] 3.878037e-01 3.699250e-01 3.528700e-01 3.366009e-01 3.210816e-01
[176] 3.062777e-01 2.921564e-01 2.786862e-01 2.658372e-01 2.535808e-01
[181] 2.418898e-01 2.307381e-01 2.201009e-01 2.099545e-01 2.002763e-01
[186] 1.910447e-01 1.822391e-01 1.738399e-01 1.658282e-01 1.581864e-01
[191] 1.508972e-01 1.439444e-01 1.373125e-01 1.309866e-01 1.249527e-01
[196] 1.191972e-01 1.137074e-01 1.084709e-01 1.034760e-01 9.871155e-02
[201] 9.416696e-02 8.983204e-02 8.569711e-02 8.175293e-02 7.799069e-02
[206] 7.440198e-02 7.097879e-02 6.771347e-02 6.459873e-02 6.162761e-02
[211] 5.879347e-02 5.609000e-02 5.351115e-02 5.105117e-02 4.870457e-02
[216] 4.646611e-02 4.433080e-02 4.229387e-02 4.035078e-02 3.849721e-02
[221] 3.672900e-02 3.504223e-02 3.343314e-02 3.189814e-02 3.043380e-02
[226] 2.903688e-02 2.770425e-02 2.643295e-02 2.522016e-02 2.406316e-02
[231] 2.295940e-02 2.190641e-02 2.090184e-02 1.994348e-02 1.902918e-02
[236] 1.815692e-02 1.732476e-02 1.653085e-02 1.577342e-02 1.505080e-02
[241] 1.436138e-02 1.370363e-02 1.307610e-02 1.247738e-02 1.190616e-02
[246] 1.136117e-02 1.084120e-02 1.034509e-02 9.871755e-03 9.420140e-03
[251] 8.989247e-03 8.578122e-03 8.185856e-03 7.811581e-03 7.454469e-03
[256] 7.113731e-03 6.788615e-03 6.478401e-03 6.182405e-03 5.899974e-03
[261] 5.630483e-03 5.373338e-03 5.127973e-03 4.893844e-03 4.670438e-03
[266] 4.457260e-03 4.253842e-03 4.059735e-03 3.874512e-03 3.697765e-03
[271] 3.529105e-03 3.368161e-03 3.214578e-03 3.068020e-03 2.928163e-03
[276] 2.794701e-03 2.667340e-03 2.545800e-03 2.429816e-03 2.319131e-03
[281] 2.213503e-03 2.112701e-03 2.016502e-03 1.924698e-03 1.837085e-03
[286] 1.753472e-03 1.673676e-03 1.597523e-03 1.524844e-03 1.455483e-03
[291] 1.389285e-03 1.326108e-03 1.265811e-03 1.208265e-03 1.153343e-03
[296] 1.100924e-03 1.050896e-03 1.003147e-03 9.575742e-04 9.140780e-04
[301] 8.725634e-04
>
>
>
>
>
> dev.off()
null device
1
>