Content

ランダムウォーク2系列の回帰分析から見せかけの回帰を確認しましょう。
set.seed(20190102)
library(tseries)
fun_calculation <- function(n=12*10){
  obj <- data.frame(n=seq(n),rw_blue = cumsum(rnorm(n)),rw_red = cumsum(rnorm(n)))
  result_lm <- lm(obj$rw_red~obj$rw_blue)
  result_adf <- apply(obj[,-1],2,adf.test)
  return(list('obj'=obj,'result_lm'=result_lm,'result_adf'=result_adf))
}
result_lm_adf <- lapply(X = seq(100),FUN = function(x)fun_calculation())


シミュレーション結果
No. slope Pr |r| adf test:p_value(blue) adf test:p_value(red)
1 -0.3866103 2.614686e-03 0.272 0.7822267 0.5147557
2 -1.6419267 2.52575e-16 0.66 0.0768731 0.99
3 -0.2686837 9.935517e-25 0.769 0.587752 0.159791
4 -0.0557305 6.165847e-01 0.046 0.6544758 0.470589
5 0.2059091 6.264176e-04 0.308 0.727041 0.1777418
6 0.0559933 2.617785e-02 0.203 0.3476206 0.6378531
7 -0.0301946 7.081948e-01 0.035 0.3153305 0.6237523
8 -1.228424 7.917889e-28 0.799 0.9371724 0.0512222
9 -0.0905298 1.291681e-02 0.226 0.3340851 0.3526858
10 -0.0331515 8.578619e-01 0.017 0.4156226 0.575534
11 -0.0668871 6.54197e-02 0.169 0.2884706 0.4240141
12 1.0363306 3.322507e-23 0.753 0.6094544 0.4904518
13 -0.1886036 7.87709e-05 0.352 0.906945 0.4363763
14 0.1685169 1.481499e-04 0.34 0.6028218 0.01
15 -0.4880918 9.611335e-03 0.236 0.0451903 0.6592499
16 0.1122482 1.505649e-02 0.221 0.6688006 0.6617955
17 -0.059265 3.020336e-01 0.095 0.5659042 0.9387599
18 -0.3871054 1.015414e-02 0.234 0.0723965 0.6910092
19 -0.220972 1.809889e-08 0.486 0.5775387 0.6038144
20 -0.3231651 1.766462e-03 0.283 0.5670364 0.346844
21 0.032787 6.975466e-01 0.036 0.9858074 0.590543
22 -0.3957196 6.815769e-13 0.596 0.4508585 0.2897484
23 -0.4607798 2.133943e-02 0.21 0.475275 0.4634931
24 0.3605043 2.186211e-18 0.692 0.1866004 0.0237634
25 -0.1533477 1.456846e-03 0.287 0.47724 0.087492
26 0.1508146 1.577592e-01 0.13 0.8750331 0.0518936
27 -0.2840067 1.01626e-05 0.391 0.9058706 0.350491
28 0.2020067 3.403466e-03 0.265 0.6497907 0.3629584
29 0.0626357 2.591713e-01 0.104 0.7733262 0.0471707
30 -0.1410841 1.512995e-08 0.488 0.3227976 0.7318669
31 0.6268101 1.066974e-06 0.428 0.99 0.9367588
32 -0.1349093 3.713257e-02 0.191 0.0332345 0.3104532
33 0.5308405 1.225563e-13 0.611 0.7654255 0.6381499
34 0.2625635 3.388856e-07 0.446 0.5968917 0.5711556
35 0.1845242 5.879013e-05 0.358 0.8696674 0.4278616
36 0.1973583 1.132156e-01 0.145 0.2842463 0.9773055
37 -0.8518967 5.695592e-37 0.864 0.1537254 0.3400339
38 0.1308479 2.392638e-01 0.108 0.3815577 0.6849915
39 -0.9018348 8.740837e-25 0.77 0.7092815 0.764888
40 -1.0938694 7.921564e-17 0.668 0.323326 0.5757721
41 0.7857707 4.388756e-24 0.763 0.423952 0.1897502
42 1.6868022 8.267406e-23 0.749 0.2726106 0.0101247
43 -0.2908448 1.634406e-05 0.382 0.7731706 0.4584576
44 -0.2966665 3.779895e-17 0.673 0.022002 0.2885194
45 0.0401133 6.902001e-01 0.037 0.3932963 0.5900591
46 -1.0998832 2.518204e-16 0.66 0.070072 0.9203331
47 0.1769314 5.806381e-02 0.174 0.4001775 0.7000181
48 0.0760054 2.186695e-02 0.209 0.5762928 0.7640283
49 -0.4574162 1.657719e-04 0.337 0.6477839 0.0806401
50 0.7672883 4.735728e-20 0.715 0.0973225 0.111897
51 -0.7307492 1.54313e-13 0.609 0.9020163 0.6974946
52 -0.1253053 3.841016e-03 0.262 0.9335164 0.2454279
53 0.2851177 2.183833e-01 0.113 0.6566701 0.4237136
54 -2.2863211 2.008298e-19 0.706 0.0413278 0.0330921
55 -0.495338 6.138847e-16 0.653 0.5956759 0.2135582
56 -1.7331279 1.487583e-17 0.679 0.5348008 0.7255111
57 0.2943906 2.071853e-10 0.539 0.1336383 0.4430777
58 0.1449496 9.901651e-02 0.151 0.7971493 0.8073765
59 0.4413054 6.731341e-19 0.699 0.6586549 0.6447966
60 -0.0735141 4.251027e-01 0.073 0.7830733 0.5044752
61 0.5423086 7.265393e-12 0.574 0.99 0.6869407
62 0.4211802 5.697577e-04 0.31 0.5578295 0.2361895
63 0.7460666 1.392895e-35 0.856 0.1866575 0.1339174
64 0.5589338 2.440739e-22 0.743 0.01 0.5335385
65 0.0809833 5.024534e-01 0.062 0.4513972 0.3404594
66 0.6748642 2.320682e-39 0.877 0.4669055 0.01
67 -0.4068843 1.175948e-18 0.696 0.0925391 0.3091907
68 0.841021 1.742334e-16 0.662 0.6675174 0.3582323
69 0.6131608 7.141828e-36 0.858 0.8318781 0.7034233
70 0.0596187 1.534585e-01 0.131 0.9754802 0.4035565
71 0.0151131 8.34702e-01 0.019 0.2904206 0.4791181
72 -1.5481151 1.481546e-53 0.931 0.4333814 0.8837904
73 0.6276802 3.724866e-23 0.753 0.4798028 0.8012084
74 -0.0919443 4.313691e-01 0.072 0.2992043 0.6207261
75 -0.0959122 1.336416e-01 0.138 0.5140419 0.6566059
76 -0.4087161 4.542094e-13 0.6 0.3730424 0.5470724
77 0.4112215 1.725252e-08 0.487 0.0812302 0.3148921
78 -0.2242966 1.557434e-02 0.22 0.266922 0.6953997
79 0.2027356 8.149017e-04 0.302 0.5721345 0.266004
80 0.0617283 4.134812e-01 0.075 0.5956766 0.6332084
81 -0.0282744 8.75617e-01 0.014 0.1616444 0.8310294
82 -0.3676827 1.15099e-06 0.427 0.8106479 0.7190328
83 -0.213749 3.09928e-08 0.479 0.1460311 0.5627819
84 -1.712121 1.005e-33 0.844 0.01 0.1776322
85 0.6559315 1.156974e-23 0.758 0.6918742 0.9035605
86 -0.0582198 2.771354e-02 0.201 0.3294229 0.01
87 2.3569834 2.201243e-20 0.719 0.0108073 0.2841679
88 0.4882685 2.740563e-17 0.675 0.7892745 0.5240444
89 0.2647547 6.345964e-04 0.307 0.2831253 0.5318973
90 0.1267566 1.795185e-01 0.123 0.0755764 0.6302326
91 -0.0152017 7.871629e-01 0.025 0.4546051 0.9251064
92 0.3809659 3.060311e-07 0.447 0.4664772 0.8560266
93 0.565627 7.781257e-11 0.55 0.5804733 0.037747
94 -0.4111481 7.691636e-08 0.467 0.403523 0.928531
95 0.143933 3.868086e-02 0.189 0.4149978 0.2335793
96 0.5709785 1.948972e-06 0.419 0.7835656 0.5400169
97 -1.0557231 1.146966e-02 0.23 0.1765016 0.9520604
98 -0.4244243 2.912999e-03 0.27 0.0618071 0.7687858
99 0.3053843 3.671683e-02 0.191 0.490428 0.2882501
100 -0.2525538 2.527728e-04 0.328 0.6831811 0.1956849
2系列はランダムウォーク、つまり独立にも関わらず100回の試行中、相関係数の絶対値が0.7以上は18回、0.4以上0.7未満は28回、0.2以上0.4未満は27回、0以上0.2未満が27回。