Model with Open Source Software: and Friends Dr. Heiko Frings Mathematical isk Consulting Bern, 01.09.2011
Agenda in a Friends Model with & Friends o o o Overview First instance: An Extreme Value Example Second instance: Gibbs Sampling with WinBUGS 2
3
Friends Model Instance 1 Instance 2 in a is an integrated frame of open source software (GNU) for effective data handling and data storage calculations on arrays statistical data analysis sophisticated graphical display object oriented programming language is used by thousands of people, worldwide and from a all kind of disciplines. Among them: Biostatistics, Medical Science, Geostatistics, Meteorology, Finance. 4
Friends Model Instance 1 Instance 2 in a / Some History The syntax of is very similar to S. S his hand, was initiated in 1976 as an internal statistical analysis environment. Version 4 the version we use today- of S language was released in 1998. Insightful and since 2008 TIBCO sells its implementation of the S language under the product name S-PLUS. The future of S-PLUS is uncertain. In 1991 oss Ihaka and obert Gentleman created. In 1993 there was the first announcement of to the public. Since 1995 is a free software under the GNU General Public License. The Core Group which controls the source code of was formed in 1997. 5
6
Friends Model Instance 1 Instance 2 There are thousands of additional packages available. Some of the most important ones from a model calibration point of view are shown on the next slide. This overview is by far not complete and the choice is (unavoidable) somewhat subjective. 7
Friends Model Instance 1 Instance 2 8
Friends Model Instance 1 Instance 2 9
Friends 10
Friends Model Example 1 Example 2 GUIS In terms of a user friendly GUI comes very naked. But, meanwhile there is a range of quite useful and free of charge available GUIS Commander Studio Various packages for creating simple GUIS are available. Nacked GUI Screenshot from Commander Screenshot from Studio 11
Friends Model Example 1 Example 2 (-) Workflows Analytic Flow ed KNIME. 12
Friends Model Instance 1 Instance 2 WinBUGS The BUGS (Bayesian Inference Using Gibbs Sampling) project is concerned with flexible software for the Bayesian analysis of complex statistical models using Markov Chain Monte Carlo (MCMC) methods. The project began in 1989 in the MC Biostatistics Unit and led initially to the `Classic' BUGS program, and then onto the WinBUGS software developed jointly with the Imperial College School of Medicine at St Mary's, London. The 2WinBUGS package provides convenient method to call WinBUGS from. Coda package: Output analysis and diagnostics for MCMC 13
Friends Model Instance 1 Instance 2 Some Interfaces Combining with L A T E X: SWEAVE Communication between and Excel: and Word: Excel Word Interface with KNIME Interface with the editor Tinn 14
Model 15
Friends Model Instance 1 Instance 2 Some Important functions for Purposes optim{stats} General-purpose optimization based on Nelder Mead, quasi-newton and conjugate-gradient algorithms. mle {stats4} Estimate parameters by the method of maximum likelihood. mle is a wrapper around optim mle2 {bbmle} Improved version of mle fitdist {fitdistrplus} Convenient function to fit univariate distributions 16
Friends Model Example 1 Example 2 An Extreme Value Example Data input: simple vector of loss data Some Explorative Statistics Decide on a treshhold using an Me Plot / Hill Plot Fit a GPD Test quality of fit un some simulations 17
Friends Model Example 1 Example 2 An Extreme Value Example 18
Friends Model Example 1 Example 2 An Extreme Value Example 19
Friends Model Instance 1 Instance 2 Gibbs Sampling with WinBUGS Gibbs sampling is an algorithm to generate a sequence of samples from the joint probability distribution of two or more random variables. It is one of the simplest Markov chain Monte Carlo algorithms. The algorithm is named after the physicist J. W. Gibbs, in reference to an analogy between the sampling algorithm and statistical physics. Geman and Geman 1984, Gelfand and Smith 1990. WinBUGS is a specialized software to run the Gibbs Sampler on hirarchical model structures. David P.M Scollnick described various actuarial application of WinBUGS. 20
Friends Model Instance 1 Instance 2 Gibbs Sampling with WinBUGS Specify an initial value X = (X 0 1 X 0 2, X 0 3..,X 0 k ) epeat for j = 0,,n Sample X j+1 1 from ψ(x 1 X j 2, X j 3..,X j k ) Sample X j+1 2 from ψ(x 2 X j+1 1, X j 3,..,X j k ) Sample X j+1 k from ψ(x p X j+1 1, X j+1 3,..,X j+1 k-1 )... 21
Friends Model Instance 1 Instance 2 Gibbs Sampling with WinBUGS Gibbs sampling algorithm in two dimensions starting from an initial point and then completing three iterations 2 3 1 0 22
Friends Model Instance 1 Instance 2 Fit Loss Severity in WinBUGS There are to enable the communication between and WinBUGS: 2WinBUGS, Brugs, coda. Let s have a look at this simple example inside the software..
Use! 24