Rパッケージ {performanceAsLeader} を公開しました

  1. 日本の首相および日本銀行総裁毎に経済・金融指標のパフォーマンスを確認するパッケージです。
  2. devtools::install_github("am-consulting/performanceAsLeader")
    library(performanceAsLeader)
    
  3. 日本の首相および日本銀行総裁の就任日、退任日および在任日数が確認できます。
  4. > tail(pmoj)
       inaugural.Date resignation.Date(or incumbency)    Prime Minister of Japan tenure.Days
    72     2007-09-26                      2008-09-23               Yasuo Fukuda    363 days
    73     2008-09-24                      2009-09-15                   Taro Aso    356 days
    74     2009-09-16                      2010-06-07             Yukio Hatoyama    264 days
    75     2010-06-08                      2011-09-01                  Naoto Kan    450 days
    76     2011-09-02                      2012-12-25             Yoshihiko Noda    480 days
    77     2012-12-26                      2016-02-08 Shinzo Abe(2,3)-incumbency   1139 days
    > tail(goboj)
       inaugural.Date resignation.Date(or incumbency)  Governor of Bank of Japan tenure.Days
    26     1989-12-17                      1994-12-16              Yasushi Mieno   1825 days
    27     1994-12-17                      1998-03-19           Yasuo Matsushita   1188 days
    28     1998-03-20                      2003-03-19              Masaru Hayami   1825 days
    29     2003-03-20                      2008-04-08            Toshihiko Fukui   1846 days
    30     2008-04-09                      2013-03-19          Masaaki Shirakawa   1805 days
    31     2013-03-20                      2016-02-08 Haruhiko Kuroda-incumbency   1055 days
    
  5. 2016年02月09日時点ではパッケージから日本国債金利(データ引用元:財務省)、日経平均株価、ドル円為替レートおよび日本銀行資産(前記3系列のデータ引用元:Federal Reserve Bank of St. Louis)の時系列データが取得できます。また独自データ(1列目が日付形式のデータフレーム)を変数 preData に収めることでも利用できます( dataSource にデータ出典を入れてください。例 dataSource<-"日本銀行")
  6. > jgb(1)
    > tail(jgbData)
                Date JapaneseGovernmentBond.1Y
    10704 2016-01-29                    -0.068
    10705 2016-02-01                    -0.141
    10706 2016-02-02                    -0.137
    10707 2016-02-03                    -0.174
    10708 2016-02-04                    -0.175
    10709 2016-02-05                    -0.183
    > jgb(10)
    > tail(jgbData)
                Date JapaneseGovernmentBond.10Y
    10704 2016-01-29                      0.104
    10705 2016-02-01                      0.068
    10706 2016-02-02                      0.085
    10707 2016-02-03                      0.067
    10708 2016-02-04                      0.064
    10709 2016-02-05                      0.036
    > getindex(no = 1)
    > tail(preData)
                Date NIKKEI225
    16605 2016-02-01  17865.23
    16606 2016-02-02  17750.68
    16607 2016-02-03  17191.25
    16608 2016-02-04  17044.99
    16609 2016-02-05  16819.59
    16610 2016-02-08  17004.30
    > getindex(no = 2)
    > tail(preData)
                Date DEXJPUS
    11302 2016-01-22  118.37
    11303 2016-01-25  118.55
    11304 2016-01-26  118.50
    11305 2016-01-27  118.90
    11306 2016-01-28  118.61
    11307 2016-01-29  121.05
    > getindex(no = 3)
    > tail(preData)
              Date JPNASSETS
    209 2015-08-01   3614591
    210 2015-09-01   3661278
    211 2015-10-01   3735537
    212 2015-11-01   3812542
    213 2015-12-01   3831076
    214 2016-01-01   3964498
    
  7. 時系列データ日付毎の日本の首相および日本銀行総裁が確認できます
  8. > valueswithleader(target = 2, dd = 99)
    > tail(dataset)
              Date JPNASSETS    Prime Minister of Japan  Governor of Bank of Japan
    209 2015-08-31   3614591 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    210 2015-09-30   3661278 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    211 2015-10-31   3735537 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    212 2015-11-30   3812542 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    213 2015-12-31   3831076 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    214 2016-01-31   3964498 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    > valueswithleader(target = 2, dd = 999)
    > tail(dataset)
              Date JPNASSETS    Prime Minister of Japan  Governor of Bank of Japan
    209 2015-08-15   3614591 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    210 2015-09-15   3661278 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    211 2015-10-15   3735537 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    212 2015-11-15   3812542 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    213 2015-12-15   3831076 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    214 2016-01-15   3964498 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    > valueswithleader(target = 2)
    > tail(dataset)
              Date JPNASSETS    Prime Minister of Japan  Governor of Bank of Japan
    209 2015-08-01   3614591 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    210 2015-09-01   3661278 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    211 2015-10-01   3735537 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    212 2015-11-01   3812542 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    213 2015-12-01   3831076 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    214 2016-01-01   3964498 Shinzo Abe(2,3)-incumbency Haruhiko Kuroda-incumbency
    
  9. ボックスプロット図を出力します。※先に関数 valueswithleader により dataset を作成してください。
  10. boxplotbyleader()
    

  11. 日本の首相および日本銀行総裁毎の基本統計量を表示します。表中のperformanceは(last/first-1)*100としています。
  12. > performancesummary()
    > tail(pmojSummary)
    Source: local data frame [6 x 10]
    
                        variable      mean    median        sd      max      min     n    first     last performance
                          (fctr)     (dbl)     (dbl)     (dbl)    (dbl)    (dbl) (int)    (dbl)    (dbl)       (dbl)
    1               Yasuo Fukuda 14050.206 13690.190 1389.7744 17458.98 11489.30   243 16435.74 12090.59      -26.44
    2                   Taro Aso  9050.807  8924.430 1045.0077 12115.03  7054.98   239 12115.03 10217.62      -15.66
    3             Yukio Hatoyama 10320.153 10257.560  498.8712 11339.30  9081.52   173 10270.77  9520.80       -7.30
    4                  Naoto Kan  9730.135  9645.445  493.6093 10857.53  8605.15   306  9537.94  9060.80       -5.00
    5             Yoshihiko Noda  8968.470  8841.220  468.4251 10255.15  8160.01   325  8950.74 10080.12       12.62
    6 Shinzo Abe(2,3)-incumbency 16094.627 15457.870 2610.2967 20868.03 10230.36   761 10230.36 17004.30       66.21
    > tail(gobojSummary)
    Source: local data frame [6 x 10]
    
                        variable      mean   median       sd      max      min     n    first     last performance
                          (fctr)     (dbl)    (dbl)    (dbl)    (dbl)    (dbl) (int)    (dbl)    (dbl)       (dbl)
    1              Yasushi Mieno 22313.976 20642.93 5107.473 38915.87 14309.41  1231 38586.18 19163.43      -50.34
    2           Yasuo Matsushita 18785.052 18614.26 2021.987 22666.80 14485.41   801 19270.85 16679.02      -13.45
    3              Masaru Hayami 13975.409 14152.95 3280.555 20833.21  7862.43  1231 16830.47  8051.04      -52.16
    4            Toshihiko Fukui 13406.892 12645.65 2890.915 18261.98  7607.88  1242  8195.05 13250.43       61.69
    5          Masaaki Shirakawa  9885.947  9608.94 1430.543 14489.44  7054.98  1211 13111.89 12468.23       -4.91
    6 Haruhiko Kuroda-incumbency 16463.569 15661.87 2320.733 20868.03 12003.43   707 12635.69 17004.30       34.57
    >