What function to use to calculate a vector of variance ratios
Show older comments
I have a vector of stock returns (or prices, whichever is needed), and need to calculate the variance ratio over time. Each of the variance ratio functions that I found only returned one number, the variance ratio test number. I need a vector of variance ratios for the entire time period. Is there a function that would allow me to do this?
Answers (1)
You can use the 'vratiotest' function that you've mentioned to get the variance ratios across a vector. Normally the 'vratiotest' returns only the variance test rejection decision, but it has multiple arguments including a vector of variance ratios. Here's the documentation for it and some sample code:
load Data_GlobalIdx1
dates = datetime(dates,ConvertFrom="datenum");
TT = table2timetable(DataTable,RowTimes=dates);
LTT = varfun(@log,TT(:,2:end));
q = [2 4 8 2 4 8];
iid = logical([1 1 1 0 0 0]);
[StatTbl,ratio] = vratiotest(LTT,Period=q,IID=iid,DataVariable="log_SP")
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!