-
Notifications
You must be signed in to change notification settings - Fork 1
/
.Rhistory
512 lines (512 loc) · 25.6 KB
/
.Rhistory
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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
c(hlrt_pa_s1$LR0, hlrt_pa_s1$pval[4,], hlrt_pa_s2$LR0, hlrt_pa_s2$pval[4,], hlrt_pa_s3$LR0, hlrt_pa_s3$pval[4,]))
# Panel B: change in mean and variance
panelB <- rbind(c(lmclrt_pb_s1$LRT_0, lmclrt_pb_s1$pval, lmclrt_pb_s2$LRT_0, lmclrt_pb_s2$pval, lmclrt_pb_s3$LRT_0, lmclrt_pb_s3$pval),
c(mmclrt_pb_s1$LRT_0, mmclrt_pb_s1$pval, mmclrt_pb_s2$LRT_0, mmclrt_pb_s2$pval,mmclrt_pb_s3$LRT_0, mmclrt_pb_s3$pval),
c(lmcmoment_pb_s1$F0_min, lmcmoment_pb_s1$pval_min, lmcmoment_pb_s2$F0_min, lmcmoment_pb_s2$pval_min, lmcmoment_pb_s3$F0_min, lmcmoment_pb_s3$pval_min),
c(lmcmoment_pb_s1$F0_prod, lmcmoment_pb_s1$pval_prod, lmcmoment_pb_s2$F0_prod, lmcmoment_pb_s2$pval_prod, lmcmoment_pb_s3$F0_prod, lmcmoment_pb_s3$pval_prod),
c(mmcmoment_pb_s1$F0_min, mmcmoment_pb_s1$pval_min, mmcmoment_pb_s2$F0_min, mmcmoment_pb_s2$pval_min, mmcmoment_pb_s3$F0_min, mmcmoment_pb_s3$pval_min),
c(mmcmoment_pb_s1$F0_prod, mmcmoment_pb_s1$pval_prod, mmcmoment_pb_s2$F0_prod, mmcmoment_pb_s2$pval_prod, mmcmoment_pb_s3$F0_prod, mmcmoment_pb_s3$pval_prod),
c(pstabilitytest_pb_s1$supTS, pstabilitytest_pb_s1$pval_supTS, pstabilitytest_pb_s2$supTS, pstabilitytest_pb_s2$pval_supTS, pstabilitytest_pb_s3$supTS, pstabilitytest_pb_s3$pval_supTS),
c(pstabilitytest_pb_s1$expTS, pstabilitytest_pb_s1$pval_expTS, pstabilitytest_pb_s2$expTS, pstabilitytest_pb_s2$pval_expTS, pstabilitytest_pb_s3$expTS, pstabilitytest_pb_s3$pval_expTS),
c(hlrt_pb_s1$LR0,hlrt_pb_s1$pval[4,], hlrt_pb_s2$LR0,hlrt_pb_s2$pval[4,], hlrt_pb_s3$LR0,hlrt_pb_s3$pval[4,]))
panelA <- format(round(panelA,2),nsmall=2)
panelB <- format(round(panelB,2),nsmall=2)
rownames(panelA) <- c("LMC-LRT","MMC-LRT","supTS","expTS","H-LRT")
rownames(panelB) <- c("LMC-LRT","MMC-LRT","LMC$_\text{min}$","LMC$_\text{prod}$","MMC$_\text{min}$","MMC$_\text{prod}$","supTS","expTS","H-LRT")
colnames(panelA) <- NULL
colnames(panelB) <- NULL
# prepare in Latex table format
panelA <- data.frame(panelA)
panelA$skip <- "&"
panelA$end <- "\\"
panelA <- panelA[,c("skip","X1","skip","X2","skip","X3","skip","X4","skip","X5","skip","X6","end")]
panelB <- data.frame(panelB)
panelB$skip <- "&"
panelB$end <- "\\"
panelB <- panelB[,c("skip","X1","skip","X2","skip","X3","skip","X4","skip","X5","skip","X6","end")]
panelB
panelB <- rbind(c(lmclrt_pb_s1$LRT_0, lmclrt_pb_s1$pval, lmclrt_pb_s2$LRT_0, lmclrt_pb_s2$pval, lmclrt_pb_s3$LRT_0, lmclrt_pb_s3$pval),
c(mmclrt_pb_s1$LRT_0, mmclrt_pb_s1$pval, mmclrt_pb_s2$LRT_0, mmclrt_pb_s2$pval,mmclrt_pb_s3$LRT_0, mmclrt_pb_s3$pval),
c(lmcmoment_pb_s1$F0_min, lmcmoment_pb_s1$pval_min, lmcmoment_pb_s2$F0_min, lmcmoment_pb_s2$pval_min, lmcmoment_pb_s3$F0_min, lmcmoment_pb_s3$pval_min),
c(lmcmoment_pb_s1$F0_prod, lmcmoment_pb_s1$pval_prod, lmcmoment_pb_s2$F0_prod, lmcmoment_pb_s2$pval_prod, lmcmoment_pb_s3$F0_prod, lmcmoment_pb_s3$pval_prod),
c(mmcmoment_pb_s1$F0_min, mmcmoment_pb_s1$pval_min, mmcmoment_pb_s2$F0_min, mmcmoment_pb_s2$pval_min, mmcmoment_pb_s3$F0_min, mmcmoment_pb_s3$pval_min),
c(mmcmoment_pb_s1$F0_prod, mmcmoment_pb_s1$pval_prod, mmcmoment_pb_s2$F0_prod, mmcmoment_pb_s2$pval_prod, mmcmoment_pb_s3$F0_prod, mmcmoment_pb_s3$pval_prod),
c(pstabilitytest_pb_s1$supTS, pstabilitytest_pb_s1$pval_supTS, pstabilitytest_pb_s2$supTS, pstabilitytest_pb_s2$pval_supTS, pstabilitytest_pb_s3$supTS, pstabilitytest_pb_s3$pval_supTS),
c(pstabilitytest_pb_s1$expTS, pstabilitytest_pb_s1$pval_expTS, pstabilitytest_pb_s2$expTS, pstabilitytest_pb_s2$pval_expTS, pstabilitytest_pb_s3$expTS, pstabilitytest_pb_s3$pval_expTS),
c(hlrt_pb_s1$LR0,hlrt_pb_s1$pval[4,], hlrt_pb_s2$LR0,hlrt_pb_s2$pval[4,], hlrt_pb_s3$LR0,hlrt_pb_s3$pval[4,]))
panelB
format(round(panelB,2),nsmall=2)
round(panelB,2)
panelB[1,]
panelB <- rbind(c(lmclrt_pb_s1$LRT_0, lmclrt_pb_s1$pval, lmclrt_pb_s2$LRT_0, lmclrt_pb_s2$pval, lmclrt_pb_s3$LRT_0, lmclrt_pb_s3$pval),
c(mmclrt_pb_s1$LRT_0, mmclrt_pb_s1$pval, mmclrt_pb_s2$LRT_0, mmclrt_pb_s2$pval,mmclrt_pb_s3$LRT_0, mmclrt_pb_s3$pval),
c(lmcmoment_pb_s1$F0_min, lmcmoment_pb_s1$pval_min, lmcmoment_pb_s2$F0_min, lmcmoment_pb_s2$pval_min, lmcmoment_pb_s3$F0_min, lmcmoment_pb_s3$pval_min),
c(lmcmoment_pb_s1$F0_prod, lmcmoment_pb_s1$pval_prod, lmcmoment_pb_s2$F0_prod, lmcmoment_pb_s2$pval_prod, lmcmoment_pb_s3$F0_prod, lmcmoment_pb_s3$pval_prod),
c(mmcmoment_pb_s1$F0_min, mmcmoment_pb_s1$pval_min, mmcmoment_pb_s2$F0_min, mmcmoment_pb_s2$pval_min, mmcmoment_pb_s3$F0_min, mmcmoment_pb_s3$pval_min),
c(mmcmoment_pb_s1$F0_prod, mmcmoment_pb_s1$pval_prod, mmcmoment_pb_s2$F0_prod, mmcmoment_pb_s2$pval_prod, mmcmoment_pb_s3$F0_prod, mmcmoment_pb_s3$pval_prod),
c(pstabilitytest_pb_s1$supTS, pstabilitytest_pb_s1$pval_supTS, pstabilitytest_pb_s2$supTS, pstabilitytest_pb_s2$pval_supTS, pstabilitytest_pb_s3$supTS, pstabilitytest_pb_s3$pval_supTS),
c(pstabilitytest_pb_s1$expTS, pstabilitytest_pb_s1$pval_expTS, pstabilitytest_pb_s2$expTS, pstabilitytest_pb_s2$pval_expTS, pstabilitytest_pb_s3$expTS, pstabilitytest_pb_s3$pval_expTS),
c(hlrt_pb_s1$LR0,hlrt_pb_s1$pval[4,], hlrt_pb_s2$LR0,hlrt_pb_s2$pval[4,], hlrt_pb_s3$LR0,hlrt_pb_s3$pval[4,]))
panelA <- format(round(panelA,2),nsmall=2)
panelB <- rbind(c(lmclrt_pb_s1$LRT_0, lmclrt_pb_s1$pval, lmclrt_pb_s2$LRT_0, lmclrt_pb_s2$pval, lmclrt_pb_s3$LRT_0, lmclrt_pb_s3$pval),
c(mmclrt_pb_s1$LRT_0, mmclrt_pb_s1$pval, mmclrt_pb_s2$LRT_0, mmclrt_pb_s2$pval,mmclrt_pb_s3$LRT_0, mmclrt_pb_s3$pval),
c(lmcmoment_pb_s1$F0_min, lmcmoment_pb_s1$pval_min, lmcmoment_pb_s2$F0_min, lmcmoment_pb_s2$pval_min, lmcmoment_pb_s3$F0_min, lmcmoment_pb_s3$pval_min),
c(lmcmoment_pb_s1$F0_prod, lmcmoment_pb_s1$pval_prod, lmcmoment_pb_s2$F0_prod, lmcmoment_pb_s2$pval_prod, lmcmoment_pb_s3$F0_prod, lmcmoment_pb_s3$pval_prod),
c(mmcmoment_pb_s1$F0_min, mmcmoment_pb_s1$pval_min, mmcmoment_pb_s2$F0_min, mmcmoment_pb_s2$pval_min, mmcmoment_pb_s3$F0_min, mmcmoment_pb_s3$pval_min),
c(mmcmoment_pb_s1$F0_prod, mmcmoment_pb_s1$pval_prod, mmcmoment_pb_s2$F0_prod, mmcmoment_pb_s2$pval_prod, mmcmoment_pb_s3$F0_prod, mmcmoment_pb_s3$pval_prod),
c(pstabilitytest_pb_s1$supTS, pstabilitytest_pb_s1$pval_supTS, pstabilitytest_pb_s2$supTS, pstabilitytest_pb_s2$pval_supTS, pstabilitytest_pb_s3$supTS, pstabilitytest_pb_s3$pval_supTS),
c(pstabilitytest_pb_s1$expTS, pstabilitytest_pb_s1$pval_expTS, pstabilitytest_pb_s2$expTS, pstabilitytest_pb_s2$pval_expTS, pstabilitytest_pb_s3$expTS, pstabilitytest_pb_s3$pval_expTS),
c(hlrt_pb_s1$LR0,hlrt_pb_s1$pval[4,], hlrt_pb_s2$LR0,hlrt_pb_s2$pval[4,], hlrt_pb_s3$LR0,hlrt_pb_s3$pval[4,]))
panelA <- format(round(panelA,2),nsmall=2)
panelB <- rbind(c(lmclrt_pb_s1$LRT_0, lmclrt_pb_s1$pval, lmclrt_pb_s2$LRT_0, lmclrt_pb_s2$pval, lmclrt_pb_s3$LRT_0, lmclrt_pb_s3$pval),
c(mmclrt_pb_s1$LRT_0, mmclrt_pb_s1$pval, mmclrt_pb_s2$LRT_0, mmclrt_pb_s2$pval,mmclrt_pb_s3$LRT_0, mmclrt_pb_s3$pval),
c(lmcmoment_pb_s1$F0_min, lmcmoment_pb_s1$pval_min, lmcmoment_pb_s2$F0_min, lmcmoment_pb_s2$pval_min, lmcmoment_pb_s3$F0_min, lmcmoment_pb_s3$pval_min),
c(lmcmoment_pb_s1$F0_prod, lmcmoment_pb_s1$pval_prod, lmcmoment_pb_s2$F0_prod, lmcmoment_pb_s2$pval_prod, lmcmoment_pb_s3$F0_prod, lmcmoment_pb_s3$pval_prod),
c(mmcmoment_pb_s1$F0_min, mmcmoment_pb_s1$pval_min, mmcmoment_pb_s2$F0_min, mmcmoment_pb_s2$pval_min, mmcmoment_pb_s3$F0_min, mmcmoment_pb_s3$pval_min),
c(mmcmoment_pb_s1$F0_prod, mmcmoment_pb_s1$pval_prod, mmcmoment_pb_s2$F0_prod, mmcmoment_pb_s2$pval_prod, mmcmoment_pb_s3$F0_prod, mmcmoment_pb_s3$pval_prod),
c(pstabilitytest_pb_s1$supTS, pstabilitytest_pb_s1$pval_supTS, pstabilitytest_pb_s2$supTS, pstabilitytest_pb_s2$pval_supTS, pstabilitytest_pb_s3$supTS, pstabilitytest_pb_s3$pval_supTS),
c(pstabilitytest_pb_s1$expTS, pstabilitytest_pb_s1$pval_expTS, pstabilitytest_pb_s2$expTS, pstabilitytest_pb_s2$pval_expTS, pstabilitytest_pb_s3$expTS, pstabilitytest_pb_s3$pval_expTS),
c(hlrt_pb_s1$LR0,hlrt_pb_s1$pval[4,], hlrt_pb_s2$LR0,hlrt_pb_s2$pval[4,], hlrt_pb_s3$LR0,hlrt_pb_s3$pval[4,]))
panelA <- format(round(panelA,2),nsmall=2)
rbind(c(lmclrt_pb_s1$LRT_0, lmclrt_pb_s1$pval, lmclrt_pb_s2$LRT_0, lmclrt_pb_s2$pval, lmclrt_pb_s3$LRT_0, lmclrt_pb_s3$pval),
c(mmclrt_pb_s1$LRT_0, mmclrt_pb_s1$pval, mmclrt_pb_s2$LRT_0, mmclrt_pb_s2$pval,mmclrt_pb_s3$LRT_0, mmclrt_pb_s3$pval),
c(lmcmoment_pb_s1$F0_min, lmcmoment_pb_s1$pval_min, lmcmoment_pb_s2$F0_min, lmcmoment_pb_s2$pval_min, lmcmoment_pb_s3$F0_min, lmcmoment_pb_s3$pval_min),
c(lmcmoment_pb_s1$F0_prod, lmcmoment_pb_s1$pval_prod, lmcmoment_pb_s2$F0_prod, lmcmoment_pb_s2$pval_prod, lmcmoment_pb_s3$F0_prod, lmcmoment_pb_s3$pval_prod),
c(mmcmoment_pb_s1$F0_min, mmcmoment_pb_s1$pval_min, mmcmoment_pb_s2$F0_min, mmcmoment_pb_s2$pval_min, mmcmoment_pb_s3$F0_min, mmcmoment_pb_s3$pval_min),
c(mmcmoment_pb_s1$F0_prod, mmcmoment_pb_s1$pval_prod, mmcmoment_pb_s2$F0_prod, mmcmoment_pb_s2$pval_prod, mmcmoment_pb_s3$F0_prod, mmcmoment_pb_s3$pval_prod),
c(pstabilitytest_pb_s1$supTS, pstabilitytest_pb_s1$pval_supTS, pstabilitytest_pb_s2$supTS, pstabilitytest_pb_s2$pval_supTS, pstabilitytest_pb_s3$supTS, pstabilitytest_pb_s3$pval_supTS),
c(pstabilitytest_pb_s1$expTS, pstabilitytest_pb_s1$pval_expTS, pstabilitytest_pb_s2$expTS, pstabilitytest_pb_s2$pval_expTS, pstabilitytest_pb_s3$expTS, pstabilitytest_pb_s3$pval_expTS),
c(hlrt_pb_s1$LR0,hlrt_pb_s1$pval[4,], hlrt_pb_s2$LR0,hlrt_pb_s2$pval[4,], hlrt_pb_s3$LR0,hlrt_pb_s3$pval[4,]))
panelB
panelB <- rbind(c(lmclrt_pb_s1$LRT_0, lmclrt_pb_s1$pval, lmclrt_pb_s2$LRT_0, lmclrt_pb_s2$pval, lmclrt_pb_s3$LRT_0, lmclrt_pb_s3$pval),
c(mmclrt_pb_s1$LRT_0, mmclrt_pb_s1$pval, mmclrt_pb_s2$LRT_0, mmclrt_pb_s2$pval,mmclrt_pb_s3$LRT_0, mmclrt_pb_s3$pval),
c(lmcmoment_pb_s1$F0_min, lmcmoment_pb_s1$pval_min, lmcmoment_pb_s2$F0_min, lmcmoment_pb_s2$pval_min, lmcmoment_pb_s3$F0_min, lmcmoment_pb_s3$pval_min),
c(lmcmoment_pb_s1$F0_prod, lmcmoment_pb_s1$pval_prod, lmcmoment_pb_s2$F0_prod, lmcmoment_pb_s2$pval_prod, lmcmoment_pb_s3$F0_prod, lmcmoment_pb_s3$pval_prod),
c(mmcmoment_pb_s1$F0_min, mmcmoment_pb_s1$pval_min, mmcmoment_pb_s2$F0_min, mmcmoment_pb_s2$pval_min, mmcmoment_pb_s3$F0_min, mmcmoment_pb_s3$pval_min),
c(mmcmoment_pb_s1$F0_prod, mmcmoment_pb_s1$pval_prod, mmcmoment_pb_s2$F0_prod, mmcmoment_pb_s2$pval_prod, mmcmoment_pb_s3$F0_prod, mmcmoment_pb_s3$pval_prod),
c(pstabilitytest_pb_s1$supTS, pstabilitytest_pb_s1$pval_supTS, pstabilitytest_pb_s2$supTS, pstabilitytest_pb_s2$pval_supTS, pstabilitytest_pb_s3$supTS, pstabilitytest_pb_s3$pval_supTS),
c(pstabilitytest_pb_s1$expTS, pstabilitytest_pb_s1$pval_expTS, pstabilitytest_pb_s2$expTS, pstabilitytest_pb_s2$pval_expTS, pstabilitytest_pb_s3$expTS, pstabilitytest_pb_s3$pval_expTS),
c(hlrt_pb_s1$LR0,hlrt_pb_s1$pval[4,], hlrt_pb_s2$LR0,hlrt_pb_s2$pval[4,], hlrt_pb_s3$LR0,hlrt_pb_s3$pval[4,]))
panelB <- format(round(panelB,2),nsmall=2)
panelB
panelB <- rbind(c(lmclrt_pb_s1$LRT_0, lmclrt_pb_s1$pval, lmclrt_pb_s2$LRT_0, lmclrt_pb_s2$pval, lmclrt_pb_s3$LRT_0, lmclrt_pb_s3$pval),
c(mmclrt_pb_s1$LRT_0, mmclrt_pb_s1$pval, mmclrt_pb_s2$LRT_0, mmclrt_pb_s2$pval,mmclrt_pb_s3$LRT_0, mmclrt_pb_s3$pval),
c(lmcmoment_pb_s1$F0_min, lmcmoment_pb_s1$pval_min, lmcmoment_pb_s2$F0_min, lmcmoment_pb_s2$pval_min, lmcmoment_pb_s3$F0_min, lmcmoment_pb_s3$pval_min),
c(lmcmoment_pb_s1$F0_prod, lmcmoment_pb_s1$pval_prod, lmcmoment_pb_s2$F0_prod, lmcmoment_pb_s2$pval_prod, lmcmoment_pb_s3$F0_prod, lmcmoment_pb_s3$pval_prod),
c(mmcmoment_pb_s1$F0_min, mmcmoment_pb_s1$pval_min, mmcmoment_pb_s2$F0_min, mmcmoment_pb_s2$pval_min, mmcmoment_pb_s3$F0_min, mmcmoment_pb_s3$pval_min),
c(mmcmoment_pb_s1$F0_prod, mmcmoment_pb_s1$pval_prod, mmcmoment_pb_s2$F0_prod, mmcmoment_pb_s2$pval_prod, mmcmoment_pb_s3$F0_prod, mmcmoment_pb_s3$pval_prod),
c(pstabilitytest_pb_s1$supTS, pstabilitytest_pb_s1$pval_supTS, pstabilitytest_pb_s2$supTS, pstabilitytest_pb_s2$pval_supTS, pstabilitytest_pb_s3$supTS, pstabilitytest_pb_s3$pval_supTS),
c(pstabilitytest_pb_s1$expTS, pstabilitytest_pb_s1$pval_expTS, pstabilitytest_pb_s2$expTS, pstabilitytest_pb_s2$pval_expTS, pstabilitytest_pb_s3$expTS, pstabilitytest_pb_s3$pval_expTS),
c(hlrt_pb_s1$LR0,hlrt_pb_s1$pval[4,], hlrt_pb_s2$LR0,hlrt_pb_s2$pval[4,], hlrt_pb_s3$LR0,hlrt_pb_s3$pval[4,]))
panelB <- round(panelB,2)
panelB
rownames(panelA) <- c("LMC-LRT","MMC-LRT","supTS","expTS","H-LRT")
rownames(panelB) <- c("LMC-LRT","MMC-LRT","LMC$_\text{min}$","LMC$_\text{prod}$","MMC$_\text{min}$","MMC$_\text{prod}$","supTS","expTS","H-LRT")
colnames(panelA) <- NULL
colnames(panelB) <- NULL
panelB <- data.frame(panelB)
panelB$skip <- "&"
panelB$end <- "\\"
panelB <- panelB[,c("skip","X1","skip","X2","skip","X3","skip","X4","skip","X5","skip","X6","end")]
panelB
panelB[1,]
panelB[1:3,]
panelB[1:6,]
panelB[1:8,]
panelB[1:7,]
panelB[8:9,]
panelB[8,]
panelB[9,]
chp_control$msvar <- FALSE
set.seed(250493)
pstabilitytest_pa_s1 <- CHPTest(Y, p = 4, control = chp_control)
pstabilitytest_pa_s1
chp_control$msvar <- TRUE
set.seed(250493)
pstabilitytest_pb_s1 <- CHPTest(Y, p = 4, control = chp_control)
pstabilitytest_pa_s1
panelA <- rbind(c(lmclrt_pa_s1$LRT_0, lmclrt_pa_s1$pval, lmclrt_pa_s2$LRT_0, lmclrt_pa_s2$pval, lmclrt_pa_s3$LRT_0, lmclrt_pa_s3$pval),
c(mmclrt_pa_s1$LRT_0, mmclrt_pa_s1$pval, mmclrt_pa_s2$LRT_0, mmclrt_pa_s2$pval,mmclrt_pa_s3$LRT_0, mmclrt_pa_s3$pval),
c(pstabilitytest_pa_s1$supTS, pstabilitytest_pa_s1$pval_supTS, pstabilitytest_pa_s2$supTS, pstabilitytest_pa_s2$pval_supTS, pstabilitytest_pa_s3$supTS, pstabilitytest_pa_s3$pval_supTS),
c(pstabilitytest_pa_s1$expTS, pstabilitytest_pa_s1$pval_expTS, pstabilitytest_pa_s2$expTS, pstabilitytest_pa_s2$pval_expTS, pstabilitytest_pa_s3$expTS, pstabilitytest_pa_s3$pval_expTS),
c(hlrt_pa_s1$LR0, hlrt_pa_s1$pval[4,], hlrt_pa_s2$LR0, hlrt_pa_s2$pval[4,], hlrt_pa_s3$LR0, hlrt_pa_s3$pval[4,]))
panelA
panelA <- format(round(panelA,2),nsmall=2)
rownames(panelA) <- c("LMC-LRT","MMC-LRT","supTS","expTS","H-LRT")
colnames(panelA) <- NULL
panelA <- data.frame(panelA)
panelA$skip <- "&"
panelA$end <- "\\"
panelA <- panelA[,c("skip","X1","skip","X2","skip","X3","skip","X4","skip","X5","skip","X6","end")]
panelA
MSTest::USGNP
## Package and options
library("MSTest")
library("foreach")
library("doParallel")
options(prompt = "R> ", continue = "+ ", width = 70,
useFancyQuotes = FALSE)
seed <- 250493
### ----- Test Markov switching autoregressive process using Rodriguez-Rondon & Dufour (2024) LMC-LRT -----
set.seed(seed)
# Set options for testing procedure
lmc_control = list(N = 99,
mdl_h0_control = list(const = TRUE,
getSE = FALSE),
mdl_h1_control = list(msmu = TRUE,
msvar = TRUE,
getSE = FALSE,
method = "EM",
use_diff_init = 5))
# Perform Rodriguez-Rondon & Dufour (2023) LMC-LRT
lmclrt <- LMCLRTest(simu_msar[["y"]], p = 1, k0 = 1 , k1 = 2, control = lmc_control)
summary(lmclrt)
### ----- Test autoregressive process using Rodriguez-Rondon & Dufour (2024) MMC-LRT -----
set.seed(seed)
# Set options for testing procedure
mmc_control = list(N = 99,
eps = 0.3,
threshold_stop = 0.05 + 1e-6,
type = "pso",
workers = 8,
CI_union = FALSE,
mdl_h0_control = list(const = TRUE,
getSE = FALSE),
mdl_h1_control = list(msmu = TRUE,
msvar = TRUE,
getSE = FALSE,
method = "EM"),
maxit = 100)
# start cluster
doParallel::registerDoParallel(mmc_control[["workers"]])
# Perform Rodriguez-Rondon & Dufour (2023) MMC-LRT
mmclrt <- MMCLRTest(simu_ar[["y"]], p = 1, k0 = 1 , k1 = 2, control = mmc_control)
summary(mmclrt)
# stop cluster
doParallel::stopImplicitCluster()
out <- read.table('/Users/gabrielrodriguez/Downloads/pu2023.csv', sep='|', header=T)
library("MSTest")
library("foreach")
library("doParallel")
options(prompt = "R> ", continue = "+ ", width = 70,
useFancyQuotes = FALSE)
seed <- 250493
data("hamilton84GNP", package = "MSTest")
data("chp10GNP", package = "MSTest")
data("USGNP", package = "MSTest")
data("USRGDP", package = "MSTest")
set.seed(seed)
### ----- Simulate Multivariate Normal process -----
# Define DGP of multivariate normal process
mdl_norm <- list(n = 500,
q = 2,
mu = c(5, -2),
sigma = rbind(c(5.0, 1.5),
c(1.5, 1.0)))
# Simulate process
simu_norm <- simuNorm(mdl_norm)
### ----- Simulate Autoregressive process -----
# Define DGP of AR(2) process
mdl_ar <- list(n = 500,
mu = 5,
sigma = 1,
phi = c(0.75))
# Simulate process
simu_ar <- simuAR(mdl_ar)
### ----- Simulate Vector Autoregressive process -----
# Define DGP of VAR(2) process
mdl_var <- list(n = 500,
p = 1,
q = 2,
mu = c(5, -2),
sigma = rbind(c(5.0, 1.5),
c(1.5, 1.0)),
phi = rbind(c(0.50, 0.30),
c(0.20, 0.70)))
# Simulate process
simu_var <- simuVAR(mdl_var)
### ----- Simulate Hidden Markov process -----
# Define DGP of HMM
mdl_hmm <- list(n = 500,
q = 2,
mu = rbind(c(5, -2),
c(10, 2)),
sigma = list(rbind(c(5.0, 1.5),
c(1.5, 1.0)),
rbind(c(7.0, 3.0),
c(3.0, 2.0))),
k = 2,
P = rbind(c(0.95, 0.10),
c(0.05, 0.90)))
# Simulate process
simu_hmm <- simuHMM(mdl_hmm)
### ----- Simulate Markov switching Autoregressive process -----
# Define DGP of MS AR process
mdl_ms <- list(n = 500,
mu = c(5,10),
sigma = c(1,2),
phi = c(0.75),
k = 2,
P = rbind(c(0.95, 0.10),
c(0.05, 0.90)))
# Simulate process
simu_msar <- simuMSAR(mdl_ms)
### ----- Simulate Markov switching Vector Autoregressive process -----
# Define DGP of MS VAR process
mdl_msvar <- list(n = 500,
p = 1,
q = 2,
mu = rbind(c(5, -2),
c(10, 2)),
sigma = list(rbind(c(5.0, 1.5),
c(1.5, 1.0)),
rbind(c(7.0, 3.0),
c(3.0, 2.0))),
phi = rbind(c(0.50, 0.30),
c(0.20, 0.70)),
k = 2,
P = rbind(c(0.95, 0.10),
c(0.05, 0.90)))
# Simulate process
simu_msvar <- simuMSVAR(mdl_msvar)
pdf(file = "simulations.pdf")
par(mfrow=c(3,2))
matplot(simu_norm$y, type = "l", ylab = "", main = "Multivariate normal process",cex.main=1)
matplot(simu_hmm$y, type = "l", ylab = "", main = "Hidden Markov process",cex.main=1)
plot(simu_ar$y, type = "l", ylab = "", main = "Autoregressive process",cex.main=1)
plot(simu_msar$y, type = "l", ylab = "", main = "Markov switching autoregressive process",cex.main=1)
matplot(simu_var$y, type = "l", ylab = "", main = "Vector autoregressive process",cex.main=1)
matplot(simu_msvar$y, type = "l", ylab = "", main = "Markov switching vector autoregressive process",cex.main=1)
dev.off()
# =========================================================== #
## ----- Model Estimation -----
# =========================================================== #
set.seed(seed)
### ----- Estimate Hidden Markov model -----
# Set options for model estimation
control <- list(msmu = TRUE,
msvar = TRUE,
method = "EM",
use_diff_init = 30)
# Estimate model
mdl_est_hmm <- HMmdl(simu_hmm[["y"]], k = 2, control = control)
summary(mdl_est_hmm)
### ----- Estimate Markov switching autoregressive model -----
# Set options for model estimation
control <- list(msmu = TRUE,
msvar = TRUE,
method = "EM",
use_diff_init = 30)
# Estimate model
mdl_est_msar <- MSARmdl(simu_msar[["y"]], p = 1, k = 2, control = control)
summary(mdl_est_msar)
### ----- Estimate Markov switching vector autoregressive model -----
# Set options for model estimation
control <- list(msmu = TRUE,
msvar = TRUE,
method = "EM",
use_diff_init = 30)
# Estimate model
mdl_est_msvar <- MSVARmdl(simu_msvar[["y"]], p = 1, k = 2, control = control)
summary(mdl_est_msvar)
# plot simulated process, true regime states and model estimated smoothed probabilities
pdf(file = "MSestim_smoothedprobs.pdf")
par(mfrow=c(3,1))
plot(simu_hmm$y[,1], type = "l", ylab = "", main = "Hidden Markov process",cex.main=1)
par(new = TRUE)
lines(simu_hmm$y[,2], type = "l", ylab = "", col = "blue")
par(new = TRUE)
plot(mdl_est_hmm$St[,1], type = "l", ylab = "", col = "green3", lty="dashed", axes = FALSE)
par(new = TRUE)
plot(simu_hmm$St, type = "l", ylab = "", col = "red", lty="dashed", axes = FALSE)
axis(side = 4, at = pretty(range(0,1)))
plot(simu_msar$y[,1], type = "l", ylab = "", main = "Markov switching autoregressive process",cex.main=1)
par(new = TRUE)
plot(mdl_est_msar$St[,1], type = "l", ylab = "", col = "green3", lty="dashed", axes = FALSE)
par(new = TRUE)
plot(simu_msar$St, type = "l", ylab = "", col = "red", lty="dashed", axes = FALSE)
axis(side = 4, at = pretty(range(0,1)))
plot(simu_msvar$y[,1], type = "l", ylab = "", main = "Markov switching vector autoregressive process",cex.main=1)
par(new = TRUE)
lines(simu_msvar$y[,2], type = "l", ylab = "", col = "blue")
par(new = TRUE)
plot(mdl_est_msvar$St[,2], type = "l", ylab = "", col = "green3", lty="dashed", axes = FALSE)
par(new = TRUE)
plot(simu_msvar$St, type = "l", ylab = "", col = "red", lty="dashed", axes = FALSE)
axis(side = 4, at = pretty(range(0,1)))
dev.off()
### ----- Estimate Hidden Markov model -----
# Set options for model estimation
control <- list(msmu = TRUE,
msvar = TRUE,
method = "EM",
use_diff_init = 30)
# Estimate model
mdl_est_hmm <- HMmdl(simu_hmm[["y"]], k = 2, control = control)
summary(mdl_est_hmm)
set.seed(seed)
### ----- Estimate Markov switching autoregressive model -----
# Set options for model estimation
control <- list(msmu = TRUE,
msvar = TRUE,
method = "EM",
use_diff_init = 30)
# Estimate model
mdl_est_msar <- MSARmdl(simu_msar[["y"]], p = 1, k = 2, control = control)
summary(mdl_est_msar)
set.seed(seed)
### ----- Estimate Markov switching vector autoregressive model -----
# Set options for model estimation
control <- list(msmu = TRUE,
msvar = TRUE,
method = "EM",
use_diff_init = 30)
# Estimate model
mdl_est_msvar <- MSVARmdl(simu_msvar[["y"]], p = 1, k = 2, control = control)
summary(mdl_est_msvar)
# plot simulated process, true regime states and model estimated smoothed probabilities
pdf(file = "MSestim_smoothedprobs.pdf")
par(mfrow=c(3,1))
plot(simu_hmm$y[,1], type = "l", ylab = "", main = "Hidden Markov process",cex.main=1)
par(new = TRUE)
lines(simu_hmm$y[,2], type = "l", ylab = "", col = "blue")
par(new = TRUE)
plot(mdl_est_hmm$St[,1], type = "l", ylab = "", col = "green3", lty="dashed", axes = FALSE)
par(new = TRUE)
plot(simu_hmm$St, type = "l", ylab = "", col = "red", lty="dashed", axes = FALSE)
axis(side = 4, at = pretty(range(0,1)))
plot(simu_msar$y[,1], type = "l", ylab = "", main = "Markov switching autoregressive process",cex.main=1)
par(new = TRUE)
plot(mdl_est_msar$St[,1], type = "l", ylab = "", col = "green3", lty="dashed", axes = FALSE)
par(new = TRUE)
plot(simu_msar$St, type = "l", ylab = "", col = "red", lty="dashed", axes = FALSE)
axis(side = 4, at = pretty(range(0,1)))
plot(simu_msvar$y[,1], type = "l", ylab = "", main = "Markov switching vector autoregressive process",cex.main=1)
par(new = TRUE)
lines(simu_msvar$y[,2], type = "l", ylab = "", col = "blue")
par(new = TRUE)
plot(mdl_est_msvar$St[,2], type = "l", ylab = "", col = "green3", lty="dashed", axes = FALSE)
par(new = TRUE)
plot(simu_msvar$St, type = "l", ylab = "", col = "red", lty="dashed", axes = FALSE)
axis(side = 4, at = pretty(range(0,1)))
dev.off()
# =========================================================== #
## ----- Hypothesis Testing -----
# =========================================================== #
### ----- Test Markov switching autoregressive process using Rodriguez-Rondon & Dufour (2024) LMC-LRT -----
set.seed(seed)
# Set options for testing procedure
lmc_control = list(N = 99,
mdl_h0_control = list(const = TRUE,
getSE = FALSE),
mdl_h1_control = list(msmu = TRUE,
msvar = TRUE,
getSE = FALSE,
method = "EM",
use_diff_init = 5))
# Perform Rodriguez-Rondon & Dufour (2023) LMC-LRT
lmclrt <- LMCLRTest(simu_msar[["y"]], p = 1, k0 = 1 , k1 = 2, control = lmc_control)
summary(lmclrt)
### ----- Test autoregressive process using Rodriguez-Rondon & Dufour (2024) MMC-LRT -----
set.seed(seed)
# Set options for testing procedure
mmc_control = list(N = 99,
eps = 0.3,
threshold_stop = 0.05 + 1e-6,
type = "pso",
workers = 8,
CI_union = FALSE,
mdl_h0_control = list(const = TRUE,
getSE = FALSE),
mdl_h1_control = list(msmu = TRUE,
msvar = TRUE,
getSE = FALSE,
method = "EM"),
maxit = 100)
# start cluster
doParallel::registerDoParallel(mmc_control[["workers"]])
# Perform Rodriguez-Rondon & Dufour (2023) MMC-LRT
mmclrt <- MMCLRTest(simu_ar[["y"]], p = 1, k0 = 1 , k1 = 2, control = mmc_control)
summary(mmclrt)
# stop cluster
doParallel::stopImplicitCluster()
set.seed(seed)
# Set options for testing procedure
lmc_control = list(N = 99,
simdist_N = 10000,
getSE = TRUE)
# Perform Dufour & Luger (2017) LMC test
lmcmoment <- DLMCTest(simu_msar[["y"]], p = 1, control = lmc_control)
summary(lmcmoment)
set.seed(seed)
# Set options for testing procedure
mmc_control <- list(N = 99,
getSE = TRUE,
eps = 1e-9,
CI_union = TRUE,
optim_type = "GenSA",
threshold_stop = 0.05 + 1e-6,
type_control = list(maxit = 100))
# Perform Dufour & Luger (2017) MMC test
mmcmoment <- DLMMCTest(simu_msar[["y"]], p = 1, control = mmc_control)
summary(mmcmoment)
set.seed(seed)
# Set options for testing procedure
mmc_control <- list(N = 99,
getSE = TRUE,
eps = 1e-9,
CI_union = TRUE,
optim_type = "GenSA",
threshold_stop = 0.05 + 1e-6,
maxit = 100)
# Perform Dufour & Luger (2017) MMC test
mmcmoment <- DLMMCTest(simu_msar[["y"]], p = 1, control = mmc_control)
summary(mmcmoment)
set.seed(seed)
# Set options for testing procedure
chp_control = list(N = 1000,
rho_b = 0.7,
msvar = TRUE)
# Perform Carrasco, Hu, & Ploberger (2014) test
pstabilitytest <- CHPTest(simu_ar[["y"]], p = 1, control = chp_control)
summary(pstabilitytest)
### ----- Test Markov switching autoregressive process using Hansen (1992) LRT -----
set.seed(seed)
# Set options for testing procedure
hlrt_control <- list(msvar = TRUE,
gridsize = 20,
mugrid_from = 0,
mugrid_by = 1,
siggrid_from = 0.5,
siggrid_by = 0.1,
theta_null_low = c(0,-0.99,0.01),
theta_null_upp = c(20,0.99,20))
# Perform Hansen (1992) likelihood ratio test
hlrt <- HLRTest(simu_msar[["y"]], p = 1, control = hlrt_control)
summary(hlrt)
R.version.string
citation()
citation(MSTest)
citation("MSTest"")
citation("MSTest")
citation("pso")
citation("foreachpack")
citation("foreach")
citation("doparallel")
citation("doParallel")
citation("Rcpp")
citation("doParallel",options(citation.bibtex.max=999))
citation("Rcpp",options(citation.bibtex.max=999))
options(citation.bibtex.max=999)
citation("Rcpp")
citation("RcppArmadillo")
packageVersion(Rcpp)
packageVersion("Rcpp")
packageVersion("RcppArmadillo")
packageVersion("GenSA")
citation("GenSA")
packageVersion("pso")
packageVersion("foreach")
packageVersion("doParallel")
sessionInfo()
Sys.info()