Reputation: 83
I am using the Shapiro-Wilk Test to reject the null hypothesis of Normality.
I am using code from Yahoo. For example, for 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)
I get an error when I try to run the Shapiro-Wilk Test.
For example,
> SWTestSP500 = shapiro.test(rSP500[(3000-499):3000])
Error in if (rng == 0) stop("all 'x' values are identical") :
argument is of length zero
The only search I got online was that it has to do with the input not being numerical, but I am fairly certain that rSP500 are all numbers.
Can someone advise? Thank you!
Upvotes: 1
Views: 1493
Reputation: 83
After reading up on the R documentation many times, I tried
SWTestSP500 = shapiro.test(as.vector(rSP500[(3000-499):3000]))
And it finally worked. Turns out that shapiro.test() strictly takes in vectors.
Upvotes: 2