中国株式市場のベータを計算する関数は次のとおりです。
mybeta <- function(company) {
require(quantmod)
setSymbolLookup(CSI300=list(name="000300.ss",src="yahoo"))
getSymbols("CSI300",from="2010-01-01",to="2011-01-01")
setSymbolLookup(SDB=list(name=company,src="yahoo"))
getSymbols("SDB",from="2010-01-01",to="2011-01-01")
csi=as.data.frame(weeklyReturn(CSI300))
sdb=as.data.frame(weeklyReturn(SDB))
cbeta=merge(csi, sdb, by="row.names")
cov(cbeta[2],cbeta[3])/var(cbeta[2])
}
私が入力したとき:
mybeta("600005.ss")
weekly.returns.y
weekly.returns.x 1.105631
1.105631
「weekly.returns.y」と「weekly.returns.x」ではなく、出力からのみが必要です。どうやってやるの?