robfilter an r package for robust time series filters
play

robfilter : An R-Package for Robust Time Series Filters Karen - PowerPoint PPT Presentation

robfilter : An R-Package for Robust Time Series Filters Karen Schettlinger, Roland Fried, Ursula Gather Fakult at Statistik UseR! The R User Conference 2008, August 12-14, Technische Universit at Dortmund i 1 i 1 Motivation q q


  1. i 1 i 1 robreg.filter – Illustration q q Rob ust reg ression in a moving time window: with delay: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● 2 ● 0 5 10 15 20 25 30 time online: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● 2 ● 0 5 10 15 20 25 30 time 3 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  2. i 1 i 1 robreg.filter – Illustration q q Rob ust reg ression in a moving time window: with delay: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● 2 ● 0 5 10 15 20 25 30 time online: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● 2 ● 0 5 10 15 20 25 30 time 3 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  3. i 1 i 1 robreg.filter – Illustration q q Rob ust reg ression in a moving time window: with delay: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● 2 ● 0 5 10 15 20 25 30 time online: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● 2 ● 0 5 10 15 20 25 30 time 3 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  4. i 1 i 1 robreg.filter – Illustration q q Rob ust reg ression in a moving time window: with delay: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● 2 ● 0 5 10 15 20 25 30 time online: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● 2 ● 0 5 10 15 20 25 30 time 3 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  5. i 1 i 1 robreg.filter – Illustration q q Rob ust reg ression in a moving time window: with delay: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● 2 ● 0 5 10 15 20 25 30 time online: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● 2 ● 0 5 10 15 20 25 30 time 3 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  6. i 1 i 1 robreg.filter – Illustration q q Rob ust reg ression in a moving time window: with delay: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● 2 ● 0 5 10 15 20 25 30 time online: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● 2 ● 0 5 10 15 20 25 30 time 3 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  7. i 1 i 1 robreg.filter – Illustration q q Rob ust reg ression in a moving time window: with delay: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● 2 ● 0 5 10 15 20 25 30 time online: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● 2 ● 0 5 10 15 20 25 30 time 3 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  8. i 1 i 1 robreg.filter – Illustration q q Rob ust reg ression in a moving time window: with delay: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● ● 2 ● 0 5 10 15 20 25 30 time online: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● ● 2 ● 0 5 10 15 20 25 30 time 3 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  9. i 1 i 1 robreg.filter – Illustration q q Rob ust reg ression in a moving time window: with delay: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● ● 2 ● ● 0 5 10 15 20 25 30 time online: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● ● 2 ● ● 0 5 10 15 20 25 30 time 3 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  10. i 1 i 1 robreg.filter – Illustration q q Rob ust reg ression in a moving time window: with delay: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● ● ● 2 ● ● 0 5 10 15 20 25 30 time online: ● ● 7 time series 6 ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● ● ● ● ● ● ● 3 ● ● ● ● ● ● ● ● 2 ● ● 0 5 10 15 20 25 30 time 3 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  11. i 1 i 1 robreg.filter – Illustration q q Rob ust reg ression in a moving time window: with delay: ● 7 time series 6 ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● 3 ● ● ● ● 2 ● 0 5 10 15 20 25 30 time online: ● 7 time series 6 ● ● ● 5 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 4 ● ● ● ● ● ● 3 ● ● ● ● 2 ● 0 5 10 15 20 25 30 time 3 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  12. i 1 i 1 robreg.filter – Parameter Options q q • Robust regression techniques robreg.filter(...,method=" ") Median MED Repeated Median RM (Siegel, 1982) Least Median of Squares LMS (Hampel, 1975; Rousseeuw, 1984) LTS Least Trimmed Squares (Rousseeuw, 1983) LQD Least Quartile Difference (Croux, Rousseeuw, H¨ ossjer, 1994) Deepest Regression DR (Rousseeuw and Hubert, 1999) 4 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  13. i 1 i 1 robreg.filter – Parameter Options q q • Robust regression techniques robreg.filter(...,method=" ") Median MED Repeated Median RM (Siegel, 1982) Least Median of Squares LMS (Hampel, 1975; Rousseeuw, 1984) Least Trimmed Squares LTS (Rousseeuw, 1983) Least Quartile Difference LQD (Croux, Rousseeuw, H¨ ossjer, 1994) Deepest Regression DR (Rousseeuw and Hubert, 1999) 4 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  14. i 1 i 1 robreg.filter – Parameter Options q q • Robust regression techniques robreg.filter(...,method=" ") Median MED Repeated Median RM (Siegel, 1982) Least Median of Squares LMS (Hampel, 1975; Rousseeuw, 1984) Least Trimmed Squares LTS (Rousseeuw, 1983) Least Quartile Difference LQD (Croux, Rousseeuw, H¨ ossjer, 1994) Deepest Regression DR (Rousseeuw and Hubert, 1999) • Window width ∈ N ( width ) 4 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  15. i 1 i 1 robreg.filter – Parameter Options q q • Robust regression techniques robreg.filter(...,method=" ") Median MED Repeated Median RM (Siegel, 1982) Least Median of Squares LMS (Hampel, 1975; Rousseeuw, 1984) Least Trimmed Squares LTS (Rousseeuw, 1983) Least Quartile Difference LQD (Croux, Rousseeuw, H¨ ossjer, 1994) Deepest Regression DR (Rousseeuw and Hubert, 1999) • Window width ∈ N ( width ) • Minimum number of non-missing observations within one window ( minNonNAs ) 4 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  16. i 1 i 1 robreg.filter – Parameter Options q q • Robust regression techniques robreg.filter(...,method=" ") Median MED Repeated Median RM (Siegel, 1982) Least Median of Squares LMS (Hampel, 1975; Rousseeuw, 1984) Least Trimmed Squares LTS (Rousseeuw, 1983) Least Quartile Difference LQD (Croux, Rousseeuw, H¨ ossjer, 1994) Deepest Regression DR (Rousseeuw and Hubert, 1999) • Window width ∈ N ( width ) • Minimum number of non-missing observations within one window ( minNonNAs ) • Online estimation ( online = TRUE / FALSE ) 4 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  17. i 1 i 1 robreg.filter – Parameter Options q q • Robust regression techniques Aliases robreg.filter(...,method=" ") Median MED med.filter Repeated Median RM rm.filter Least Median of Squares LMS lms.filter Least Trimmed Squares LTS lts.filter Least Quartile Difference LQD lqd.filter Deepest Regression DR dr.filter • Window width ∈ N ( width ) • Minimum number of non-missing observations within one window ( minNonNAs ) • Online estimation ( online = TRUE / FALSE ) 4 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  18. i 1 i 1 robreg.filter – Example q q Filter Output with Delay 10 MED LTS 8 LMS 6 4 2 0 0 10 20 30 40 50 60 time 10 LQD RM 8 DR 6 4 2 0 0 10 20 30 40 50 60 time 5 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  19. i 1 i 1 robreg.filter – Example q q Online Filter Output 10 MED LTS 8 LMS 6 4 2 0 0 10 20 30 40 50 60 time 10 LQD RM 8 DR 6 4 2 0 0 10 20 30 40 50 60 time 5 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  20. i 1 i 1 robreg.filter – Option extrapolate q q rm.filter(ts, width=11, extrapolate=FALSE, ... ) RM−Filter Output with Delay 10 8 online=FALSE 6 4 2 0 0 10 20 30 40 50 60 time Online RM−Filter Output 10 8 6 online=TRUE 4 2 0 0 10 20 30 40 50 60 time 6 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  21. i 1 i 1 robreg.filter – Option extrapolate q q rm.filter(ts, width=11, extrapolate=TRUE , ... ) RM−Filter Output with Delay 10 8 online=FALSE 6 4 2 0 0 10 20 30 40 50 60 time Online RM−Filter Output 10 8 6 online=TRUE 4 2 0 0 10 20 30 40 50 60 time 6 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  22. i 1 i 1 Repeated Median Regression q q hi (Siegel, 1982) y t = ( y t + i ) ′ Sample in one time window � �� � y t + i − y t + j � β RM = med med t i − j i j � = i � � y t + i + � µ RM β RM = med · i � t t i � − n + 1 , . . . , − 1 , 0 (online) with i = − m, . . . , m and n = 2 m + 1 (with delay) 7 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  23. i 1 i 1 hybrid.filter q q Application of ’subfilters’ to a moving time window y t = ( y t − m , . . . , y t − 1 , y t , y t +1 , . . . , y t + m ) ′ m = width − 1 with 2 8 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  24. i 1 i 1 hybrid.filter q q Application of ’subfilters’ to a moving time window y t = ( y t − m , . . . , y t − 1 , y t , y t +1 , . . . , y t + m ) ′ m = width − 1 with 2 Φ j ( y t ) , j = 1 , . . . , k , subfilters µ t = med { Φ 1 ( y t ) , Φ 2 ( y t ) , . . . , Φ k ( y t ) } ˆ Filter output 8 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  25. i 1 i 1 hybrid.filter q q Application of ’subfilters’ to a moving time window y t = ( y t − m , . . . , y t − 1 , y t , y t +1 , . . . , y t + m ) ′ m = width − 1 with 2 Φ j ( y t ) , j = 1 , . . . , k , subfilters µ t = med { Φ 1 ( y t ) , Φ 2 ( y t ) , . . . , Φ k ( y t ) } ˆ Filter output Parameters options: method , width , minNonNAs , and extrapolate Online estimation not possible!!! 8 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  26. i 1 i 1 hybrid.filter – Estimation in One Window q q 6 ● ● ● ● ● ● 4 ● 2 ● ● 0 ● ● ● ● ● ● t−m ... t−1 t t+1 ... t+m 9 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  27. i 1 i 1 hybrid.filter – Estimation in One Window q q FMH 6 ● ● ● ● ● ● ● ● mean ● ● ● ● y t 4 ● ● 2 ● ● ● ● 0 ● ● ● ● ● ● ● ● ● ● ● ● ● t−m ... t−1 t t+1 ... t+m 9 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  28. i 1 i 1 hybrid.filter – Estimation in One Window q q FMH 6 ● ● ● ● ● ● ● ● mean ● ● ● ● y t 4 ● ● 2 ● ● ● ● 0 ● ● ● ● ● ● ● ● ● ● ● ● ● t−m ... t−1 t t+1 ... t+m PFMH ● 6 ● ● ● ● ● ● ● LS ● ● ● ● y t 4 ● ● 2 ● ● ● ● 0 ● ● ● ● ● ● ● ● ● ● ● ● ● t−m ... t−1 t t+1 ... t+m 9 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  29. i 1 i 1 hybrid.filter – Estimation in One Window q q FMH 6 ● ● ● ● ● ● ● ● mean ● ● ● ● y t 4 ● ● 2 ● ● ● ● 0 ● ● ● ● ● ● ● ● ● ● ● ● ● t−m ... t−1 t t+1 ... t+m PFMH ● 6 ● ● ● ● ● ● ● LS ● ● ● ● y t 4 ● ● 2 ● ● ● ● 0 ● ● ● ● ● ● ● ● ● ● ● ● ● t−m ... t−1 t t+1 ... t+m CFMH 6 ● ● ● ● ● ● ● ● mean ● ● ● ● LS 4 y t ● ● 2 ● ● ● ● 0 ● ● ● ● ● ● ● ● ● ● ● ● ● t−m ... t−1 t t+1 ... t+m 9 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  30. i 1 i 1 hybrid.filter – Estimation in One Window q q MH 6 ● ● ● ● ● ● ● ● median ● ● ● ● y t 4 ● ● 2 ● ● ● ● 0 ● ● ● ● ● ● ● ● ● ● ● ● ● t−m ... t−1 t t+1 ... t+m PRMH ● 6 ● ● ● ● ● ● ● RM ● ● ● ● y t 4 ● ● 2 ● ● ● ● ● 0 ● ● ● ● ● ● ● ● ● ● ● ● t−m ... t−1 t t+1 ... t+m CRMH 6 ● ● ● ● ● ● ● ● median ● ● ● ● RM 4 y t ● ● 2 ● ● ● ● ● 0 ● ● ● ● ● ● ● ● ● ● ● ● t−m ... t−1 t t+1 ... t+m 9 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  31. i 1 i 1 hybrid.filter – Estimation in One Window q q MMH 6 ● ● ● ● ● ● ● ● median ● ● ● ● 4 ● ● 2 ● ● ● ● ● 0 ● ● ● ● ● ● ● ● ● ● ● ● t−m ... t−1 t t+1 ... t+m PRMMH ● 6 ● ● ● ● ● ● ● median ● ● ● ● RM 4 ● ● 2 ● ● ● ● ● 0 ● ● ● ● ● ● ● ● ● ● ● ● t−m ... t−1 t t+1 ... t+m CRMMH 6 ● ● ● ● ● ● ● ● median ● ● ● ● RM 4 ● ● 2 ● ● ● ● ● 0 ● ● ● ● ● ● ● ● ● ● ● ● t−m ... t−1 t t+1 ... t+m 9 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  32. i 1 i 1 dw.filter – Parameter Options q q D ouble w indow filtering techniques with Outer window width ( ∈ N ) outer.width Inner window width ( ∈ N , < outer.width ) inner.width Filter method(s) method Scale estimation method scale Trimming factor d Minimum number of non-missing observations minNonNAs within one window TRUE / FALSE for online / delayed estimation online TRUE / FALSE for extrapolation to the edges extrapolate 10 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  33. i 1 i 1 dw.filter – Estimation in One Window q q inner outer ● method 10 window window ● ● MED MEAN DWMTM 8 RM LS DWTRM ● 6 ● RM RM DWMRM RM RM DWRM 4 slope location ● 2 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 0 ● ● ● ● −2 t−15 t−10 t−5 t t+5 t+10 t+15 11 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  34. i 1 i 1 dw.filter – Estimation in One Window q q inner outer ● method 10 initial RM fit window window ● ● MED MEAN DWMTM 8 RM LS DWTRM ● 6 ● RM RM DWMRM inner window RM RM DWRM 4 slope location ● 2 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 0 ● ● ● ● −2 t−15 t−10 t−5 t t+5 t+10 t+15 11 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  35. i 1 i 1 dw.filter – Estimation in One Window q q inner outer ● method 10 initial RM fit window window ● ● MED MEAN DWMTM 8 RM LS DWTRM ● 6 ● RM RM DWMRM inner window RM RM DWRM 4 slope location ● 2 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 0 ● ● ● ● −2 t−15 t−10 t−5 t t+5 t+10 t+15 11 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  36. i 1 i 1 dw.filter – Estimation in One Window q q inner outer ● method 10 window window initial RM fit ● trimming boundaries ● MED MEAN DWMTM 8 RM LS DWTRM ● 6 ● RM RM DWMRM inner window RM RM DWRM 4 slope location ● ^ + d σ 2 ● ˆ scale σ ● ● ● ● ● ● ● ^ − d σ ● ● ● ● ● median absolute ● ● ● ● ● ● ● ● MAD 0 ● ● ● deviation ● Q n scale QN −2 S n scale SN t−15 t−10 t−5 t t+5 t+10 t+15 (Rousseeuw, Croux, 1993) 11 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  37. i 1 i 1 dw.filter – Estimation in One Window q q inner outer ● method 10 window window initial RM fit ● trimming boundaries ● MED MEAN DWMTM 8 RM LS DWTRM ● 6 ● RM RM DWMRM inner window RM RM DWRM 4 slope location ● ^ + d σ 2 ● ● ˆ scale σ ● ● ● ● ● ● ● ● ● ● ● ● ● ● ^ − d σ ● ● ● ● ● ● ● ● ● ● median absolute ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● MAD 0 ● ● ● ● ● ● deviation ● ● Q n scale QN −2 S n scale SN t−15 t−10 t−5 t t+5 t+10 t+15 (Rousseeuw, Croux, 1993) 11 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  38. i 1 i 1 dw.filter – Estimation in One Window q q inner outer ● method 10 window window ● initial RM fit ● MED MEAN DWMTM trimming boundaries 8 final LS fit to the trimmed data RM LS DWTRM final estimate ● 6 ● RM RM DWMRM inner window RM RM DWRM 4 slope location ● ^ + d σ 2 ● ● ˆ scale σ ● ● ● ● ● ● ● ● ● ● ● ● ● ● ^ − d σ ● ● ● ● ● ● ● ● ● ● Median Absolute ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● MAD 0 ● ● ● ● ● ● Deviation ● ● Q n scale QN −2 S n scale SN t−15 t−10 t−5 t t+5 t+10 t+15 (Rousseeuw, Croux, 1993) 11 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  39. i 1 i 1 robust.filter – Parameter Options q q Window width ∈ N width Median trend "MED" Repeated Median "RM" Least Median of Squares "LMS" Least Trimmed Squares "LTS" 12 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  40. i 1 i 1 robust.filter – Parameter Options q q Window width ∈ N width Median trend "MED" Repeated Median "RM" Least Median of Squares "LMS" Least Trimmed Squares "LTS" Median Absolute Deviation scale "MAD" Q n scale "QN" S n scale "SN" Length of the Shortest Half "LSH" 12 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  41. i 1 i 1 robust.filter – Parameter Options q q Window width ∈ N width Median trend "MED" Repeated Median "RM" Least Median of Squares "LMS" Least Trimmed Squares "LTS" Median Absolute Deviation scale "MAD" Q n scale "QN" S n scale "SN" Length of the Shortest Half "LSH" Options online and extrapolate Further arguments for level shift & outlier detection and outlier treatment 12 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  42. i 1 i 1 robust.filter – Illustration q q time series 10 true signal 5 0 0 50 100 150 200 250 time fit <- robust.filter(series, width=31) 13 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  43. i 1 i 1 robust.filter – Illustration q q time series 10 true signal robust.filter−signal 5 0 0 50 100 150 200 250 time > fit $level [1] -2.391516 -2.335128 -2.278741 -2.222354 -2.165966 ... $slope [1] 0.056387 0.056387 0.056387 0.056387 0.056387 ... $sigma [1] 0.798726 0.798726 0.798726 0.798726 0.798726 ... 245 observations omitted 13 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  44. i 1 i 1 robust.filter – Illustration q q time series 10 true signal robust.filter−signal 5 0 0 50 100 150 200 250 time Level shifts? 13 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  45. i 1 i 1 robust.filter – Illustration q q time series 10 true signal robust.filter−signal 5 0 positive level shift detected at t=96 0 50 100 150 200 250 time Level shifts? > which(fit$level.shift!=0) [1] 96 > fit$level.shift[which(fit$level.shift!=0)] [1] 1 13 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  46. i 1 i 1 robust.filter – Illustration q q time series 10 true signal robust.filter−signal 5 0 positive level shift detected at t=96 0 50 100 150 200 250 time Outliers? 13 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  47. i 1 i 1 robust.filter – Illustration q q ● time series ● ● 10 ● true signal ● ● ● ●● robust.filter−signal ● negative outliers ● ● positive outliers ● ● ● ● 5 ● ● ● ● ● ●● ● ● ● ● ●● ● ● 0 ● positive level shift ● ● detected at t=96 0 50 100 150 200 250 time Outliers? 13 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  48. i 1 i 1 robust.filter – Illustration q q ● time series ● ● 10 ● true signal ● ● ● ●● robust.filter−signal ● negative outliers ● ● positive outliers ● ● ● ● 5 ● ● ● ● ● ● ●● ● ● ● ● ● ● ●● ● ●● ● ● ● 0 ● ● positive level shift ● ● ● detected at t=96 0 50 100 150 200 250 time Outliers? 23 correctly detected 9 falsely detected 2 not detected 13 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  49. i 1 i 1 Weighted Repeated Median Regression q q hi (Fried, Einbeck, Gather, 2007) y t = ( y t + i ) ′ Sample in one time window � �� � y t + i − y t + j � β RM = med med w i ✸ w j ✸ t i − j i j � = i � � w i ✸ ( y t + i + � µ RM β RM = med · i ) � t t i � − n + 1 , . . . , − 1 , 0 (online) with i = − m, . . . , m and n = 2 m + 1 (with delay) 14 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  50. i 1 i 1 Weighted Repeated Median Regression q q hi (Fried, Einbeck, Gather, 2007) y t = ( y t + i ) ′ Sample in one time window � �� � y t + i − y t + j � β RM = med med w i ✸ w j ✸ t i − j i j � = i � � w i ✸ ( y t + i + � µ RM β RM = med · i ) � t t i � − n + 1 , . . . , − 1 , 0 (online) with i = − m, . . . , m and n = 2 m + 1 (with delay) w ✸ a denotes the set of w replications of a : 3 ✸ a = { a, a, a } . 14 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  51. i 1 i 1 Weighted Repeated Median Regression q q hi (Fried, Einbeck, Gather, 2007) ( x , y ) = ( x i , y i ) ′ , Sample i = 1 , . . . , n Generally: � �� � y i − y j � β RM = med med w i ✸ w j ✸ x i − x j i j � = i � � β RM · x i ) + � µ RM = med w i ✸ ( y i � i 14 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  52. i 1 i 1 Weighted Repeated Median Regression q q hi (Fried, Einbeck, Gather, 2007) ( x , y ) = ( x i , y i ) ′ , Sample i = 1 , . . . , n Generally: � �� � y i − y j � β RM = med med w i ✸ w j ✸ x i − x j i j � = i � � β RM · x i ) + � µ RM = med w i ✸ ( y i � i wrm.smooth : • Non-equidistant regressor variables • Smoothing with kernel weight functions 14 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  53. i 1 i 1 wrm.filter – Parameter Options q q input time series ( ts -object or vector) y window width ( ∈ N ) width delay of the extracted signal: del=0 means ’online’, del default is del=floor(width/2) (delayed) weight function: weight 0: equal weighting 1: triangular weights 2: Epanechnikov weights 15 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  54. i 1 i 1 wrm.filter – Weight Functions q q Window width = 21 Uniform Weights for Online Estimation 1.4 1.2 weights 1.0 0.8 0.6 5 10 15 20 Triangular Weights for Online Estimation 1.5 weights 1.0 0.5 5 10 15 20 Epanechnikov Weights for Online Estimation 0.7 0.6 weights 0.5 0.4 0.3 0.2 0.1 5 10 15 20 16 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  55. i 1 i 1 wrm.filter – Weight Functions q q Window width = 21 Uniform Weights with a Delay of del= 1 1.4 1.2 weights 1.0 0.8 0.6 5 10 15 20 Triangular Weights with a Delay of del= 1 1.5 weights 1.0 0.5 5 10 15 20 Epanechnikov Weights with a Delay of del= 1 0.8 0.7 0.6 weights 0.5 0.4 0.3 0.2 0.1 5 10 15 20 16 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  56. i 1 i 1 wrm.filter – Weight Functions q q Window width = 21 Uniform Weights with a Delay of del= 2 1.4 1.2 weights 1.0 0.8 0.6 5 10 15 20 Triangular Weights with a Delay of del= 2 1.5 weights 1.0 0.5 5 10 15 20 Epanechnikov Weights with a Delay of del= 2 0.8 weights 0.6 0.4 0.2 5 10 15 20 16 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  57. i 1 i 1 wrm.filter – Weight Functions q q Window width = 21 Uniform Weights with a Delay of del= 3 1.4 1.2 weights 1.0 0.8 0.6 5 10 15 20 Triangular Weights with a Delay of del= 3 1.5 weights 1.0 0.5 5 10 15 20 Epanechnikov Weights with a Delay of del= 3 0.8 weights 0.6 0.4 0.2 5 10 15 20 16 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  58. i 1 i 1 wrm.filter – Weight Functions q q Window width = 21 Uniform Weights with a Delay of del= 4 1.4 1.2 weights 1.0 0.8 0.6 5 10 15 20 Triangular Weights with a Delay of del= 4 1.5 weights 1.0 0.5 5 10 15 20 Epanechnikov Weights with a Delay of del= 4 0.8 weights 0.6 0.4 0.2 5 10 15 20 16 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  59. i 1 i 1 wrm.filter – Weight Functions q q Window width = 21 Uniform Weights with a Delay of del= 5 1.4 1.2 weights 1.0 0.8 0.6 5 10 15 20 Triangular Weights with a Delay of del= 5 1.5 weights 1.0 0.5 5 10 15 20 Epanechnikov Weights with a Delay of del= 5 1.0 0.8 weights 0.6 0.4 0.2 5 10 15 20 16 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  60. i 1 i 1 wrm.filter – Weight Functions q q Window width = 21 Uniform Weights with a Delay of del= 6 1.4 1.2 weights 1.0 0.8 0.6 5 10 15 20 Triangular Weights with a Delay of del= 6 1.5 weights 1.0 0.5 5 10 15 20 Epanechnikov Weights with a Delay of del= 6 1.0 0.8 weights 0.6 0.4 0.2 5 10 15 20 16 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  61. i 1 i 1 wrm.filter – Weight Functions q q Window width = 21 Uniform Weights with a Delay of del= 7 1.4 1.2 weights 1.0 0.8 0.6 5 10 15 20 Triangular Weights with a Delay of del= 7 1.5 weights 1.0 0.5 5 10 15 20 Epanechnikov Weights with a Delay of del= 7 1.0 weights 0.8 0.6 0.4 0.2 5 10 15 20 16 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  62. i 1 i 1 wrm.filter – Weight Functions q q Window width = 21 Uniform Weights with a Delay of del= 8 1.4 1.2 weights 1.0 0.8 0.6 5 10 15 20 Triangular Weights with a Delay of del= 8 1.5 weights 1.0 0.5 5 10 15 20 Epanechnikov Weights with a Delay of del= 8 1.2 1.0 weights 0.8 0.6 0.4 0.2 5 10 15 20 16 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  63. i 1 i 1 wrm.filter – Weight Functions q q Window width = 21 Uniform Weights with a Delay of del= 9 1.4 1.2 weights 1.0 0.8 0.6 5 10 15 20 Triangular Weights with a Delay of del= 9 1.5 weights 1.0 0.5 5 10 15 20 Epanechnikov Weights with a Delay of del= 9 1.2 weights 1.0 0.8 0.6 0.4 0.2 5 10 15 20 16 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  64. i 1 i 1 wrm.filter – Weight Functions q q Window width = 21 Uniform Weights with a Delay of del= 10 1.4 1.2 weights 1.0 0.8 0.6 5 10 15 20 Triangular Weights with a Delay of del= 10 1.5 weights 1.0 0.5 5 10 15 20 Epanechnikov Weights with a Delay of del= 10 1.4 1.2 weights 1.0 0.8 0.6 0.4 5 10 15 20 16 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  65. i 1 i 1 Influence of the Window Width q q ● ● ● ● ● 6 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● signal ● ● ● ● ● ● ● ● ● ● ● ● ● n = 10 ● ● ● ● ● 4 ● ● ● ● ● n = 40 ● 2 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 0 ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● −2 ● 0 20 40 60 80 100 time n small n large + small bias + small variance + adapts quickly to changes + smooth + short computation time + robust Data adaptive choice of window width 17 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  66. i 1 i 1 adore.filter q q hi (Schettlinger, Fried, Gather, 2008) ad aptive o nline re peated median filtering: Window width adaptation by a test � � n � using the ’balance’ of the residual signs i =1 sign ( r t,i ) = 0 RM approximation in current time window ❄ Test: Selection of positive & negative residuals balanced? 18 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  67. i 1 i 1 adore.filter q q hi (Schettlinger, Fried, Gather, 2008) ad aptive o nline re peated median filtering: Window width adaptation by a test � � n � using the ’balance’ of the residual signs i =1 sign ( r t,i ) = 0 RM approximation in current time window ✲ ❄ Test: Selection of positive & negative residuals balanced? ✟ ✟ ✟ ✟ No ✟ ✟ ✟ ✟ ✟ ✟ ✟ ✙ Reduce window width 18 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  68. i 1 i 1 adore.filter q q hi (Schettlinger, Fried, Gather, 2008) ad aptive o nline re peated median filtering: Window width adaptation by a test � � n � using the ’balance’ of the residual signs i =1 sign ( r t,i ) = 0 RM approximation in current time window ✲ ✛ ❄ Test: Selection of positive & negative residuals balanced? ✟ ❍❍❍❍❍❍❍❍❍❍ ✟ ✟ ✟ No Yes ✟ ✟ ✟ ✟ ✟ ✟ ✙ ✟ ❍ ❥ Save current signal estimate Reduce window width ❄ Update window t → t + 1 and n → n + 1 18 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  69. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 11 20 n(t) = 11 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  70. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 12 20 n(t) = 12 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  71. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 13 20 n(t) = 13 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  72. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 14 20 n(t) = 14 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  73. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 15 20 n(t) = 15 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  74. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 16 20 n(t) = 16 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  75. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 17 20 n(t) = 17 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  76. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 18 20 n(t) = 18 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  77. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 19 20 n(t) = 19 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  78. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 19 20 n(t) = 18 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  79. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 19 20 n(t) = 17 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  80. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 19 20 n(t) = 16 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  81. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 19 20 n(t) = 15 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  82. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 19 20 n(t) = 14 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  83. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 19 20 n(t) = 13 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  84. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 19 20 n(t) = 12 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  85. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 19 20 n(t) = 11 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  86. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 20 20 n(t) = 12 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

  87. i 1 i 1 adore.filter – Illustration q q min.width=11 p.test=5 max.width=100 t = 20 20 n(t) = 11 15 ● ● ● ● ● ● ● ● ● 10 ● ● ● ● ● ● ● ● ● ● 5 ● ● ● ● ● ● ● ● ● ● 0 ● 0 5 10 15 20 25 30 time 19 UseR! The R User Conference 2008, August 12-14, Technische Universit¨ at Dortmund

Recommend


More recommend