2014年9月11日から過去三カ月間の日経平均終値と各種通貨との関連 データ出所:株式会社日本経済新聞社、株式会社みずほ銀行

nikkei_stock_average_daily_jp.csv_NIKKEIclose quote.csv_USDquote.csv_GBP quote.csv_EURquote.csv_NZD quote.csv_AUDquote.csv_ZAR CCF_NIKKEIclose-ZARCCF_NIKKEIclose-USD CCF_NIKKEIclose-NZDCCF_NIKKEIclose-GBP CCF_NIKKEIclose-EURCCF_NIKKEIclose-AUD
ファイル名:nikkei_stock_average_daily_jp.csv,列名:NIKKEIclose,対象期間:2014/6/12-2014/9/11
1)単位根検定 H0:単位根が存在する(ランダムウォークである) 
・原系列,p値=0.4554338
・一次階差,p値=0.01

2)Summary 
・原系列 
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  14780   15270   15370   15380   15520   15910 
・一次階差 
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-454.00  -47.41   16.73   14.62   77.71  352.10 

3)その他基本統計量 
・原系列 
要素数= 65 ,不偏分散= 47673.5 ,標準偏差= 218.3426
・一次階差 
要素数= 64 ,不偏分散= 13923.31 ,標準偏差= 117.9971
 
4)ARIMA 
・原系列
 ARIMA(2,1,2) with drift         : 1e+20
 ARIMA(0,1,0) with drift         : 782.8973
 ARIMA(1,1,0) with drift         : 783.0718
 ARIMA(0,1,1) with drift         : 783.4043
 ARIMA(1,1,1) with drift         : 784.7234
 ARIMA(0,1,0)                    : 794.2511

 Best model: ARIMA(0,1,0) with drift         

Series: dataset[, ccc] 
ARIMA(0,1,0) with drift         

Coefficients:
        drift
      14.6198
s.e.  14.7496

sigma^2 estimated as 13923:  log likelihood=-389.45
AIC=782.9   AICc=783.09   BIC=787.22

5)ARIMA残差の正規性 H0:正規分布からのサンプルである 
・原系列
        Shapiro-Wilk normality test

data:  Result.arima$res
W = 0.9474, p-value = 0.007874

6)原系列の一部 
          date NIKKEIclose
846 2014-06-12    14973.53
847 2014-06-13    15097.84
848 2014-06-16    14933.29
849 2014-06-17    14975.97
850 2014-06-18    15115.80
851 2014-06-19    15361.16
852 2014-06-20    15349.42
853 2014-06-23    15369.28
854 2014-06-24    15376.24
855 2014-06-25    15266.61

 





ファイル名:quote.csv,列名:USD,対象期間:2014/6/12-2014/9/11
1)単位根検定 H0:単位根が存在する(ランダムウォークである) 
・原系列,p値=0.99
・一次階差,p値=0.01

2)Summary 
・原系列 
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  101.3   101.7   102.2   102.7   103.0   106.8 
・一次階差 
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
-0.46000 -0.11250  0.04000  0.07437  0.23250  0.93000 

3)その他基本統計量 
・原系列 
要素数= 65 ,不偏分散= 1.809968 ,標準偏差= 1.345351
・一次階差 
要素数= 64 ,不偏分散= 0.0944377 ,標準偏差= 0.3073072
 
4)ARIMA 
・原系列
 ARIMA(2,2,2)                    : 32.33825
 ARIMA(0,2,0)                    : 76.75318
 ARIMA(1,2,0)                    : 41.64423
 ARIMA(0,2,1)                    : 35.62681
 ARIMA(1,2,2)                    : 33.77092
 ARIMA(3,2,2)                    : 30.80099
 ARIMA(3,2,1)                    : 30.32753
 ARIMA(2,2,0)                    : 43.57795
 ARIMA(4,2,2)                    : 34.29891
 ARIMA(3,2,1)                    : 30.32753
 ARIMA(2,2,1)                    : 33.84756
 ARIMA(4,2,1)                    : 32.32518
 ARIMA(3,2,0)                    : 39.66283

 Best model: ARIMA(3,2,1)                    

Series: dataset[, ccc] 
ARIMA(3,2,1)                    

Coefficients:
          ar1     ar2      ar3      ma1
      -0.0358  0.2371  -0.3120  -0.9099
s.e.   0.1252  0.1247   0.1273   0.0556

sigma^2 estimated as 0.07784:  log likelihood=-10.16
AIC=30.33   AICc=31.38   BIC=41.04

5)ARIMA残差の正規性 H0:正規分布からのサンプルである 
・原系列
        Shapiro-Wilk normality test

data:  Result.arima$res
W = 0.9912, p-value = 0.9273

6)原系列の一部 
           date    USD    GBP    EUR   AUD   NZD  ZAR
2996 2014-06-12 102.04 171.38 138.16 95.73 88.16 9.51
2997 2014-06-13 101.80 172.52 137.97 95.89 88.24 9.53
2998 2014-06-16 101.98 173.18 138.08 95.71 88.49 9.52
2999 2014-06-17 101.95 173.07 138.44 95.74 88.40 9.51
3000 2014-06-18 102.18 173.37 138.44 95.41 88.56 9.44
3001 2014-06-19 102.01 173.35 138.58 95.90 88.91 9.55
3002 2014-06-20 101.90 173.61 138.73 95.81 88.80 9.48
3003 2014-06-23 102.10 173.69 138.72 95.85 88.90 9.57
3004 2014-06-24 101.83 173.32 138.49 95.98 88.72 9.61
3005 2014-06-25 101.96 173.13 138.69 95.42 88.36 9.58

 


ファイル名:quote.csv,列名:GBP,対象期間:2014/6/12-2014/9/11
1)単位根検定 H0:単位根が存在する(ランダムウォークである) 
・原系列,p値=0.07158046
・一次階差,p値=0.01

2)Summary 
・原系列 
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  170.6   172.2   173.0   172.9   173.6   175.3 
・一次階差 
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
-1.49000 -0.27250  0.02000  0.02797  0.30000  1.96000 

3)その他基本統計量 
・原系列 
要素数= 65 ,不偏分散= 1.128713 ,標準偏差= 1.062409
・一次階差 
要素数= 64 ,不偏分散= 0.3485783 ,標準偏差= 0.5904052
 
4)ARIMA 
・原系列
 ARIMA(2,1,2) with drift         : 116.2175
 ARIMA(0,1,0) with drift         : 115.3989
 ARIMA(1,1,0) with drift         : 115.7131
 ARIMA(0,1,1) with drift         : 115.6111
 ARIMA(1,1,1) with drift         : 117.602
 ARIMA(0,1,0)                    : 115.3129
 ARIMA(1,1,0)                    : 115.6456
 ARIMA(0,1,1)                    : 115.5307
 ARIMA(1,1,1)                    : 117.5243

 Best model: ARIMA(0,1,0)                    

Series: dataset[, ccc] 
ARIMA(0,1,0)                    

sigma^2 estimated as 0.3439:  log likelihood=-56.66
AIC=115.31   AICc=115.38   BIC=117.47

5)ARIMA残差の正規性 H0:正規分布からのサンプルである 
・原系列
        Shapiro-Wilk normality test

data:  Result.arima$res
W = 0.978, p-value = 0.3001

6)原系列の一部 
           date    USD    GBP    EUR   AUD   NZD  ZAR
2996 2014-06-12 102.04 171.38 138.16 95.73 88.16 9.51
2997 2014-06-13 101.80 172.52 137.97 95.89 88.24 9.53
2998 2014-06-16 101.98 173.18 138.08 95.71 88.49 9.52
2999 2014-06-17 101.95 173.07 138.44 95.74 88.40 9.51
3000 2014-06-18 102.18 173.37 138.44 95.41 88.56 9.44
3001 2014-06-19 102.01 173.35 138.58 95.90 88.91 9.55
3002 2014-06-20 101.90 173.61 138.73 95.81 88.80 9.48
3003 2014-06-23 102.10 173.69 138.72 95.85 88.90 9.57
3004 2014-06-24 101.83 173.32 138.49 95.98 88.72 9.61
3005 2014-06-25 101.96 173.13 138.69 95.42 88.36 9.58

 


ファイル名:quote.csv,列名:EUR,対象期間:2014/6/12-2014/9/11
1)単位根検定 H0:単位根が存在する(ランダムウォークである) 
・原系列,p値=0.04863389
・一次階差,p値=0.01

2)Summary 
・原系列 
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  136.1   136.9   137.7   137.6   138.3   139.1 
・一次階差 
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
-1.430000 -0.222500 -0.020000 -0.002031  0.217500  1.050000 

3)その他基本統計量 
・原系列 
要素数= 65 ,不偏分散= 0.6200622 ,標準偏差= 0.7874403
・一次階差 
要素数= 64 ,不偏分散= 0.1729656 ,標準偏差= 0.4158914
 
4)ARIMA 
・原系列
 ARIMA(2,1,2) with drift         : 1e+20
 ARIMA(0,1,0) with drift         : 71.25039
 ARIMA(1,1,0) with drift         : 71.91699
 ARIMA(0,1,1) with drift         : 70.55368
 ARIMA(1,1,1) with drift         : 69.88825
 ARIMA(1,1,2) with drift         : 1e+20
 ARIMA(1,1,1)                    : 68.87066
 ARIMA(0,1,1)                    : 69.57842
 ARIMA(2,1,1)                    : 65.38308
 ARIMA(2,1,0)                    : 66.61949
 ARIMA(2,1,2)                    : 67.24771
 ARIMA(1,1,0)                    : 70.96346
 ARIMA(3,1,2)                    : 67.86139
 ARIMA(2,1,1) with drift         : 66.10694
 ARIMA(3,1,1)                    : 67.28077

 Best model: ARIMA(2,1,1)                    

Series: dataset[, ccc] 
ARIMA(2,1,1)                    

Coefficients:
         ar1      ar2      ma1
      0.7578  -0.3858  -0.6769
s.e.  0.2044   0.1224   0.2025

sigma^2 estimated as 0.1425:  log likelihood=-28.69
AIC=65.38   AICc=66.06   BIC=74.02

5)ARIMA残差の正規性 H0:正規分布からのサンプルである 
・原系列
        Shapiro-Wilk normality test

data:  Result.arima$res
W = 0.9804, p-value = 0.3892

6)原系列の一部 
           date    USD    GBP    EUR   AUD   NZD  ZAR
2996 2014-06-12 102.04 171.38 138.16 95.73 88.16 9.51
2997 2014-06-13 101.80 172.52 137.97 95.89 88.24 9.53
2998 2014-06-16 101.98 173.18 138.08 95.71 88.49 9.52
2999 2014-06-17 101.95 173.07 138.44 95.74 88.40 9.51
3000 2014-06-18 102.18 173.37 138.44 95.41 88.56 9.44
3001 2014-06-19 102.01 173.35 138.58 95.90 88.91 9.55
3002 2014-06-20 101.90 173.61 138.73 95.81 88.80 9.48
3003 2014-06-23 102.10 173.69 138.72 95.85 88.90 9.57
3004 2014-06-24 101.83 173.32 138.49 95.98 88.72 9.61
3005 2014-06-25 101.96 173.13 138.69 95.42 88.36 9.58

 


ファイル名:quote.csv,列名:AUD,対象期間:2014/6/12-2014/9/11
1)単位根検定 H0:単位根が存在する(ランダムウォークである) 
・原系列,p値=0.7639864
・一次階差,p値=0.01

2)Summary 
・原系列 
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  94.57   95.43   95.74   96.01   96.34   98.59 
・一次階差 
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
-0.94000 -0.16000  0.10500  0.03359  0.21250  0.87000 

3)その他基本統計量 
・原系列 
要素数= 65 ,不偏分散= 0.9192078 ,標準偏差= 0.9587532
・一次階差 
要素数= 64 ,不偏分散= 0.1147948 ,標準偏差= 0.3388138
 
4)ARIMA 
・原系列
 ARIMA(2,1,2) with drift         : 1e+20
 ARIMA(0,1,0) with drift         : 45.42374
 ARIMA(1,1,0) with drift         : 46.60569
 ARIMA(0,1,1) with drift         : 46.6375
 ARIMA(1,1,1) with drift         : 48.51193
 ARIMA(0,1,0)                    : 44.71726
 ARIMA(1,1,0)                    : 46.02438
 ARIMA(0,1,1)                    : 46.0719
 ARIMA(1,1,1)                    : 47.87897

 Best model: ARIMA(0,1,0)                    

Series: dataset[, ccc] 
ARIMA(0,1,0)                    

sigma^2 estimated as 0.1141:  log likelihood=-21.36
AIC=44.72   AICc=44.78   BIC=46.88

5)ARIMA残差の正規性 H0:正規分布からのサンプルである 
・原系列
        Shapiro-Wilk normality test

data:  Result.arima$res
W = 0.9754, p-value = 0.2213

6)原系列の一部 
           date    USD    GBP    EUR   AUD   NZD  ZAR
2996 2014-06-12 102.04 171.38 138.16 95.73 88.16 9.51
2997 2014-06-13 101.80 172.52 137.97 95.89 88.24 9.53
2998 2014-06-16 101.98 173.18 138.08 95.71 88.49 9.52
2999 2014-06-17 101.95 173.07 138.44 95.74 88.40 9.51
3000 2014-06-18 102.18 173.37 138.44 95.41 88.56 9.44
3001 2014-06-19 102.01 173.35 138.58 95.90 88.91 9.55
3002 2014-06-20 101.90 173.61 138.73 95.81 88.80 9.48
3003 2014-06-23 102.10 173.69 138.72 95.85 88.90 9.57
3004 2014-06-24 101.83 173.32 138.49 95.98 88.72 9.61
3005 2014-06-25 101.96 173.13 138.69 95.42 88.36 9.58

 


ファイル名:quote.csv,列名:NZD,対象期間:2014/6/12-2014/9/11
1)単位根検定 H0:単位根が存在する(ランダムウォークである) 
・原系列,p値=0.8050185
・一次階差,p値=0.01

2)Summary 
・原系列 
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  86.15   86.95   87.55   87.85   88.80   89.64 
・一次階差 
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
-0.930000 -0.212500  0.030000 -0.006406  0.160000  0.800000 

3)その他基本統計量 
・原系列 
要素数= 65 ,不偏分散= 0.9982351 ,標準偏差= 0.9991172
・一次階差 
要素数= 64 ,不偏分散= 0.102725 ,標準偏差= 0.3205074
 
4)ARIMA 
・原系列
 ARIMA(2,1,2) with drift         : 44.15524
 ARIMA(0,1,0) with drift         : 38.42501
 ARIMA(1,1,0) with drift         : 39.05723
 ARIMA(0,1,1) with drift         : 39.12069
 ARIMA(1,1,1) with drift         : 41.01511
 ARIMA(0,1,0)                    : 36.99741
 ARIMA(1,1,0)                    : 37.61931
 ARIMA(0,1,1)                    : 37.68607
 ARIMA(1,1,1)                    : 39.574

 Best model: ARIMA(0,1,0)                    

Series: dataset[, ccc] 
ARIMA(0,1,0)                    

sigma^2 estimated as 0.1012:  log likelihood=-17.5
AIC=37   AICc=37.06   BIC=39.16

5)ARIMA残差の正規性 H0:正規分布からのサンプルである 
・原系列
        Shapiro-Wilk normality test

data:  Result.arima$res
W = 0.9667, p-value = 0.07748

6)原系列の一部 
           date    USD    GBP    EUR   AUD   NZD  ZAR
2996 2014-06-12 102.04 171.38 138.16 95.73 88.16 9.51
2997 2014-06-13 101.80 172.52 137.97 95.89 88.24 9.53
2998 2014-06-16 101.98 173.18 138.08 95.71 88.49 9.52
2999 2014-06-17 101.95 173.07 138.44 95.74 88.40 9.51
3000 2014-06-18 102.18 173.37 138.44 95.41 88.56 9.44
3001 2014-06-19 102.01 173.35 138.58 95.90 88.91 9.55
3002 2014-06-20 101.90 173.61 138.73 95.81 88.80 9.48
3003 2014-06-23 102.10 173.69 138.72 95.85 88.90 9.57
3004 2014-06-24 101.83 173.32 138.49 95.98 88.72 9.61
3005 2014-06-25 101.96 173.13 138.69 95.42 88.36 9.58

 


ファイル名:quote.csv,列名:ZAR,対象期間:2014/6/12-2014/9/11
1)単位根検定 H0:単位根が存在する(ランダムウォークである) 
・原系列,p値=0.355486
・一次階差,p値=0.01

2)Summary 
・原系列 
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  9.440   9.520   9.610   9.617   9.700   9.850 
・一次階差 
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
-0.100000 -0.022500  0.010000  0.003906  0.030000  0.130000 

3)その他基本統計量 
・原系列 
要素数= 65 ,不偏分散= 0.01211596 ,標準偏差= 0.1100725
・一次階差 
要素数= 64 ,不偏分散= 0.002382912 ,標準偏差= 0.04881508
 
4)ARIMA 
・原系列
 ARIMA(2,1,2) with drift         : 1e+20
 ARIMA(0,1,0) with drift         : -198.6901
 ARIMA(1,1,0) with drift         : -206.4706
 ARIMA(0,1,1) with drift         : -205.0029
 ARIMA(2,1,0) with drift         : -204.6541
 ARIMA(1,1,1) with drift         : -204.6776
 ARIMA(2,1,1) with drift         : -202.6793
 ARIMA(1,1,0)                    : -211.0008
 ARIMA(0,1,0)                    : -203.4924
 ARIMA(2,1,0)                    : -209.2984
 ARIMA(1,1,1)                    : -209.3086
 ARIMA(2,1,1)                    : -207.3099

 Best model: ARIMA(1,1,0)                    

Series: dataset[, ccc] 
ARIMA(1,1,0)                    

Coefficients:
          ar1
      -0.3695
s.e.   0.1151

sigma^2 estimated as 0.00203:  log likelihood=107.5
AIC=-211   AICc=-210.8   BIC=-206.68

5)ARIMA残差の正規性 H0:正規分布からのサンプルである 
・原系列
        Shapiro-Wilk normality test

data:  Result.arima$res
W = 0.9801, p-value = 0.3784

6)原系列の一部 
           date    USD    GBP    EUR   AUD   NZD  ZAR
2996 2014-06-12 102.04 171.38 138.16 95.73 88.16 9.51
2997 2014-06-13 101.80 172.52 137.97 95.89 88.24 9.53
2998 2014-06-16 101.98 173.18 138.08 95.71 88.49 9.52
2999 2014-06-17 101.95 173.07 138.44 95.74 88.40 9.51
3000 2014-06-18 102.18 173.37 138.44 95.41 88.56 9.44
3001 2014-06-19 102.01 173.35 138.58 95.90 88.91 9.55
3002 2014-06-20 101.90 173.61 138.73 95.81 88.80 9.48
3003 2014-06-23 102.10 173.69 138.72 95.85 88.90 9.57
3004 2014-06-24 101.83 173.32 138.49 95.98 88.72 9.61
3005 2014-06-25 101.96 173.13 138.69 95.42 88.36 9.58

 



NIKKEIclose(説明変数)とUSD(応答変数)との共和分検定 H0:共和分関係なし(誤差項は非定常)
######################################## 
# Phillips and Ouliaris Unit Root Test # 
######################################## 

Test of type Pu 
detrending of series with constant and linear trend 


Call:
lm(formula = z[, 1] ~ z[, -1] + trd)

Residuals:
     Min       1Q   Median       3Q      Max 
-1.31893 -0.49784 -0.03266  0.36300  1.68534 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) 68.194937   8.339467   8.177 1.95e-11 ***
z[, -1]      0.002154   0.000551   3.908 0.000233 ***
trd          0.040899   0.006363   6.428 2.08e-08 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.7312 on 62 degrees of freedom
Multiple R-squared:  0.7138,    Adjusted R-squared:  0.7046 
F-statistic: 77.32 on 2 and 62 DF,  p-value: < 2.2e-16


Value of test-statistic is: 5.3919 

Critical values of Pu are:
                  10pct    5pct    1pct
critical values 41.2488 48.8439 65.1714


NIKKEIclose(説明変数)とUSD(応答変数)との線形回帰残差のダービン=ワトソン検定 H0:自己相関無し
        Durbin-Watson test

data:  lm(AllData02[, c(nnn, 2)])
DW = 0.3293, p-value < 2.2e-16
alternative hypothesis: true autocorrelation is greater than 0




NIKKEIclose(説明変数)とGBP(応答変数)との共和分検定 H0:共和分関係なし(誤差項は非定常)
######################################## 
# Phillips and Ouliaris Unit Root Test # 
######################################## 

Test of type Pu 
detrending of series with constant and linear trend 


Call:
lm(formula = z[, 1] ~ z[, -1] + trd)

Residuals:
     Min       1Q   Median       3Q      Max 
-2.04089 -0.45481 -0.03936  0.61674  1.57647 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)  1.359e+02  9.173e+00  14.815  < 2e-16 ***
z[, -1]      2.509e-03  6.061e-04   4.139 0.000107 ***
trd         -4.916e-02  6.999e-03  -7.024 1.96e-09 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.8044 on 62 degrees of freedom
Multiple R-squared:  0.4447,    Adjusted R-squared:  0.4268 
F-statistic: 24.82 on 2 and 62 DF,  p-value: 1.204e-08


Value of test-statistic is: 29.9762 

Critical values of Pu are:
                  10pct    5pct    1pct
critical values 41.2488 48.8439 65.1714


NIKKEIclose(説明変数)とGBP(応答変数)との線形回帰残差のダービン=ワトソン検定 H0:自己相関無し
        Durbin-Watson test

data:  lm(AllData02[, c(nnn, 2)])
DW = 0.3148, p-value < 2.2e-16
alternative hypothesis: true autocorrelation is greater than 0




NIKKEIclose(説明変数)とEUR(応答変数)との共和分検定 H0:共和分関係なし(誤差項は非定常)
######################################## 
# Phillips and Ouliaris Unit Root Test # 
######################################## 

Test of type Pu 
detrending of series with constant and linear trend 


Call:
lm(formula = z[, 1] ~ z[, -1] + trd)

Residuals:
     Min       1Q   Median       3Q      Max 
-1.23808 -0.14412  0.04377  0.29381  0.98654 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)  1.126e+02  5.787e+00  19.453  < 2e-16 ***
z[, -1]      1.719e-03  3.824e-04   4.495 3.10e-05 ***
trd         -4.135e-02  4.415e-03  -9.366 1.76e-13 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.5074 on 62 degrees of freedom
Multiple R-squared:  0.5977,    Adjusted R-squared:  0.5848 
F-statistic: 46.06 on 2 and 62 DF,  p-value: 5.492e-13


Value of test-statistic is: 30.6944 

Critical values of Pu are:
                  10pct    5pct    1pct
critical values 41.2488 48.8439 65.1714


NIKKEIclose(説明変数)とEUR(応答変数)との線形回帰残差のダービン=ワトソン検定 H0:自己相関無し
        Durbin-Watson test

data:  lm(AllData02[, c(nnn, 2)])
DW = 0.3304, p-value < 2.2e-16
alternative hypothesis: true autocorrelation is greater than 0




NIKKEIclose(説明変数)とAUD(応答変数)との共和分検定 H0:共和分関係なし(誤差項は非定常)
######################################## 
# Phillips and Ouliaris Unit Root Test # 
######################################## 

Test of type Pu 
detrending of series with constant and linear trend 


Call:
lm(formula = z[, 1] ~ z[, -1] + trd)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.94171 -0.57250 -0.04653  0.39366  1.52078 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) 5.519e+01  7.305e+00   7.555 2.34e-10 ***
z[, -1]     2.631e-03  4.827e-04   5.451 9.22e-07 ***
trd         1.068e-02  5.574e-03   1.917   0.0599 .  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.6406 on 62 degrees of freedom
Multiple R-squared:  0.5676,    Adjusted R-squared:  0.5536 
F-statistic: 40.69 on 2 and 62 DF,  p-value: 5.175e-12


Value of test-statistic is: 11.4849 

Critical values of Pu are:
                  10pct    5pct    1pct
critical values 41.2488 48.8439 65.1714


NIKKEIclose(説明変数)とAUD(応答変数)との線形回帰残差のダービン=ワトソン検定 H0:自己相関無し
        Durbin-Watson test

data:  lm(AllData02[, c(nnn, 2)])
DW = 0.3298, p-value < 2.2e-16
alternative hypothesis: true autocorrelation is greater than 0




NIKKEIclose(説明変数)とNZD(応答変数)との共和分検定 H0:共和分関係なし(誤差項は非定常)
######################################## 
# Phillips and Ouliaris Unit Root Test # 
######################################## 

Test of type Pu 
detrending of series with constant and linear trend 


Call:
lm(formula = z[, 1] ~ z[, -1] + trd)

Residuals:
     Min       1Q   Median       3Q      Max 
-1.45896 -0.41343 -0.04314  0.43731  1.48558 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept) 58.3230950  7.0915227   8.224 1.62e-11 ***
z[, -1]      0.0020337  0.0004686   4.340 5.35e-05 ***
trd         -0.0530341  0.0054108  -9.802 3.22e-14 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.6218 on 62 degrees of freedom
Multiple R-squared:  0.6248,    Adjusted R-squared:  0.6127 
F-statistic: 51.61 on 2 and 62 DF,  p-value: 6.361e-14


Value of test-statistic is: 13.748 

Critical values of Pu are:
                  10pct    5pct    1pct
critical values 41.2488 48.8439 65.1714


NIKKEIclose(説明変数)とNZD(応答変数)との線形回帰残差のダービン=ワトソン検定 H0:自己相関無し
        Durbin-Watson test

data:  lm(AllData02[, c(nnn, 2)])
DW = 0.1427, p-value < 2.2e-16
alternative hypothesis: true autocorrelation is greater than 0




NIKKEIclose(説明変数)とZAR(応答変数)との共和分検定 H0:共和分関係なし(誤差項は非定常)
######################################## 
# Phillips and Ouliaris Unit Root Test # 
######################################## 

Test of type Pu 
detrending of series with constant and linear trend 


Call:
lm(formula = z[, 1] ~ z[, -1] + trd)

Residuals:
      Min        1Q    Median        3Q       Max 
-0.130242 -0.039462  0.003004  0.047069  0.096965 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) 7.253e+00  6.340e-01  11.440  < 2e-16 ***
z[, -1]     1.455e-04  4.189e-05   3.474  0.00094 ***
trd         3.794e-03  4.838e-04   7.844 7.39e-11 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.05559 on 62 degrees of freedom
Multiple R-squared:  0.7529,    Adjusted R-squared:  0.7449 
F-statistic: 94.44 on 2 and 62 DF,  p-value: < 2.2e-16


Value of test-statistic is: 31.9976 

Critical values of Pu are:
                  10pct    5pct    1pct
critical values 41.2488 48.8439 65.1714


NIKKEIclose(説明変数)とZAR(応答変数)との線形回帰残差のダービン=ワトソン検定 H0:自己相関無し
        Durbin-Watson test

data:  lm(AllData02[, c(nnn, 2)])
DW = 0.3798, p-value < 2.2e-16
alternative hypothesis: true autocorrelation is greater than 0





        date NIKKEIclose    USD    GBP    EUR   AUD   NZD  ZAR
1 2014-06-12    14973.53 102.04 171.38 138.16 95.73 88.16 9.51
2 2014-06-13    15097.84 101.80 172.52 137.97 95.89 88.24 9.53
3 2014-06-14          NA     NA     NA     NA    NA    NA   NA
4 2014-06-15          NA     NA     NA     NA    NA    NA   NA

        date NIKKEIclose    USD    GBP    EUR   AUD   NZD  ZAR
1 2014-06-12    14973.53 102.04 171.38 138.16 95.73 88.16 9.51
2 2014-06-13    15097.84 101.80 172.52 137.97 95.89 88.24 9.53
3 2014-06-16    14933.29 101.98 173.18 138.08 95.71 88.49 9.52
4 2014-06-17    14975.97 101.95 173.07 138.44 95.74 88.40 9.51
 警告メッセージ: 
1: In adf.test(diff(dataset[, ccc]), k = 1) :
  p-value smaller than printed p-value
2: In adf.test(dataset[, ccc], k = 1) :
  p-value greater than printed p-value
3: In adf.test(diff(dataset[, ccc]), k = 1) :
  p-value smaller than printed p-value
4: In adf.test(diff(dataset[, ccc]), k = 1) :
  p-value smaller than printed p-value
5: In adf.test(diff(dataset[, ccc]), k = 1) :
  p-value smaller than printed p-value
6: In adf.test(diff(dataset[, ccc]), k = 1) :
  p-value smaller than printed p-value
7: In adf.test(diff(dataset[, ccc]), k = 1) :
  p-value smaller than printed p-value
8: In adf.test(diff(dataset[, ccc]), k = 1) :
  p-value smaller than printed p-value
> 

#各種条件設定
	FirstDate<-as.Date("2014/6/12")
	LastDate<-as.Date("2014/9/11")
	period<-"days"
	condition01<-0 #個別系列分析 0:行う、1:行わない
	condition02<-0 #系列間分析 0:行う、1:行わない
#パッケージ読込
	library(urca) #ca.po()
	library(tseries)
	library(forecast)
	library(MASS) #truehist()
	library(lmtest) #dwtest
	library(systemfit)
#ファイルパス設定
	username<-Sys.info()['user']
	path01<-paste("C:/Users/",username,"/Desktop/R_Data_Read/",sep="")
	path02<-paste("C:/Users/",username,"/Desktop/R_Graph/",sep="")
	path03<-paste("C:/Users/",username,"/Desktop/R_Data_Write/",sep="")
#分析開始
	if(period=="months"){
		DispFirstDate<-format(FirstDate,"%Y/%b")
		DispLastDate<-format(LastDate,"%Y/%b")
	} else
	if(period=="days"){
		DispFirstDate<-format(FirstDate,"%Y/%b/%d")
		DispLastDate<-format(LastDate,"%Y/%b/%d")
	}
	setwd(path01)
	AllData01<-data.frame(date=seq(FirstDate,LastDate,by=period),dummy=1)
	AllData02<-AllData01
	for(iii in 1:length(dir(path01))){#ファイル単位
		dataset<-read.table(file=dir(path01)[iii],header=TRUE,sep=",")
		#日付列書式の統一
		dataset[,1]<-as.Date(dataset[,1])
		colnames(dataset)[1]<-"date" #小文字
		dataset<-subset(dataset,FirstDate<=dataset[,1])
		dataset<-subset(dataset,LastDate>=dataset[,1])
		for(ccc in 2:ncol(dataset)){#列単位
			#以下は非数値データ行の削除及びデータの実数化。オリジナルデータ書式、分析目的に合わせて適宜追加、変更。
			dataset<-subset(dataset,dataset[,ccc]!=".")
			dataset<-subset(dataset,is.na(dataset[,ccc])==F)
			dataset[,ccc]<-as.double(as.character(dataset[,ccc]))
			if(condition01==0){
				#単位根検定及びARIMA検討
					p0<-adf.test(dataset[,ccc],k=1)$p.value	
					p1<-adf.test(diff(dataset[,ccc]),k=1)$p.value	
				#テキストパート
					cat("\n","\n","ファイル名:",dir(path01)[iii],",列名:",colnames(dataset)[ccc],",対象期間:",DispFirstDate,"-",DispLastDate,"\n",sep="")
					cat("1)単位根検定 H0:単位根が存在する(ランダムウォークである)","\n")
					cat("・原系列,p値=",p0,"\n",sep="")
					cat("・一次階差,p値=",p1,"\n",sep="")
					cat("\n")
					cat("2)Summary","\n")
					cat("・原系列","\n")
					print(summary(dataset[,ccc]))
					cat("・一次階差","\n")
					print(summary(diff(dataset[,ccc])))
					cat("\n")
					cat("3)その他基本統計量","\n")
					cat("・原系列","\n")
					cat("要素数=",length(dataset[,ccc]),",")
					cat("不偏分散=",var(dataset[,ccc]),",")
					cat("標準偏差=",sd(dataset[,ccc]))
					cat("\n")
					cat("・一次階差","\n")
					cat("要素数=",length(diff(dataset[,ccc])),",")
					cat("不偏分散=",var(diff(dataset[,ccc])),",")
					cat("標準偏差=",sd(diff(dataset[,ccc])))
					cat("\n","\n")
					cat("4)ARIMA","\n")
					cat("・原系列")
					Result.arima<-auto.arima(dataset[,ccc],ic="aic",trace=T,stepwise=T)
					print(Result.arima)
					cat("\n")
					cat("5)ARIMA残差の正規性 H0:正規分布からのサンプルである","\n")
					cat("・原系列")
					print(shapiro.test(Result.arima$res))
					cat("6)原系列の一部","\n")
					print(head(dataset,10))
					cat("\n","\n")
				#グラフパート
					ymax<-max(dataset[,ccc])
					ymin<-min(dataset[,ccc])
					ytitle<-colnames(dataset)[ccc]
					setwd(path02)
					png(file=paste(dir(path01)[iii],"_",colnames(dataset)[ccc],".png",sep=""),width=1200,height=800)
					par(mfrow=c(3,4),mar=c(5,5,5,5),ps=22,cex.axis=1,cex.lab=1,cex.main=1,cex.sub=1)
					Date<-dataset[,1]
					#1
					plot(Date,dataset[,ccc],type="l",ylim=c(ymin,ymax),ylab=ytitle,xaxt="n",main=ytitle)
					axis.Date(side=1,at=seq(FirstDate,LastDate,period),format="%Y%m")
					#2
					plot(Date,dataset[,ccc]/ymax*100,type="l",ylim=c(ymin/ymax*100,ymax/ymax*100),
					ylab=paste("Max=100%:",ytitle,sep=""),xaxt="n",main=paste(ytitle,"Normalization"))
					axis.Date(side=1,at=seq(FirstDate,LastDate,period),format="%Y%m")
					#3
					plot(dataset[,ccc],type="l",ylim=c(ymin,ymax),ylab=ytitle,xaxt="n",main="Trend")
					abline(lm(dataset[,ccc]~seq(1,length(dataset[,ccc]))),col=2)
					#4
					plot(diff(dataset[,ccc]),type="h",ylab=paste("1stDifference:",ytitle,sep=""),main="1st Difference")
					#5
					#truehist(diff(dataset[,ccc]),xlab="",main=paste("1stDifference:",ytitle,sep="")) 
					hist(diff(dataset[,ccc]),xlab="",main=paste("1st Difference:",ytitle,sep="")) 
					#6
					qqnorm(diff(dataset[,ccc]),main="1st Diff Normal Q-Q Plot")
					qqline(diff(dataset[,ccc]),col=2)
					#7
					acf(dataset[,ccc],type="correlation",ci=c(0.9,0.95),plot=T,main=colnames(dataset)[ccc],lag=length(floor(dataset[,ccc]/5))) 
					#8
					pacf(dataset[,ccc],ci=c(0.9,0.95),plot=T,main=colnames(dataset)[ccc],lag=length(floor(dataset[,ccc]/5)))
					#9
					plot(forecast(Result.arima,level=c(50,95),h=floor(length(dataset[,ccc])/10)),ylab=ytitle)
					#10
					#構造変化
					StChg<-data.frame(id=seq(1:length(dataset[,ccc])),dummy=0,Pr=0)
					cnt<-0
					for(kkk in 2:length(dataset[,ccc])){#kkkは構造変化時点
					StChg[,2]<-0
					StChg[,2][kkk<=StChg[,1]]<-1
					fm0<-lm(seq(1:length(dataset[,ccc]))~dataset[,ccc])
					fm1<-lm(seq(1:length(dataset[,ccc]))~dataset[,ccc]+StChg[,2]+StChg[,2]*dataset[,ccc])
					StChg[,3][kkk]<-anova(fm0,fm1)$Pr[2]#H0:構造変化なし
					if(0.05<=StChg[,3][kkk] && cnt==0){
					SCDate<-dataset[,1][kkk]
					if(period=="months"){
					SCDate<-format(SCDate,"%Y/%b")
					}else
					if(period=="days"){
					SCDate<-format(SCDate,"%Y%/b/%d")
					}
					cnt<-1
					}
					}
					plot(StChg[,1],StChg[,3],type="h",main=paste("Structure Change ",SCDate,sep=""),xlab="Index",ylab="Pr(>F)")
					#11
					spec.pgram(dataset[,ccc],spans=c(5,5),col=2,main=paste(colnames(dataset)[ccc],"\n","Smoothed Periodogram"))
					#12
					spectrum(dataset[,ccc],method="ar") #method="pgram"
					title(paste("\n",dir(path01)[iii],",",colnames(dataset)[ccc],",","対象期間:",DispFirstDate,"-",DispLastDate,sep=""),outer=T)
					dev.off()
			}
		}
		cat("\n")
		cat("\n")
		cat("\n")
		setwd(path01)
		AllData01<-merge(AllData01,dataset,by="date",all=T,sort=T) #欠損はNAとして処理
		AllData02<-merge(AllData02,dataset,by="date",sort=T) #全系列に数値データが存在する日付のみ
		if(iii==length(dir(path01))){ 
			AllData01<-subset(AllData01,select=-dummy)
			AllData02<-subset(AllData02,select=-dummy)
			if(condition02==0){
				setwd(path02)
				if(3<=ncol(AllData02)){
					for(nnn in 3:ncol(AllData02)){
						#2列目を説明変数、その他列を応答変数として各種検定
						#共和分検定
						cat(colnames(AllData02[2]),"(説明変数)と",colnames(AllData02[nnn]),"(応答変数)との共和分検定 H0:共和分関係なし(誤差項は非定常)",sep="")
						print(summary(ca.po(AllData02[,c(nnn,2)],demean="trend")))
						cat("\n")
						#D.W test
						cat(colnames(AllData02[2]),"(説明変数)と",colnames(AllData02[nnn]),"(応答変数)との線形回帰残差のダービン=ワトソン検定 H0:自己相関無し",sep="")
						print(dwtest(lm(AllData02[,c(nnn,2)]))) 
						cat("\n")
						cat("\n")
						cat("\n")
						#相互相関
						png(file=paste("CCF_",colnames(AllData02[2]),"-",colnames(AllData02[nnn]),".png",sep=""),width=800,height=800)
						par(mfrow=c(1,2),mar=c(5,5,5,5),ps=22,cex.axis=1,cex.lab=1,cex.main=1,cex.sub=1)
						ccf(AllData02[,nnn],AllData02[,2],main=paste("CCF:",colnames(AllData02[2]),"-",colnames(AllData02[nnn])))
						ccf(diff(AllData02[,nnn]),diff(AllData02[,2]),main=paste("CCF:1stDiff ",colnames(AllData02[2]),"-1stDiff ",colnames(AllData02[nnn])))
						dev.off()
					}
				}
			}
			cat("\n")
			print(head(AllData01,4))
			cat("\n")
			print(head(AllData02,4))
			setwd(path03)
			write.table(AllData01,file="AllData01.csv",sep=",",quote=FALSE,row.names=FALSE)
			write.table(AllData02,file="AllData02.csv",sep=",",quote=FALSE,row.names=FALSE)
		}
	}