A blog for physicists or biologists. Mainly for experimentalists interested in Statistics. R scripts detailed and explained.
Associate Professor at Université de Paris
Change point detection. Part III : multiple change points and states
In a time series, change point detection tries to identify abrupt changes. In a previous post we have learned how to identify single change points using likelihood estimates and AIC values. Here, I show how to identify multiple change points states (i.e. statistically identical data).
# packages rm(list=ls()) # clear memory if (!require(ggplot2)) install.packages('ggplot2')
R is not just for statistics. It is also a powerful tool for manipulating and displaying data.
I have the feeling that students sometimes think R is just for statistics. But R is also a perfect environment for organizing and displaying data without doing fancy statistics. That is what I show here using real data and taking advantage of the famous yet powerful package tidyverse.
rm(list = ls()) if (!require(tidyverse)) install.packages('tidyverse')
Change point detection. Part II : maximum likelihood estimates
In a time series, change point detection tries to identify abrupt changes. Different approaches have been proposed and here I show one of them based on maximum likelihood estimates. I also recommend to have a look at this website (which is a wonderful introduction to change point detection using Likelihood ratio tests) and this R package from R. Killick and I.A. Eckley.Data
Let's start and define some parameters (I will come back to this latter) and generate some data.
rm(list = ls()) # parameters penalty<-10 # Delta AIC penalty display<-1 # display all graphs during calculations (good to see what is going on) sd<-1 # sd is known and set here as 1 # data set.seed(50) values<-c(rnorm(200,10,sd),rnorm(200,2.1,sd))
Change point detection. Part I : rolling t-test
In a time series, change point detection tries to identify abrupt changes. Different approaches have been proposed and here I show one of them based on a simple rolling t-test.
For this example, I use ggplot2 and so you need to enter:
rm(list = ls()) if (!require(ggplot2)) install.packages('ggplot2')