-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep0_SumStats.m
89 lines (85 loc) · 2.65 KB
/
step0_SumStats.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
%% Warning: this code clears the workspace and the command window
% codes developed for the manuscript titled
% "A False Discovery Rate Approach to Optimal Volatility Forecasting Model Selection"
% This script generates the summary statistics as presented in Table 2 of
% the manuscript.
% The summary stats are stored in the table variable named "perf_table" and
% written to file named "SummaryStats.xlsx"
% Script last revised 30 Oct 2022
% @author: Arman Hassanniakalager GitHub: https://github.com/hkalager
% Common disclaimers apply. Subject to change at all time.
clear;clc;
drpadd=pwd;
if ispc()
addpath([drpadd,'\Dataset_ETFS']);
else
addpath([drpadd,'/Dataset_ETFS']);
end
tickerlist={'SPY','QQQ','GLD','USO'};
perf_table=table();
iter=0;
for t=1:numel(tickerlist)
iter=iter+1;
flname=[tickerlist{t},'_M5_processed.csv'];
tbl0=readtable(flname);
perf_table{iter,'Asset'}=tickerlist(t);
ret_ser=tbl0.OCReturn;
%% Basic stats
perf_table{iter,'Observations'}=numel(ret_ser);
perf_table{iter,'MeanX100'}=mean(ret_ser)*100;
perf_table{iter,'MedianX100'}=median(ret_ser)*100;
perf_table{iter,'MaxX100'}=max(ret_ser)*100;
perf_table{iter,'MinX100'}=min(ret_ser)*100;
perf_table{iter,'StdX100'}=std(ret_ser)*100;
perf_table{iter,'Skewness'}=skewness(ret_ser);
perf_table{iter,'Kurtosis'}=kurtosis(ret_ser)-3;
%% Jarque-Bera test
[~,p_val_jb,jbstat]=jbtest(ret_ser);
if p_val_jb<=1e-3
sig='***';
elseif p_val_jb<=1e-2
sig='**';
elseif p_val_jb<=5e-2
sig='**';
else
sig='';
end
perf_table{iter,'JB'}={[num2str(round(jbstat,2)),sig]};
%% Ljung-Box Q test
[~,p_val_q,qstat]=lbqtest(ret_ser);
if p_val_q<=1e-3
sig='***';
elseif p_val_q<=1e-2
sig='**';
elseif p_val_q<=5e-2
sig='**';
else
sig='';
end
perf_table{iter,'Q20'}={[num2str(round(qstat,2)),sig]};
%% ADF test - based on min-AIC
[adfstat,pval_adf]=opt_lag_adf(ret_ser);
if pval_adf<=1e-3
sig='***';
elseif pval_adf<=1e-2
sig='**';
elseif pval_adf<=5e-2
sig='**';
else
sig='';
end
perf_table{iter,'ADF'}={[num2str(round(adfstat,2)),sig]};
%% Phillips-Perron test - based on min-AIC
[ppstat,pval_pp]=opt_lag_pp(ret_ser);
if pval_pp<=1e-3
sig='***';
elseif pval_pp<=1e-2
sig='**';
elseif pval_pp<=5e-2
sig='**';
else
sig='';
end
perf_table{iter,'PP'}={[num2str(round(ppstat,2)),sig]};
end
writetable(perf_table,'SummaryStats.xlsx')