2017-03-19 19 views
0

我正在使用Shapiro-Wilk測試來拒絕Normality的虛假設。R:Shapiro-Wilk測試

我正在使用雅虎的代碼。例如,對於s & P500:

SP500 = get.hist.quote(instrument = '^GSPC', 
     start="2001-01-01", end = "2015-12-31", 
     quote = c("AdjClose"),provider = "yahoo", 
     compress = "d") 
rSP500 = diff(log(SP500) 

我得到一個錯誤,當我嘗試運行夏皮羅 - 威爾克測試。

例如,

> SWTestSP500 = shapiro.test(rSP500[(3000-499):3000]) 
Error in if (rng == 0) stop("all 'x' values are identical") : 
    argument is of length zero 

我在網上是它有沒有被數字輸入的事,但我相當肯定,rSP500都是數字的唯一搜索。

有人可以提醒嗎?謝謝!

回答

0

的R文件上閱讀了許多次後,我試圖

SWTestSP500 = shapiro.test(as.vector(rSP500 [(3000-499):3000]))

它終於奏效了。原來,shapiro.test()嚴格接受載體。