2018年2月5日月曜日

Calculate a number of the iteration, which records decline for each month from 1950-01 to now.



for(i in seq(1,12,1)){print(length(((SP5[,4]-SP5[,1])/SP5[,1])[seq(i,length(SP5[,4]),12)][((SP5[,4]-SP5[,1])/SP5[,1])[seq(i,length(SP5[,4]),12)] < 0]))}

> for(i in seq(1,12,1)){print(length(((SP5[,4]-SP5[,1])/SP5[,1])[seq(i,length(SP5[,4]),12)][((SP5[,4]-SP5[,1])/SP5[,1])[seq(i,length(SP5[,4]),12)] < 0]))}
[1] 28
[1] 30
[1] 25
[1] 21
[1] 28
[1] 33
[1] 30
[1] 31
[1] 38
[1] 26
[1] 23
[1] 17

January records 28 times decline since 1950. September is the worst to do 38 times, which is more than 50% probability, while December is the best month to invest S&P 500.

0 件のコメント: