Learn R Programming

EBS (version 2.8)

EBSegmentation: Exact Bayesian Segmentation for Poisson, Negative Binomial and Normal models

Description

Calculates the bayesian probability of each segmentation in 1 to Kmax segments (assuming the data is poisson, normal or negative binomial distributed) and returns object of class EBS.

Usage

EBSegmentation(data=numeric(), model=1, Kmax = 15, hyper = numeric(), 

theta = numeric(), var = numeric(), unif= TRUE)

Arguments

data
A vector containing the data within which you wish to find changepoints.
model
Model under which data is assumed to be distributed. Possible values are 1 for Poisson, 2 for Normal Homoscedastic, 3 for Negative Binomial and 4 for Normal Heteroscedastic.
Kmax
The maximum number of segments for the segmentation. Function will find explore the set of all possible segmentations in k segments for k in 1 to Kmax.
hyper
The set of hyper-parameters for the prior on the data-distribution. If model is Poisson the conjugate law is Gamma and 2 parameters are needed. If model is Negative Binomial the conjugate is Beta and 2 parameters are needed. If model is Normal the prior o
theta
If model=3 (Negative binomial), the value of the inverse of the overdispersion parameter. If the user does not give his own hyperparameters, the package uses a modified version of Johnson and Kotz's estimator where the mean is replaced by the median.
var
If model=2 (Normal Homoscedastic), the value of the variance. If the user does not give his own hyperparameters, the package uses Hall's estimator whith d=4.
unif
A boolean stating whether prior on segmentation is uniform given number of segments. If false, then the prior favors segmentation with segments of equal length, i.e. n_r is proportional to the inverse of segment length.

Value

  • An object of class "EBS".
  • modelEmission distribution (Poisson, Normal Homoscedastic, Negative Binomial or Normal Heteroscedastic)
  • lengththe length of the data-set
  • Kmaxthe maximum number of segments for the segmentation
  • HyperParametersThe hyperparameters used for the prior on the data distribution
  • Lia matrix of size Kmax*(length+1). Element [i,j] is the log-probability of interval [1,j[ being segmented in i segments
  • Cola matrix of size (length+1)*Kmax. Element [i,j] is the log-probability of interval [i,n] being segmented in j segments
  • matProbaa matrix of size (length+1)*(length+1). Element [i,j] is the log-probability of interval [i,j[

Details

This function is used to compute the matrix of segment probabilities assuming data is poisson, normal or negative binomial distributed. The probability of each interval being divided in k segments (k in 1 to Kmax) is computed.

References

Rigaill, Lebarbier & Robin: Exact posterior distributions over the segmentation space and model selection for multiple change-point detection problems

Johnson, Kotz & Kemp: Univariate Discrete Distributions

Hall, Kay & Titterington: Asymptotically optimal difference-based estimation of variance in non-parametric regression

See Also

EBS-class, EBSDistrib, EBSProfiles

Examples

Run this code
# changes for Poisson model
set.seed(1)
x<-c(rpois(125,1),rpois(100,5),rpois(50,1),rpois(75,5),rpois(50,1))
out <- EBSegmentation(x,model=1,Kmax=20)

Run the code above in your browser using DataLab