Top Banner
Statistics and Operational Research Doctoral Training Centre Lancaster University Changepoints for a Range Of PenaltieS using the changepoint R package Kaylea Haynes Supervised by: Idris Eckley, Paul Fearnhead and Ralph Mansson useR! 2015 Aalborg July 2015
28

C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Jul 21, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Statistics and Operational ResearchDoctoral Training CentreLancaster University

Changepoints for a Range Of PenaltieS using thechangepoint R package

Kaylea HaynesSupervised by: Idris Eckley, Paul Fearnhead and Ralph ManssonuseR! 2015 Aalborg

July 2015

Page 2: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Overview

I changepoint: An R package for changepoint analysisI Version: 2.0I Author: Rebecca Killick [aut, cre], Kaylea Haynes [aut], Idris Eckley

[aut] and Paul Fearnhead [ctb]

I Multiple changepoint search methodsI Binary SegmentationI Pruned Exact Linear Time (PELT)I Changepoints for a Range of Penalties (CROPS)

(Killick et al. 2014, Killick and Eckley 2014)

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 3: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Changepoint Detection

For data y1, ..., yn, a changepoint is a location τ where the statisticalproperties of y1, ..., yτ differ from those of yτ+1, ..., yn.

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 4: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Segment Costs

Common costs

m+1∑i=1

[Cy(τi−1+1):τi ] + βm

I cpt.mean(data,...)

I cpt.var(data,...)

I cpt.meanvar(data,...)

test.stat: "Normal", "Gamma", "Exponential" and

"Poisson".

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 5: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Optimal Partitioning

Recursion

F (t) = minτ∈τt

{m+1∑i=1

[C(y(τi−1+1):τi ) + β]

}= min

s∈{0,...,t−1}{F (s) + C(y(s+1):n) + β}

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 6: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Optimal Partitioning

ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss0

5

10

15

0 100 200 300

Index

Dat

a

tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt0

50

100

150

200

0 100 200 300

Index

Last

Cha

nge

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 7: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Optimal Partitioning

4

8

12

16

0 100 200 300

Index

Dat

a

0

50

100

150

200

0 100 200 300

Index

Last

Cha

nge

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 8: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

PELT

tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss0

5

10

15

0 100 200 300

Index

Dat

a

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 9: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

PELT

Pruning

If there exists a constant K such that for all s < t < T

C(y(s+1):t) + C(y(t+1):T ) + K ≤ C(y(s+1):T ),

and for t > s, if

F (s) + C(y(s+1):t) + K ≥ F (t),

then at a future time T > t, s can never be the optimal last changepointprior to T .

cpt.var(data, penalty, pen.value, test.stat, method =

"PELT", minseglen)

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 10: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Penalty

cpt.var(data, penalty, pen.value, test.stat, method,

minseglen)

I “None”

I “SIC” or “BIC”

I “MBIC”

I “AIC”

I “Hannan-Quinn”

I “Asymptotic”

I “Manual”: pen.value = ?

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 11: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Penalty

4

8

12

16

0 100 200 300

Index

Dat

a

Penalty = 2

4

8

12

16

0 100 200 300

Index

Dat

a

Penalty = 100

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 12: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Changepoints for a Range of PenaltieS(CROPS).

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 13: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Step 1: Run algorithm* for βmin and βmax

If both the segmentations have the same number of changepoints:STOP.The optimal number of changepoints decreases as β increases. So allvalues of β ∈ [βmin, βmax ] will have the same optimal segmentation.

* Optimal Partitioning (Jackson et al 2005) or PELT (Killick et al(2012)).

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 14: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Step 2: Compare the number of changepoints

If the number of changepoints differs by 1, m(βmin) = m(βmax) + 1:STOP.

5.0 5.5 6.0 6.5 7.0 7.5 8.0

510

1520

25

beta

(Pen

alis

ed)

log−

likel

ihoo

d

X

X

3

2

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 15: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Step 2: Compare the number of changepoints

Otherwise calculate the point of intercept β∗, and run CPD algorithmwith this value.

5 6 7 8 9 10

510

1520

25

beta

(Pen

alis

ed)

log−

likel

ihoo

d

X

X

3

1

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 16: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Step 3: Check if new Optimal Segmentation

If the optimal segmentation for β∗ is the same as for βmin or βmax :STOP.

5 6 7 8 9 10

510

1520

25

beta

(Pen

alis

ed)

log−

likel

ihoo

d

X

X

3

1

X3

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 17: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Step 3: Check if new Optimal Segmentation

Otherwise, treat the intervals [βmin, β∗] and [β∗, βmax ] separately and

process using Step 2.

5 6 7 8 9 10

510

1520

25

beta

(Pen

alis

ed)

log−

likel

ihoo

d

X

X

3

1

X2

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 18: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Final Solution

10

11

12

13

14

15

16

789

775

800

825

850

6 7 8 9 10 11Beta

Co

st

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 19: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

CROPS

cpt.mean(data, penalty, pen.value = c(0,10), test.stat,

method = "PELT", minseglen)

if (length(pen.value == 2){return(CROPS(data, pen.value, test.stat, minseglen, func=”mean”))}

(Haynes et al. (2014))

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 20: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

CROPS - Example output

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 21: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

CROPS - Example output

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 22: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Example

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 23: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Example

I Changes in nuclear magnetic response as a probe is lowered down abore-hole into the Earth’s surface.

I Change in mean with σ̂2 = median absolute distance

100000

110000

120000

130000

140000

0 1000 2000 3000 4000index

Well−log data

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 24: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Example

100000

110000

120000

130000

140000

0 1000 2000 3000 4000

index

PELT with SIC (16.564)

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 25: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Example

●●●●

●●

●●

2e+10

4e+10

6e+10

8e+10

5 10 15 20 25

Number of Changepoints

Cos

t

100000

110000

120000

130000

140000

0 1000 2000 3000 4000

index

611.5720 − 1055.205

100000

110000

120000

130000

140000

0 1000 2000 3000 4000

index

1055.205 − 1116.312

100000

110000

120000

130000

140000

0 1000 2000 3000 4000

index

1116.312 − 1545.416

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 26: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Summary

I changepoint package has been updated to version 2.0.

I Penalty choiceI Default changed to MBICI Inclusion of CROPS - more appropriate to use a range of

segmenations rather than just using a single choiceI Popular choices such as the SIC lack robustness in the presence of

model mis-specification

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 27: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

Thank you for listening.

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk

Page 28: C R O PenaltieS using the R package - ADVANCE · R package version 2.0, 2015 (To appear very soon). Twitter: @storiKaylea Slides can be downloaded from: . Title: Changepoints for

Introduction CROPS Example

References

K. Haynes, I.A. Eckley and P. Fearnhead.Efficient penalty search for multiple changepoint problems.In Submission, arXiv:1412.3617, (2014)

B. Jackson and J.D. Sargle.An Algorithm for optimal partitioning of data on an interval.IEEE, Signal Processing Letters, 12(2):105–108, 2005.

R. Killick, P. Fearnhead and I.A. Eckley.Optimal detection of changepoints with a linear computational cost.JASA, 107, 1590-1598, 2012.

R. Killick, and I.A. Eckley.changepoint: An R package for changepoint analysis.Journal of Statistical Software, 58(3):1–19, 2014.

R. Killick, I.A. Eckley and K. Haynes.changepoint: An R package for changepoint analysis.R package version 2.0, 2015 (To appear very soon).

Twitter: @storiKaylea Slides can be downloaded from: www.khaynes.co.uk