University of Bologna & UnipolSai Assicurazioni

Slides:



Advertisements
Similar presentations
Markov chains. Probability distributions Exercise 1.Use the Matlab function nchoosek(n,k) to implement a generic function BinomialPMF(k,n,p) for calculating.
Advertisements

1 Introduction to Discrete-Time Markov Chain. 2 Motivation  many dependent systems, e.g.,  inventory across periods  state of a machine  customers.
Markov chains Assume a gene that has three alleles A, B, and C. These can mutate into each other. Transition probabilities Transition matrix Probability.
. Markov Chains. 2 Dependencies along the genome In previous classes we assumed every letter in a sequence is sampled randomly from some distribution.
Discrete Time Markov Chains
STAT 497 APPLIED TIME SERIES ANALYSIS
. Computational Genomics Lecture 7c Hidden Markov Models (HMMs) © Ydo Wexler & Dan Geiger (Technion) and by Nir Friedman (HU) Modified by Benny Chor (TAU)
Андрей Андреевич Марков. Markov Chains Graduate Seminar in Applied Statistics Presented by Matthias Theubert Never look behind you…
Markov Chains Ali Jalali. Basic Definitions Assume s as states and s as happened states. For a 3 state Markov model, we construct a transition matrix.
Continuous Time Markov Chains and Basic Queueing Theory
Hidden Markov Models Fundamentals and applications to bioinformatics.
Tutorial 8 Markov Chains. 2  Consider a sequence of random variables X 0, X 1, …, and the set of possible values of these random variables is {0, 1,
Symbolic dynamics of Markov chains P S Thiagarajan School of Computing National University of Singapore Joint work with: Manindra Agrawal, S Akshay, Blaise.
Overview of Markov chains David Gleich Purdue University Network & Matrix Computations Computer Science 15 Sept 2011.
048866: Packet Switch Architectures Dr. Isaac Keslassy Electrical Engineering, Technion Review.
5. CONCLUSIONS Initially constructed and applied for the New York State’s rainfall stations (Wilks, 1998), DUM was able to reproduce its good performance.
Chapter 4: Stochastic Processes Poisson Processes and Markov Chains
Programme in Statistics (Courses and Contents). Elementary Probability and Statistics (I) 3(2+1)Stat. 101 College of Science, Computer Science, Education.
YAP: Yet Another Puzzle Boudewijn R. Haverkort November 16, 2007.
CSE 221: Probabilistic Analysis of Computer Systems Topics covered: Course outline and schedule Introduction Event Algebra (Sec )
CSE 221: Probabilistic Analysis of Computer Systems Topics covered: Course outline and schedule Introduction (Sec )
CSE 221: Probabilistic Analysis of Computer Systems Topics covered: Discrete time Markov chains (Sec )
CSE 3504: Probabilistic Analysis of Computer Systems Topics covered: Discrete time Markov chains (Sec )
Markov Chains Chapter 16.
Stochastic Process1 Indexed collection of random variables {X t } t   for each t  T  X t is a random variable T = Index Set State Space = range.
CS6800 Advanced Theory of Computation Fall 2012 Vinay B Gavirangaswamy
DynaTraffic – Models and mathematical prognosis
ALGORITHMIC TRADING Hidden Markov Models. Overview a)Introduction b)Methodology c)Programming codes d)Conclusion.
Overview G. Jogesh Babu. Probability theory Probability is all about flip of a coin Conditional probability & Bayes theorem (Bayesian analysis) Expectation,
General information CSE : Probabilistic Analysis of Computer Systems
Monte Carlo Methods Versatile methods for analyzing the behavior of some activity, plan or process that involves uncertainty.
Generalized Linear Models All the regression models treated so far have common structure. This structure can be split up into two parts: The random part:
Computational Intelligence: Methods and Applications Lecture 12 Bayesian decisions: foundation of learning Włodzisław Duch Dept. of Informatics, UMK Google:
Extreme Value Theory: Part II Sample (N=1000) from a Normal Distribution N(0,1) and fitted curve.
Theory of Computations III CS-6800 |SPRING
Data Collection & Sampling Dr. Guerette. Gathering Data Three ways a researcher collects data: Three ways a researcher collects data: By asking questions.
CS433 Modeling and Simulation Lecture 07 – Part 01 Continuous Markov Chains Dr. Anis Koubâa 14 Dec 2008 Al-Imam.
The generalization of Bayes for continuous densities is that we have some density f(y|  ) where y and  are vectors of data and parameters with  being.
FORECASTING METHODS OF NON- STATIONARY STOCHASTIC PROCESSES THAT USE EXTERNAL CRITERIA Igor V. Kononenko, Anton N. Repin National Technical University.
1 Chapter 8: Model Inference and Averaging Presented by Hui Fang.
CS433 Modeling and Simulation Lecture 11 Continuous Markov Chains Dr. Anis Koubâa 01 May 2009 Al-Imam Mohammad Ibn Saud University.
Stochastic Processes and Transition Probabilities D Nagesh Kumar, IISc Water Resources Planning and Management: M6L5 Stochastic Optimization.
Hypothesis Testing. Statistical Inference – dealing with parameter and model uncertainty  Confidence Intervals (credible intervals)  Hypothesis Tests.
Introduction We consider the data of ~1800 phenotype measurements Each mouse has a given probability distribution of descending from one of 8 possible.
How many iterations in the Gibbs sampler? Adrian E. Raftery and Steven Lewis (September, 1991) Duke University Machine Learning Group Presented by Iulian.
Flows and Networks (158052) Richard Boucherie Stochastische Operations Research -- TW wwwhome.math.utwente.nl/~boucherierj/onderwijs/158052/ html.
Overview G. Jogesh Babu. R Programming environment Introduction to R programming language R is an integrated suite of software facilities for data manipulation,
Hierarchical Models. Conceptual: What are we talking about? – What makes a statistical model hierarchical? – How does that fit into population analysis?
Missing data: Why you should care about it and what to do about it
Probabilistic Analysis of Computer Systems
Discrete-time Markov chain (DTMC) State space distribution
Markov Chain Hasan AlShahrani CS6800
Chapter 7. Classification and Prediction
Introduction to Programming for Mechanical Engineers (ME 319)
Advanced Statistical Computing Fall 2016
Prof. Dr. Holger Schlingloff 1,2 Dr. Esteban Pavese 1
Overview G. Jogesh Babu.
When we free ourselves of desire,
Discrete-time markov chain (continuation)
Nonparametric Statistical Methods: Overview and Examples
Chapman-Kolmogorov Equations
Nonparametric Statistical Methods: Overview and Examples
Ch13 Empirical Methods.
Communication and Coding Theory Lab(CS491)
The chain of Andrej Markov and its applications NETWORKS goes to school - April 23, 2018 Jan-Pieter Dorsman.
The Most General Markov Substitution Model on an Unrooted Tree
Discrete-time markov chain (continuation)
Discrete-time markov chain (continuation)
CS723 - Probability and Stochastic Processes
CS723 - Probability and Stochastic Processes
Presentation transcript:

University of Bologna & UnipolSai Assicurazioni The markovchain R package Giorgio A. Spedicato University of Bologna & UnipolSai Assicurazioni Abstract Representing DTMCs Simulation, estimation and inference Non-homogeneous DTMCs The markovchain s4 method wraps plot functions from igraph and DiagrammeR packages Discrete Time Markov Chains (DTMCs) represent a notable class of stochastic processes. Whilst their basic theory is rather simple, they are extremely effective to model categorical data sequences. Notable applications can be found in linguistic, information theory, life sciences, economics and sociology . The markovchain package aims to fill a gap within CRAN ecosystem providing an unified infrastructure to easily manage DTMC and to perform statistical and probabilistic analyses on Markov chains stochastic processes. The markovchain package contains S4 classes and methods that allow to create and manage homogeneous and non - homogeneous DTMC straightforwardly. This means that DTMCs can be created, represented and exported using an approach natural and intuitive for any R programmer. At the same time, it provides functions to perform structural analysis of transition matrices (that means classification of matrices and states, analysis of the stationary distribution, periodicity, etc...). In addition, it provides methods to estimate transition matrix from data and to perform some inference (confidence intervals calculations), statistical tests on the order and stationarity, etc... Finally embryonic procedures for Bayesian modeling of DTMCs, continuous time Markov Chains and higher order ones has been started to be provided. Given a markovchain object, simulating a stochastic sequence given a transition matrix is straightforward Non-homogeneous DTMCs help when transition probabilities across states structurally change during time. They are represented by an implicity ordered list of markovchain objects. plot(mcWeather,main="Weather transition matrix") plot(mcWeather, package = "DiagrammeR", label = "Weather transition matrix") dailyWeathers<-rmarkovchain(n=365,object=mcWeather, t0=“sunny”) dailyWeathers[1:7] "sunny" "sunny" "sunny" "sunny" "nice" "rainy" "rainy" mcC=as(matrix(data=c(0.1,.9,.5,.5),byrow=2,nrow=2),"markovchain") mcA=as(matrix(data=c(0.4,.6,.1,.9),byrow=2,nrow=2),"markovchain") mcB=as(matrix(data=c(0.2,.8,.2,.8),byrow=2,nrow=2),"markovchain") > myMcList=new("markovchainList",markovchains=list(mcA,mcB,mcC)) myMcList list of Markov chain(s) Markovchain 1 Unnamed Markov chain A 2 - dimensional discrete Markov Chain with following states: s1, s2 The transition matrix (by rows) is defined as follows: s1 s2 s1 0.4 0.6 s2 0.1 0.9 Markovchain 2 s1 0.2 0.8 s2 0.2 0.8 Markovchain 3 s1 0.1 0.9 s2 0.5 0.5 The markovchainFit function allows to estimate the underlying transition matrix for a given character sequence. Asymptotic standard error and MLE confidence intervals are given by default. Objective mleFit<-markovchainFit(data=dailyWeathers) mleFit $estimate nice rainy sunny nice 0.0000000 0.4864865 0.5135135 rainy 0.2406015 0.4586466 0.3007519 sunny 0.2675159 0.2229299 0.5095541 $standardError nice rainy sunny nice 0.00000000 0.08108108 0.08330289 rainy 0.04253274 0.05872368 0.04755305 sunny 0.04127860 0.03768204 0.05696988 $confidenceInterval $confidenceInterval$confidenceLevel [1] 0.95 $confidenceInterval$lowerEndpointMatrix nice 0.0000000 0.3531200 0.3764924 rainy 0.1706414 0.3620548 0.2225341 sunny 0.1996187 0.1609485 0.4158470 $confidenceInterval$upperEndpointMatrix nice 0.0000000 0.6198530 0.6505346 rainy 0.3105616 0.5552385 0.3789697 sunny 0.3354132 0.2849114 0.6032613 $logLikelihood [1] -354.3094 Develop an easy-to-use software package that permits to perform most common statistical analyses on Markov Chains. Structural analysis of DTMCs The package allows to perform structural analysis of DTMCs, thanks to an algorithm by (Feres, 2007) ported from Matlab. Creating and operating with DTMCs require(matlab) mathematicaMatr <- zeros(5) mathematicaMatr[1,] <- c(0, 1/3, 0, 2/3, 0) mathematicaMatr[2,c(1,5)] <- 0.5 mathematicaMatr[c(3,4),c(3,4)] <- 0.5 mathematicaMatr[5,5] <- 1 mathematicaMc <- new("markovchain", transitionMatrix = mathematicaMatr, name = "Mathematica MC") names(mathematicaMc)<-LETTERS[1:5] #the summary method provides an overview of structural characteristics of DTMCs summary(mathematicaMc) Mathematica MC Markov chain that is composed by: Closed classes: C D E Recurrent classes: {C,D},{E} Transient classes: {A,B} The Markov chain is not irreducible The absorbing states are: E Creating DTMCs S4 classes is extremely easy Function for simulate from and fit markovchainList are available as well ##create a DTMC object library(markovchain) #defining a Transition Matrix weatherStates <- c("rainy", "nice", "sunny") weatherMatrix <- matrix(data = c(0.50,0.25, 0.25,0.5, 0.0, 0.5, 0.25, 0.25, 0.5), byrow = TRUE, nrow = 3,dimnames = list(weatherStates, weatherStates)) #create the DTMC (long and short way) #long way mcWeather <- new("markovchain", states = weatherStates, byrow = TRUE, transitionMatrix = weatherMatrix,name = "Weather") mcWeather2<-as(mcWeather, "markovchain") name(mcWeather2)<-"Weather Mc" mcWeather2 Weather Mc A 3 - dimensional discrete Markov Chain defined by the following states: rainy, nice, sunny The transition matrix (by rows) is defined as follows: rainy nice sunny rainy 0.50 0.25 0.25 nice 0.50 0.00 0.50 sunny 0.25 0.25 0.50 mcListSims<-rmarkovchain(n=1000,object=myMcList,what="matrix") head(mcListSims,3) [,1] [,2] [,3] [1,] "s2" "s2" "s1" [2,] "s2" "s1" "s2" [3,] "s2" "s2" "s1" myMcListFit<-markovchainListFit(data=mcListSims) myMcListFit$estimate list of Markov chain(s) Markovchain 1 Unnamed Markov chain A 2 - dimensional discrete Markov Chain with following states: s1, s2 The transition matrix (by rows) is defined as follows: s1 s2 s1 0.2326203 0.7673797 s2 0.2220447 0.7779553 Markovchain 2 s1 0.3584071 0.6415929 s2 0.3552972 0.6447028 Various functions have been defined at this purpose. #checking accessibility is.accessible(mathematicaMc,from = "A","E") TRUE is.accessible(mathematicaMc,from = "C","E") FALSE #canonic form myCanonicForm<-canonicForm(mathematicaMc) Mathematica MC A 5 - dimensional discrete Markov Chain defined by the following states: C, D, E, A, B The transition matrix (by rows) is defined as follows: C D E A B C 0.5 0.5000000 0.0 0.0 0.0000000 D 0.5 0.5000000 0.0 0.0 0.0000000 E 0.0 0.0000000 1.0 0.0 0.0000000 A 0.0 0.6666667 0.0 0.0 0.3333333 B 0.0 0.0000000 0.5 0.5 0.0000000 #periodicity period(mathematicaMc) Warning message: In period(mathematicaMc) : The matrix is not irreducible period(as(matrix(c(0,1,1,0),nrow = 2),"markovchain")) Algebraic and logical operations can be easily performed Algebraic and logical operations can be naturally performed: #equality mcWeather == mcWeather2 TRUE #exponentiation mcWeather^2 Weather Mc^2 A 3 - dimensional discrete Markov Chain defined by the following states: rainy, nice, sunny The transition matrix (by rows) is defined as follows: rainy nice sunny rainy 0.4375 0.1875 0.3750 nice 0.3750 0.2500 0.3750 sunny 0.3750 0.1875 0.4375 Acknowledgements In addition to maximum likelihood, estimates can be obtained by bootstrap and bayesian approaches. Special thanks are given to: the Google Summer of Code Project (2015-2016 sessions) and the many users that continuously return feedbacks, suggestions and bugs checks. Steady state distribution(s) can be easily found as well #finding the steady state steadyStates(mcWeather) rainy nice sunny 0.4 0.2 0.4 Contact information For further information please contact Giorgio A. Spedicato (spedicato_giorgio@yahoo.it). This poster is available upon request.