Rafael Martínez - 5 months ago 43

R Question

I am trying to figure out which distribution fits best logarithmic stock returns. Here is my code:

`library(TTR)`

sign="^GSPC"

start=19900101

end=20160101

x <- getYahooData(sign, start = start, end = end, freq = "daily")

x$logret <- log(x$Close) - lag(log(x$Close))

x=x[,6]

I want to use the function

`descdist(x, discrete = FALSE)`

`Error in descdist(x, discrete = FALSE) : data must be a numeric vector`

The output from

`dput(head(x))`

`structure(c(NA, -0.00258888580664607, -0.00865029791190164, -0.00980414107803274,`

0.00450431207515223, -0.011856706127011), class = c("xts", "zoo"

), .indexCLASS = "Date", .indexTZ = "UTC", tclass = "Date", tzone = "UTC", index = structure(c(631238400,

631324800, 631411200, 631497600, 631756800, 631843200), tzone = "UTC", tclass = "Date"), .Dim = c(6L,

1L), .Dimnames = list(NULL, "logret"))

Answer

Pre-process `x`

using `as.numeric(na.omit(x))`

, or simply run

```
descdist(as.numeric(na.omit(x)), discrete = FALSE)
```