Integrated R Laboratory
Integrated R Laboratory
Laboratory standard
Every result should expose five objects:
- target: what will be known, and at which horizon;
- information set: what is available when the forecast is issued;
- transformation: units and matrix operation;
- recursion or estimator: the exact equation implemented;
- evaluation: benchmark and decision-aligned loss.
The two labs below use simulated data so that the true mechanism and information boundary are visible. Replace the simulation only after the audit trail works.
Lab A — financial tail risk without look-ahead
Question
Does a dynamic variance forecast improve one-day risk measurement relative to a variance fixed in the training sample?
The exponentially weighted recursion
uses only returns observed before . It is not a full GARCH estimate, but it makes the timing transparent.
Finance mini-case: dynamic versus constant one-day risk
Interpretation
A good conclusion is:
The dynamic forecast has lower QLIKE in this fixed test sample and adapts its quantile to recent squared returns. Coverage is reported overall and by subperiod; neither result establishes adequacy for another asset or a regulatory decision.
A weak conclusion is “EWMA works.” The experiment supports only a model, horizon, loss, and simulated regime.
Extension
Replace the EWMA recursion with the GARCH estimate from Module 4. Estimate parameters using observations through the training endpoint, freeze them, and update only the variance state during evaluation. Then compare Normal and Student- quantiles without choosing between them on the final test sample.
Lab B — revised macro data and an impossible forecast
Question
How much apparent accuracy can arise from using a later revision that was unavailable at the forecast origin?
Suppose a first release is noisy and the final revised estimate is more precise. At origin , the forecaster observes the first release for period , not its final value.
Economics mini-case: real-time versus revised-data leakage
The leaky forecast will often look better because it observes a more precise value for the current latent state. That is exactly why it is invalid. A feasible forecast must be reconstructed from a vintage panel, not from the final column of a modern download.
Matrix and timing audit
For either lab, annotate code with:
| Check | Evidence |
|---|---|
| dimensions | rows of equal target observations; covariance matrices are square |
| dating | every predictor date precedes or equals its forecast origin |
| state recursion | the forecast at uses data no later than when required |
| numerical identity | symmetry, factorisation, or normal-equation error is near zero |
| test integrity | no model choice uses final test losses |
| interpretation | conclusion names horizon, loss, and population limits |
Submission exercise
Choose one lab and make one predeclared change:
- Finance: compare two fixed values using a validation window, then evaluate the selected value once on a separate test window.
- Economics: increase the revision delay from three to six periods and rebuild the vintage information set.
Submit the changed equation, code diff, result table, and a 150-word conclusion. A correct null or disappointing result earns the same evidential credit as improvement when the design is honest.
Forecast Evaluation for Decisions
Design honest pseudo-out-of-sample tests for point, density, and tail forecasts with long-run covariance and real-time information.
Capstones, Data, and Reading Ladder
Finance and economics capstone routes, reproducibility requirements, authoritative data sources, and foundational-to-recent literature.