0

quantregYahooから取得したデータに分位点回帰関数を実装しようとしています。rq()関数がデータを読み取れるように、株式データに対して手順を実行する必要があるようです。これを行う方法がわかりません。rq私の質問は、stocjデータを関数が読み取れる形式に変換する方法です。ありがとう

# Quantile Regression Fit Stock data
# Get Library
library(quantmod)
library(quantreg)

# Get Stock Data
stk1 <- getSymbols("DD",  from="2009-12-31", auto.assign=FALSE)
stk2 <- getSymbols("GE", from="2009-12-31", auto.assign=FALSE)

#median (l1) regression  fit for the stock data.
rq(stk1 ~ stk2.x,.5) 

#the 1st quartile, 
rq(stk1 ~ stk2.x,.25)  

#note that 8 of the 21 points lie exactly on this plane in 4-space! 
#this returns the full rq process
rq(stk1 ~ stk2.x, tau=-1)   

#ordinary sample median --no rank inversion ci
rq(rnorm(50) ~ 1, ci=FALSE)    

#weighted sample median 
rq(rnorm(50) ~ 1, weights=runif(50),ci=FALSE)
4

2 に答える 2

0

グレンジャーとニューボールドが「疑似回帰」と呼んだものの影響を受けやすい価格レベルを後退させているようです。おそらく最初にリターンに変換したいでしょう。quantmod パッケージなどがそれを手助けしてくれます。

于 2010-12-04T15:40:50.583 に答える
0

コードの投稿を間違えました。stk1 と stk2 である必要があります

# Get Library

library(quantmod)
library(quantreg)

# Get Stock Data

stk1 <- getSymbols("DD",  from="2009-12-31", auto.assign=FALSE)
stk2 <- getSymbols("GE",  from="2009-12-31", auto.assign=FALSE)


#median (l1) regression  fit for the stock data.

rq(stk1 ~ stk2.x,.5) 

#the 1st quartile, 

rq(stk1 ~ stk2.x,.25)  

#note that 8 of the 21 points lie exactly on this plane in 4-space! 
#this returns the full rq process

rq(stk1 ~ stk2.x, tau=-1)   

#ordinary sample median --no rank inversion ci

rq(rnorm(50) ~ 1, ci=FALSE)    

#weighted sample median 

rq(rnorm(50) ~ 1, weights=runif(50),ci=FALSE)  
于 2010-12-04T07:16:38.167 に答える