【STAM】インデックスファンド Part5【eMAXIS】
ドルコストはやはり有効だったようだ。
年率期待リターン5%、年率ボラティリティ20%、無リスク金利0%という仮定で
30年間ドルコストした場合のシャープレシオ
> (mean(TotalAssetNormaled)-1)/sd(TotalAssetNormaled)
[1] 0.6677887
30年間買い持ちした場合のシャープレシオ
> (mean(SecurityValue[Years,])-1)/sd(SecurityValue[Years,])
[1] 0.559831
***ここからRのプログラム***
Years=30
Frequency=1000000
ReturnByYear=.05
Volatility=.20
RandomNumbers<-array(rnorm(Years*Frequency,ReturnByYear,Volatility),c(Years,Frequency))
SecurityValue<-matrix(0,Years,Frequency)
SecurityValue[1,] = 1+RandomNumbers[1,]
for(i in 2:Years){
SecurityValue[i,] = (1+RandomNumbers[i,])*(SecurityValue[i-1,])
}
# write.csv(RandomNumbers,"RandomNumbers.csv")
# write.csv(SecurityValue,"SecurityValue.csv")
GottenSecurity<-matrix(1,1,Frequency)
GottenSecurity<-rbind(GottenSecurity,1/head(SecurityValue,Years-1))
# write.csv(GottenSecurity,"GottenSecurity.csv")
GottenSecuritySum=apply(GottenSecurity,2,sum)
# write.csv(GottenSecuritySum,"GottenSecuritySum.csv")
TotalAsset = SecurityValue[Years,]*GottenSecuritySum
# write.csv(TotalAsset,"TotalAsset.csv")
TotalAssetNormaled = TotalAsset/Years
# write.csv(TotalAssetNormaled,"TotalAssetNormaled.csv")
(mean(TotalAssetNormaled)-1)/sd(TotalAssetNormaled)
(mean(SecurityValue[Years,])-1)/sd(SecurityValue[Years,])
***ここまでRのプログラム***