2020年6月13日土曜日

EPS 2020JUN13



eps_year_xts["2020::"]
             [,1]
2020-01-01 116.42
2020-04-01 100.84
2020-07-01  93.89
2020-10-01  90.33
2021-01-01 110.84
2021-04-01 125.10
2021-07-01 135.49
2021-10-01 142.90

~$ tac eps.txt 
3/31/2019 2834.40 $37.99 $35.02 18.52 21.09 $153.05 $134.39
6/30/2019 2941.76 $40.14 $34.93 19.04 21.75 $154.54 $135.27
9/30/2019  2976.74 $39.81 $33.99 19.46 22.40 $152.97 $132.90
12/31/2019 3230.78 $39.18 $35.53 20.56 23.16 $157.12 $139.47
3/31/2020 (97.5%) 2584.59 $19.70 $11.98 22.42 26.73 $138.83 $116.43
6/30/2020 $23.08 $19.94 25.56 30.68 $121.77 $101.44
9/30/2020 $31.04 $27.52 27.54 32.77 $113.00 $94.97
12/31/2020 $35.89 $32.62 28.37 33.81 $109.71 $92.06
3/31/2021 $37.02 $33.16 24.50 27.49 $127.03 $113.24
6/30/2021 $38.14 $34.09 21.90 24.43 $142.09 $127.39
9/30/2021 $42.05 $37.98 20.33 22.58 $153.10 $137.85
12/31/2021 $44.59 $40.05 19.24 21.42 $161.80 $145.28

~$   tac eps.txt | awk '{gsub("\\$","",$NF);print "eps_year_xts[\"2019::\"]["NR"] <- "$NF}'

eps_year_xts["2019::"][1] <- 134.39
eps_year_xts["2019::"][2] <- 135.27
eps_year_xts["2019::"][3] <- 132.90
eps_year_xts["2019::"][4] <- 139.47
eps_year_xts["2019::"][5] <- 116.43
eps_year_xts["2019::"][6] <- 101.44
eps_year_xts["2019::"][7] <- 94.97
eps_year_xts["2019::"][8] <- 92.06
eps_year_xts["2019::"][9] <- 113.24
eps_year_xts["2019::"][10] <- 127.39
eps_year_xts["2019::"][11] <- 137.85
eps_year_xts["2019::"][12] <- 145.28

Personal Income and GDP PI



Recalculate based upon the past 20 years except 2020.


summary(lm(last(yearlyReturn(PI),20)[-20] ~ last(yearlyReturn(G),20)[-20]))

Call:
lm(formula = last(yearlyReturn(PI), 20)[-20] ~ last(yearlyReturn(G), 
    20)[-20])

Residuals:
      Min        1Q    Median        3Q       Max 
-0.063473 -0.008838  0.000614  0.013313  0.045431 

Coefficients:
                               Estimate Std. Error t value Pr(>|t|)   
(Intercept)                    0.006467   0.012627   0.512  0.61514   
last(yearlyReturn(G), 20)[-20] 0.878119   0.290504   3.023  0.00767 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.02297 on 17 degrees of freedom
Multiple R-squared:  0.3496, Adjusted R-squared:  0.3113 
F-statistic: 9.137 on 1 and 17 DF,  p-value: 0.007673

  • calculate PI according to the formula above on the assumption that 2020 GDPC1 year return is -5% and CPI is 2%.
0.006467 0.878119 *G["2019-10-01"]*0.97
                GDP
2019-10-01 18508.34


  • when 2020 GDP growth is forecasted as -0.05, to calculate PI growth rate do this.


0.006467 + 0.878119 *(expected GDP growth rate)


  • then 2020 PI forecast is as below


(1 + 0.006467 + 0.878119 *-0.05)*PI["2019-10-01"]
                 PI
2019-10-01 18061.11

plot.default(last(yearlyReturn(G),20)[-20],last(yearlyReturn(PI),20)[-20])
abline(lm(last(yearlyReturn(PI),20)[-20] ~ last(yearlyReturn(G),20)[-20]))
abline(v=0)



Recalculate based upon the past 50 years except 2020.


summary(lm(last(yearlyReturn(PI),50)[-50] ~ last(yearlyReturn(G),50)[-50]))

Call:
lm(formula = last(yearlyReturn(PI), 50)[-50] ~ last(yearlyReturn(G), 
    50)[-50])

Residuals:
      Min        1Q    Median        3Q       Max 
-0.065914 -0.005273  0.000005  0.006657  0.043099 

Coefficients:
                               Estimate Std. Error t value Pr(>|t|)    
(Intercept)                    0.008346   0.005670   1.472    0.148    
last(yearlyReturn(G), 50)[-50] 0.890811   0.080517  11.064 1.11e-14 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.01723 on 47 degrees of freedom
Multiple R-squared:  0.7226, Adjusted R-squared:  0.7167 
F-statistic: 122.4 on 1 and 47 DF,  p-value: 1.11e-14

0.008346+0.890811 *G["2019-10-01"]*0.97
                GDP
2019-10-01 18775.85

0.008346+0.890811 *(expected GDP growth rate)
  • when 2020 is -0.05
0.008346+0.890811 *-0.05
[1] -0.03619455

(1+ 0.008346+0.890811 *-0.05)*PI["2019-12-01"]

      PI
2019-12-01 18222.28

2020年6月2日火曜日

.Last function 終了 終了処理



save image files with timestamp file name like "yyyy-mm-dd-hh-mm-ss-00" and .Rdata.

.Last <- function() {
  # save.image(file=paste(getwd(),Sys.time(),sep="/"))
  #
  # save working image in the parent directory. expected the length of the directory name is fixed.
  # adjust value "len" to fit the length of the result "getwd()".
  #
  op <- options(digits.secs = 2)
  start_pos <- 1
  # len <- 23
  # change to decide based upon strings length.
  last_pos <- nchar(as.character(getwd())) -2
  save.image(file=gsub("[ :.]","-",paste(substr(getwd(),start_pos,last_pos),Sys.time(),sep="/")))
   cat("time stamp file done...\n")
  save.image(file=paste(getwd(),".Rdata",sep="/"))
   cat("RData done...\n")
  #
  # OR store working image at the working directory
  #
  # save.image(file=gsub(" ","-",paste(getwd(),Sys.time(),sep="/")))
  #
  cat("bye bye...\n")
}

2020年6月1日月曜日

EPS 2020JUN01



the entries below are wrong.

> eps_year_xts["2020::"]
             [,1]
2020-01-01 102.44
2020-04-01  96.80
2020-07-01  95.16
2020-10-01 115.77
2021-01-01 130.19
2021-04-01 140.44
2021-07-01 147.68
2021-10-01 150.31

~$ tac eps.txt | awk '{gsub("\\$","",$NF);print "eps_year_xts[\"2019::\"]["NR"] <- "$NF}'
eps_year_xts["2019::"][1] <- 134.39
eps_year_xts["2019::"][2] <- 135.27
eps_year_xts["2019::"][3] <- 132.90
eps_year_xts["2019::"][4] <- 139.47
eps_year_xts["2019::"][5] <- 116.42
eps_year_xts["2019::"][6] <- 100.84
eps_year_xts["2019::"][7] <- 93.89
eps_year_xts["2019::"][8] <- 90.33
eps_year_xts["2019::"][9] <- 110.84
eps_year_xts["2019::"][10] <- 125.10
eps_year_xts["2019::"][11] <- 135.49
eps_year_xts["2019::"][12] <- 142.90