1
$\begingroup$

below I have 2 variables x and y. I have reason to believe they move together in percentages rather than absolute terms. ie if one goes up 10 % the other will go up 10%. For this reason, I have taken the logs of both x and y and plotted it. I have then used the accuracy() function from the forecast package to compare the goodness of fits. How should I transform the data to compare them (untransformed data vs transformed)? I have tried exp() on the log transformed data, but the results are still not comparable. Thanks

enter image description here

enter image description here

enter image description here

library(quantmod)
hub = new.env()
tickers = c("QQQ", "SPY")
getSymbols(tickers, auto.assign = T, env = hub)
x = lapply(hub, na.omit)
x = lapply(x, volatility, n = 10, calc = "yang.zhang", mean0 = T)
vols = do.call(merge, x)
vols = na.omit(vols)
vols = vols[,tickers]
s = seq(1, length(index(vols)), 10)
sample = vols[s, ]
$\endgroup$
5
  • 1
    $\begingroup$ Would you please post a link to the data? $\endgroup$ Dec 19, 2018 at 20:23
  • $\begingroup$ sure thing. I add the code that retrieves the data. its good to run, if you have quantmod installed. "sample" is the data set $\endgroup$ Dec 19, 2018 at 22:30
  • $\begingroup$ I only get an "InternetOpenUrl failed" error message. This seems to be explained at forums.yahoo.net/t5/Yahoo-Finance-help/…, suggesting this code hasn't been executable for over a year. How did you succeed in downloading the data? Although the graphics are more than good enough to understand the problem, it would be nice to illustrate any discussions with the same data. $\endgroup$
    – whuber
    Dec 19, 2018 at 22:36
  • $\begingroup$ Hey whuber, that's strange. I have R 3.52 installed on my desktop and macbook, code works great on both. Maybe you have to re-install quantmod? Also is there a way to upload a csv here? $\endgroup$ Dec 19, 2018 at 22:46
  • $\begingroup$ I installed quantmod in order to do this test and I also tried to access the URL (as reported in the error message) from Chrome, with the same problem. There is no way to upload data here, unfortunately. $\endgroup$
    – whuber
    Dec 19, 2018 at 23:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.