File: strucchange-tests.Rout.save

package info (click to toggle)
strucchange 1.5-1-2
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 1,164 kB
  • sloc: makefile: 1
file content (455 lines) | stat: -rw-r--r-- 10,026 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455

R version 3.2.0 (2015-04-16) -- "Full of Ingredients"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library("strucchange")
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: sandwich
> 
> ## Nile data
> data("Nile")
> 
> Nile.rcus <- efp(Nile ~ 1, type = "Rec-CUSUM")
> Nile.ocus <- efp(Nile ~ 1, type = "OLS-CUSUM")
> Nile.re <- efp(Nile ~ 1, type = "RE")
> Nile.rmos <- efp(Nile ~ 1, type = "Rec-MOSUM", h = 0.5)
> Nile.omos <- efp(Nile ~ 1, type = "OLS-MOSUM", h = 0.5)
> Nile.me <- efp(Nile ~ 1, type = "ME", h = 0.5)
> sctest(Nile.rcus)

	Recursive CUSUM test

data:  Nile.rcus
S = 2.0669, p-value = 7.487e-08

> sctest(Nile.ocus)

	OLS-based CUSUM test

data:  Nile.ocus
S0 = 2.9518, p-value = 5.409e-08

> sctest(Nile.ocus, alt = TRUE)

	OLS-based CUSUM test with alternative boundaries

data:  Nile.ocus
S0 = 6.5741, p-value = 1e-04

> sctest(Nile.re)

	RE test (recursive estimates test)

data:  Nile.re
RE = 2.9518, p-value = 5.409e-08

> sctest(Nile.re, alt = TRUE)

	RE test (recursive estimates test) with alternative boundaries

data:  Nile.re
RE = 6.5741, p-value = 1e-04

> sctest(Nile.re, fun = "range")

	RE test (recursive estimates test) with range norm

data:  Nile.re
RE = 2.9518, p-value = 1.831e-06

> sctest(Nile.rmos)

	Recursive MOSUM test

data:  Nile.rmos
M = 5.097, p-value = 0.01

> sctest(Nile.omos)

	OLS-based MOSUM test

data:  Nile.omos
M0 = 2.4237, p-value = 0.01

> sctest(Nile.omos, fun = "range")

	OLS-based MOSUM test with range norm

data:  Nile.omos
M0 = 4.3433, p-value = 5.615e-05

> sctest(Nile.me)

	ME test (moving estimates test)

data:  Nile.me
ME = 2.4237, p-value = 0.01

> sctest(Nile.me, fun = "range")

	ME test (moving estimates test) with range norm

data:  Nile.me
ME = 4.3433, p-value = 5.615e-05

> 
> Nile.fs <- Fstats(Nile ~ 1)
> sctest(Nile.fs, type = "supF")

	supF test

data:  Nile.fs
sup.F = 75.93, p-value = 2.22e-16

> sctest(Nile.fs, type = "aveF")

	aveF test

data:  Nile.fs
ave.F = 21.215, p-value < 2.2e-16

> sctest(Nile.fs, type = "expF")

	expF test

data:  Nile.fs
exp.F = 33.759, p-value < 2.2e-16

> breakpoints(Nile.fs)

	 Optimal 2-segment partition: 

Call:
breakpoints.Fstats(obj = Nile.fs)

Breakpoints at observation number:
28 

Corresponding to breakdates:
1898 
> 
> ## Seatbelt data
> data("UKDriverDeaths")
> seatbelt <- log10(UKDriverDeaths)
> seatbelt <- cbind(seatbelt, lag(seatbelt, k = -1), lag(seatbelt, k = -12))
> colnames(seatbelt) <- c("y", "ylag1", "ylag12")
> seatbelt <- window(seatbelt, start = c(1970, 1), end = c(1984,12))
> 
> seat.rcus <- efp(y ~ ylag1 + ylag12, data = seatbelt, type = "Rec-CUSUM")
> seat.ocus <- efp(y ~ ylag1 + ylag12, data = seatbelt, type = "OLS-CUSUM")
> seat.re <- efp(y ~ ylag1 + ylag12, data = seatbelt, type = "RE")
> seat.rmos <- efp(y ~ ylag1 + ylag12, data = seatbelt, type = "Rec-MOSUM", h = 0.5)
> seat.omos <- efp(y ~ ylag1 + ylag12, data = seatbelt, type = "OLS-MOSUM", h = 0.5)
> seat.me <- efp(y ~ ylag1 + ylag12, data = seatbelt, type = "ME", h = 0.5)
> sctest(seat.rcus)

	Recursive CUSUM test

data:  seat.rcus
S = 1.1599, p-value = 0.008572

> sctest(seat.ocus)

	OLS-based CUSUM test

data:  seat.ocus
S0 = 1.4866, p-value = 0.02407

> sctest(seat.ocus, alt = TRUE)

	OLS-based CUSUM test with alternative boundaries

data:  seat.ocus
S0 = 3.4082, p-value = 0.04502

> sctest(seat.re)

	RE test (recursive estimates test)

data:  seat.re
RE = 1.6311, p-value = 0.02904

> sctest(seat.re, alt = TRUE)

	RE test (recursive estimates test) with alternative boundaries

data:  seat.re
RE = 4.7365, p-value = 3e-04

> sctest(seat.re, fun = "range")

	RE test (recursive estimates test) with range norm

data:  seat.re
RE = 1.9303, p-value = 0.04762

> sctest(seat.rmos)

	Recursive MOSUM test

data:  seat.rmos
M = 2.0539, p-value = 0.04259

> sctest(seat.omos)

	OLS-based MOSUM test

data:  seat.omos
M0 = 0.91616, p-value = 0.4004

> sctest(seat.omos, fun = "range")

	OLS-based MOSUM test with range norm

data:  seat.omos
M0 = 1.4949, p-value = 0.5175

> sctest(seat.me)

	ME test (moving estimates test)

data:  seat.me
ME = 1.7107, p-value = 0.04712

> sctest(seat.me, fun = "range")

	ME test (moving estimates test) with range norm

data:  seat.me
ME = 2.1956, p-value = 0.3007

> 
> seat.fs <- Fstats(y ~ ylag1 + ylag12, data = seatbelt, from = 0.1)
> sctest(seat.fs, type = "supF")

	supF test

data:  seat.fs
sup.F = 19.333, p-value = 0.006721

> sctest(seat.fs, type = "aveF")

	aveF test

data:  seat.fs
ave.F = 7.458, p-value = 0.01461

> sctest(seat.fs, type = "expF")

	expF test

data:  seat.fs
exp.F = 6.4247, p-value = 0.008093

> breakpoints(seat.fs)

	 Optimal 2-segment partition: 

Call:
breakpoints.Fstats(obj = seat.fs)

Breakpoints at observation number:
46 

Corresponding to breakdates:
1973(10) 
> 
> ## German M1 data
> data("GermanM1")
> LTW.model <- dm ~ dy2 + dR + dR1 + dp + m1 + y1 + R1 + season
> M1.model <- dm ~ dy2 + dR + dR1 + dp + ecm.res + season
> 
> M1.ocus <- efp(LTW.model, data = GermanM1, type = "OLS-CUSUM")
> M1.re <- efp(LTW.model, data = GermanM1, type = "RE")
> M1.fs <- Fstats(LTW.model, data = GermanM1, from = 0.1)
> sctest(M1.ocus)

	OLS-based CUSUM test

data:  M1.ocus
S0 = 0.50881, p-value = 0.958

> sctest(M1.ocus, alt = TRUE)

	OLS-based CUSUM test with alternative boundaries

data:  M1.ocus
S0 = 1.6288, p-value = 0.9704

> sctest(M1.re)

	RE test (recursive estimates test)

data:  M1.re
RE = 1.9821, p-value = 0.008475

> sctest(M1.re, fun = "range")

	RE test (recursive estimates test) with range norm

data:  M1.re
RE = 2.2386, p-value = 0.01844

> sctest(M1.re, alt = TRUE)

	RE test (recursive estimates test) with alternative boundaries

data:  M1.re
RE = 5.4937, p-value = 0.001099

> sctest(M1.fs, type = "supF")

	supF test

data:  M1.fs
sup.F = 108.83, p-value = 4.441e-16

> sctest(M1.fs, type = "aveF")

	aveF test

data:  M1.fs
ave.F = 35.551, p-value = 2.007e-07

> sctest(M1.fs, type = "expF")

	expF test

data:  M1.fs
exp.F = 49.74, p-value < 2.2e-16

> 
> M1 <- historyM1
> ols.efp <- efp(M1.model, type = "OLS-CUSUM", data = M1)
> newborder <- function(k) 1.5778*k/118
> ols.mefp <- mefp(ols.efp, period = 2)
> ols.mefp2 <- mefp(ols.efp, border = newborder)
> M1 <- GermanM1
> ols.mon <- monitor(ols.mefp)
Break detected at observation # 128 
> ols.mon2 <- monitor(ols.mefp2)
Break detected at observation # 135 
> ols.mon
Monitoring with OLS-based CUSUM test 

Initial call:
  mefp.efp(obj = ols.efp, period = 2) 

Last call:
  monitor(obj = ols.mefp) 

Significance level   :  0.05 
Critical value       :  2.795483 
History size         :  118 
Last point evaluated :  140 
Structural break at  :  128 

Parameter estimate on history :
(Intercept)         dy2          dR         dR1          dp     ecm.res 
-0.05025441 -0.29729418 -0.67278600 -0.99950033 -0.52786586  1.00000000 
   seasonQ1    seasonQ2    seasonQ3 
-0.13330148 -0.01559447 -0.10906796 
> ols.mon2
Monitoring with OLS-based CUSUM test 

Initial call:
  mefp.efp(obj = ols.efp, border = newborder) 

Last call:
  monitor(obj = ols.mefp2) 

Significance level   :  0.05 
Critical value       :  2.795483 
History size         :  118 
Last point evaluated :  140 
Structural break at  :  135 

Parameter estimate on history :
(Intercept)         dy2          dR         dR1          dp     ecm.res 
-0.05025441 -0.29729418 -0.67278600 -0.99950033 -0.52786586  1.00000000 
   seasonQ1    seasonQ2    seasonQ3 
-0.13330148 -0.01559447 -0.10906796 
> 
> ## Grossarl data
> data("Grossarl")
> Grossarl.bp <- breakpoints(fraction ~ 1, data = Grossarl, h = 0.1)
> summary(Grossarl.bp)

	 Optimal (m+1)-segment partition: 

Call:
breakpoints.formula(formula = fraction ~ 1, h = 0.1, data = Grossarl)

Breakpoints at observation number:
                                    
m = 1                127            
m = 2      55        122            
m = 3      55        124         180
m = 4      55        122     157 179
m = 5      54 86     122     157 179
m = 6   35 55 86     122     157 179
m = 7   35 55 80 101 122     157 179
m = 8   35 55 79 99  119 139 159 179

Corresponding to breakdates:
                                               
m = 1                       1826               
m = 2        1754           1821               
m = 3        1754           1823           1879
m = 4        1754           1821      1856 1878
m = 5        1753 1785      1821      1856 1878
m = 6   1734 1754 1785      1821      1856 1878
m = 7   1734 1754 1779 1800 1821      1856 1878
m = 8   1734 1754 1778 1798 1818 1838 1858 1878

Fit:
                                                                         
m   0         1         2         3         4         5         6        
RSS    1.1088    0.8756    0.6854    0.6587    0.6279    0.6019    0.5917
BIC -460.8402 -497.4625 -535.8459 -533.1857 -532.1789 -530.0501 -522.8510
                       
m   7         8        
RSS    0.5934    0.6084
BIC -511.7017 -496.0924
> confint(Grossarl.bp)

	 Confidence intervals for breakpoints
	 of optimal 3-segment partition: 

Call:
confint.breakpointsfull(object = Grossarl.bp)

Breakpoints at observation number:
  2.5 % breakpoints 97.5 %
1    52          55     61
2   116         122    124

Corresponding to breakdates:
  2.5 % breakpoints 97.5 %
1  1751        1754   1760
2  1815        1821   1823
> 
> 
> proc.time()
   user  system elapsed 
  2.268   0.076   2.613