scieee AI-readable full text Open interactive document viewer

Replication package for the study "Time as a Model: Forecasting in Trend-Based Intrinsic Time."

Grobys, Klaus

Full text

README — Replication package for “Time as a Model: Forecasting in Trend-Based Intrinsic Time (TBIT)” Version: 1.0 Language: MATLAB (R2021b or later recommended) Toolboxes: Econometrics Toolbox, Statistics & Machine Learning Toolbox, Parallel Computing Toolbox (optional) 1) Overview This repository contains simulation and bootstrap data matrices and MATLAB scripts used to produce the main and appendix tables in the manuscript. The empirical protocol estimates the same AR(1) in calendar time and in event time (TBIT, ε=0) and evaluates both on the same out-of-sample dates (event endpoints), with equal-N daily benchmarks (random-thin, contiguous block). 2) Data files (MAT) Each file stores T = 2,000 observations per series and R synthetic series (columns). Unless noted, each MAT file contains two T×R matrices:  returns (arithmetic returns in decimals)  prices (simple compounding from 100) A) R = 1,000 (used for Tables 1–4 and A.1, A.2, A.5, A.6)  sim_DGPA_phi0_1000.mat  sim_DGPA_phi01_1000.mat  sim_DGPB_mu002_p01_1000.mat  sim_DGPB_mu002_p02_1000.mat  sim_SP500_bootstrap_L250_1000.mat  sim_BTC_bootstrap_L250_1000.mat B) R = 500 (used for Tables A.3, A.4)  sim_DGPA_phi0.mat  sim_DGPA_phi01.mat  sim_DGPB_mu002_p01.mat  sim_DGPB_mu002_p02.mat Each filename reflects the design:  DGPA: AR(1)–GARCH(1,1) with t-innovations; phi0 (no predictability), phi01 (mild predictability).  DGPB: regime-switching mean with GARCH(1,1); mu002 = 𝜇¯ = 0.002; p01/p02 = flip probability 0.01/0.02.  SP500/BTC_bootstrap_L250: stationary bootstrap of daily arithmetic returns with expected block length 250 trading days; prices by simple compounding from 100. 3) How to reproduce tables from the provided MAT files Main tables (AR(1) on common event dates) Script: AR1_eventdate_compare.m Purpose: Fits AR(1) under each clock; evaluates both on the same event endpoints; produces Fullcalendar, Calendar-thin (equal-N), and Calendar-block (equal-N) results. Minimal call (example): AR1_eventdate_compare('sim_SP500_bootstrap_L250_1000.mat', ... 'SP500_main_70_30', 0.70); % 70% IS / 30% OOS Outputs:  Excel workbook with panels: o Loss Statistics Full-calendar (MSFE ratio, ΔMSFE, Δ log score) o DM (MSFE) and DM (Log score) o Loss Statistics Calendar-thin (equal-N) o Loss Statistics Calendar-block (equal-N) o Effective Sample (distribution of OOS event-endpoint counts and shares) Note: The script restricts calendar forecasts to event endpoints; intervening daily forecasts are not scored, so the loss sample is identical across clocks. Appendix A.3–A.4 (variance calibration diagnostics) Scripts:  analyze_TBIT_vs_calendar_estOnce.m — runs the Monte Carlo/bootstraps and saves results to results_*.mat.  Report_Tables.m — post-processes results_*.mat into human-readable Excel/CSV tables (coverage, SE vs MC-SD, forecast panels if present) and adds the Effective Sample sheet. Typical workflow: % 1) Run analyzer (creates results_*.mat) analyze_TBIT_vs_calendar_estOnce; % 2) Turn MAT results into tables (Excel + CSV fallback) Report_Tables; % looks for the latest results_*.mat in the working folder Outputs (Excel):  Coverage: CI coverage for (ω, α, β) under each clock  SEvsSD_TBIT / SEvsSD_Calendar: median reported SE vs Monte Carlo SD (SE/MC-SD)  (Optional) Forecast, DM_MSFE, DM_LogScore if included by that run  EffectiveSample: percentiles of equal-N lengths and shares of T Note: analyze_TBIT_vs_calendar_estOnce.m does not itself write the Excel; it saves all vectors/scalars to a MAT file (e.g., results_DGPA_phi0_estOnce.mat). Run Report_Tables.m to build and export the Excel (and CSV fallback). 4) How to regenerate the MAT datasets (optional) Data files can be recreated as follows. A) Parametric simulations  DGP A: simulate_DGP_A.m  DGP B: simulate_DGP_B.m Example: % DGP A, phi = 0.10, T = 2000, burn-in = 200, R = 1000 simulate_DGP_A(struct('phi',0.10,'omega',1e-5,'alpha',0.05,'beta',0.93, ... 'nu',8), 2000, 200, 1000, 12345, 'sim_DGPA_phi01.mat'); B) Stationary bootstraps (real data)  BTC: make_BTC_bootstrap.m  S&P 500: make_SP500_bootstrap.m Each script: 1. Loads the original daily arithmetic returns vector (BTC or S&P 500). 2. Applies the stationary bootstrap with expected block length L = 250. 3. Forms prices by compounding from 100. 4. Saves sim_BTC_bootstrap_L250.mat (or SP500 analog) with returns and prices matrices (T×R). 5) Re-running with different settings  IS/OOS split: third argument to AR1_eventdate_compare (e.g., 0.60, 0.80).  Equal-N benchmarks: both Calendar-thin and Calendar-block are built internally (no extra inputs).  Parallelization: several loops support parfor if you have the Parallel Toolbox.  Random seeds: fixed in scripts; change seed inputs if you want different draws. 6) Output locations and filenames  AR1_eventdate_compare.m writes an Excel file with a name derived from the input MAT and the split label (e.g., SP500_main_70_30.xlsx).  analyze_TBIT_vs_calendar_estOnce.m writes results_*.mat.  Report_Tables.m reads the latest results_*.mat in the working directory and writes results_*_Tables.xlsx (plus CSV fallbacks if Excel writing is unavailable). 7) Fairness and scoring note (method) For each replication, both clocks are evaluated on the same OOS dates—the event endpoints. The calendar model’s daily forecasts at non-endpoint dates are ignored to keep the loss sample identical. Point-losses use standardized MSFE (each squared error divided by the model’s in-sample innovation variance); density uses Gaussian log score. 8) Troubleshooting  Excel file not appearing: run Report_Tables.m after the analyzer; confirm write permissions to the working folder.  Variable names differ across MAT files: use whos -file to check, or assign to local variables expected by the scripts (returns, prices).  Complex or extreme SE/MC-SD ratios: arise when true parameters are near boundaries or when event-time QMLE underestimates scale; the tables already guard with medians and omit non-finite ratios. 9) Citation If you use this package, please cite the paper and the Zenodo record:  Klaus Grobys (2025), “Time as a Model: Forecasting in Trend-Based Intrinsic Time.”