Unit 13, lesson 98

Financial prediction and feature construction

How a prediction target, its label horizon and admissible features with known availability are defined relative to an information set, and why the conditional mean predictor is optimal for squared-error prediction.

  • Video 98
  • Data, prediction and learning

Suppose a volatility regime is observed before each trading period, and the question is whether it helps forecast the return of that period. The answer depends on what exactly is forecast, over which horizon, with which information and under which loss, so all four have to be fixed before any model is fitted. This lesson defines the prediction target, its label horizon and the admissible features available at the decision time, proves that the conditional mean is the best predictor under squared error, and measures in a constructed two-regime model how much an observable regime lowers the error.

Key terms

Prediction target

Definition Fix a decision time tt, a horizon h>0h > 0 and the physical measure P\mathbb{P}, since the question concerns the distribution of future observations. A prediction target is a real random variable YY whose value is determined by the information available at time t+ht + h, so YY is Ft+h\mathcal{F}_{t+h}-measurable, while in general it is not Ft\mathcal{F}_t-measurable. Defining it means stating the quantity, such as a simple or log return, an excess return, a sign or an event indicator, together with its units, the start and end of its interval and the treatment of cash flows. Squared-error prediction also assumes EP[Y2]<∞\mathbb{E}_{\mathbb{P}}[Y^2] < \infty. Different targets built from the same return have different best predictors.

In plain words The target is the number the forecast will be scored against once it is known. Predicting the size of a return, predicting its sign and choosing a position are three different tasks, and writing the target down says which one is being attempted.

Example In a constructed model the return YY of one period is 0.040.04 or −0.02-0.02, in decimal units. With the target YY itself, a forecast is a return. With the sign target 1{Y>0}\mathbf{1}_{\{Y > 0\}}, the best squared-error forecast is the conditional probability of an up move, which in the high regime of the later cards is 0.60.6, while the best return forecast there is 0.0160.016. Both come from the same distribution, but they answer different questions and cannot be compared with each other.

Label horizon

Definition The label horizon hh is the length of the interval (t,t+h](t, t + h] over which the target of the row dated tt is measured. For a self-financing position with value Wt>0W_t > 0, the horizon-hh total return label is

Yt,h=Wt+hWt−1.Y_{t,h} = \frac{W_{t+h}}{W_t} - 1 .

It becomes known only at t+ht + h, so a model fitted at time ss can train only on rows with t+h≤st + h \le s. When rows are dated at a spacing Δ<h\Delta < h, the labels of two rows kΔk\Delta apart with kΔ<hk\Delta < h share the interval (t+kΔ,t+h](t + k\Delta, t + h] and are in general dependent. If daily log returns are independent and identically distributed with finite positive variance, the hh-day log return labels of rows kk days apart, with 0≤k≤h0 \le k \le h, have correlation

ρk=h−kh,\rho_k = \frac{h - k}{h},

because the two sums share exactly h−kh - k daily terms, and labels at least hh days apart are uncorrelated.

In plain words Each label looks into the future by exactly its horizon. Rows dated more often than the horizon have overlapping labels, so neighboring rows partly repeat the same outcomes. Squared loss is still defined row by row, but the rows are not independent observations, and validation and standard errors have to allow for that.

Example Five-day log return labels on daily rows share four of their five days with the next row. With independent and identically distributed daily log returns their correlation is 4/5=0.84/5 = 0.8 one day apart, 1/5=0.21/5 = 0.2 four days apart and 00 from five days on. A model refitted at the close of day ss may use the label of row tt only if t+5≤st + 5 \le s, so the five most recent rows, those of days s−4s - 4 to ss, have no label yet. The consequences for validation are the subject of Time series validation and overlapping labels.

Admissible feature

Definition A feature for a forecast made at time tt is a random vector XtX_t, and it is admissible when σ(Xt)⊆Ft\sigma(X_t) \subseteq \mathcal{F}_t, that is, when it is Ft\mathcal{F}_t-measurable. The standard construction is

Xt=ϕ(Ot),X_t = \phi(O_t),

where OtO_t collects the observations available by tt, the as-of view of Point in time financial data and sampling, and ϕ\phi is a Borel function chosen without data from after tt. If Ft=σ(Ot)\mathcal{F}_t = \sigma(O_t), the Doob-Dynkin lemma shows that every admissible real feature has this form. In the same way, the random variables measurable with respect to σ(Xt)\sigma(X_t) are exactly the functions g(Xt)g(X_t) with gg Borel, so these are the forecasts that use only the features. A feature vector can discard information. With G=σ(Xt)⊆Ft\mathcal{G} = \sigma(X_t) \subseteq \mathcal{F}_t, the best squared-error forecast based on the features is E[Y∣Xt]\mathbb{E}[Y \mid X_t], and its error is at least that of E[Y∣Ft]\mathbb{E}[Y \mid \mathcal{F}_t], as the squared-error card shows. A rule allowed to use YY itself would have zero error, which is why a feature that reaches past tt can make a backtest look better than any admissible rule.

In plain words A feature is a summary of the past, computed by a rule that could have been run at the decision time. A past return, a trailing volatility or a ratio of accounting figures already published all qualify. A good feature keeps the parts of the information that move the forecast.

Example On daily data, the trailing 2020-day volatility computed from the returns of days t−19t - 19 to tt is admissible at the close of day tt, provided those returns are known by then. The same statistic computed over days t−18t - 18 to t+1t + 1 is not, because it uses the return of day t+1t + 1. In the two-regime model of the later cards, the regime label is an admissible feature only if the regime is known before the return period starts.

Feature availability

Definition The availability time of a feature value is the latest availability time among everything it uses. That includes the raw observations, their revisions and the data used to fit any parameter of ϕ\phi, such as a mean, a scale, a rank, a regression coefficient or the membership of a universe. The feature is available at tt when that time is at most tt, and a feature available at tt is admissible there. A fitted step is fitted on the data available for fitting and then applied, with those parameters, to later rows. Standardizing with the mean xˉ\bar{x} and the sample standard deviation sxs_x of a full sample x1,…,xTx_1, \dots, x_T,

zt=xt−xˉsx,z_t = \frac{x_t - \bar{x}}{s_x},

gives every row the availability time of the last observation xTx_T.

In plain words A feature is only as early as its latest ingredient. Publication lags of the inputs count, and so does every statistic computed from data, including the normalization step that is easy to forget.

Example Take the constructed series 1,2,3,4,5,151, 2, 3, 4, 5, 15. With the mean 22 and sample standard deviation 11 of the first three values, the standardized third value is (3−2)/1=1(3 - 2)/1 = 1. With the full-sample mean 55 and sample standard deviation 26≈5.0990\sqrt{26} \approx 5.0990, it is (3−5)/5.0990≈−0.392(3 - 5)/5.0990 \approx -0.392, and if the last value were 66 instead of 1515 it would be about −0.267-0.267. The third row’s feature changes with the sixth observation, so the full-sample version was not available at the third date.

Conditional mean predictor

Definition Suppose EP[∣Y∣]<∞\mathbb{E}_{\mathbb{P}}[\lvert Y \rvert] < \infty. The conditional mean predictor is

mt=EP[Y∣Ft],m_t = \mathbb{E}_{\mathbb{P}}[Y \mid \mathcal{F}_t],

the integrable Ft\mathcal{F}_t-measurable random variable with E[mt1A]=E[Y1A]\mathbb{E}[m_t \mathbf{1}_A] = \mathbb{E}[Y \mathbf{1}_A] for every A∈FtA \in \mathcal{F}_t. It exists and is unique up to events of probability zero. When Ft\mathcal{F}_t is generated by a finite partition into cells A1,…,AkA_1, \dots, A_k with P(Ai)>0\mathbb{P}(A_i) > 0, it is the cell average

mt=∑i=1kE[Y1Ai]P(Ai) 1Ai.m_t = \sum_{i=1}^{k} \frac{\mathbb{E}[Y \mathbf{1}_{A_i}]}{\mathbb{P}(A_i)}\, \mathbf{1}_{A_i} .

The expectation is taken under the physical measure. A conditional expectation under a pricing measure Q\mathbb{Q} uses pricing weights and is not a return forecast under P\mathbb{P}, even though the notation looks almost the same. The properties of conditional expectation used here are those of Expectation conditional expectation and variance.

In plain words Group the possible futures by what can be seen now, and average the target over the group that has actually occurred. The forecast moves when the observed information changes the probabilities of the outcomes, even if the possible outcomes stay the same.

Example In a constructed model each period starts in a high regime HH or a low regime LL, each with probability 0.50.5, and the regime is observed before the return. The return is 0.040.04 or −0.02-0.02, and the up move has probability 0.60.6 in HH and 0.20.2 in LL. In HH the two contributions are 0.6⋅0.04=0.0240.6 \cdot 0.04 = 0.024 and 0.4⋅(−0.02)=−0.0080.4 \cdot (-0.02) = -0.008, so mH=0.016m_H = 0.016. In LL they are 0.0080.008 and −0.016-0.016, so mL=−0.008m_L = -0.008. Without the regime the best constant is E[Y]=0.5⋅0.016+0.5⋅(−0.008)=0.004\mathbb{E}[Y] = 0.5 \cdot 0.016 + 0.5 \cdot (-0.008) = 0.004.

Squared-error prediction

Definition Squared-error prediction scores a forecast aa of YY by the loss (Y−a)2(Y - a)^2, and a forecasting rule by its population risk EP[(Y−at)2]\mathbb{E}_{\mathbb{P}}[(Y - a_t)^2]. Suppose E[Y2]<∞\mathbb{E}[Y^2] < \infty, and let ata_t be any Ft\mathcal{F}_t-measurable predictor with E[at2]<∞\mathbb{E}[a_t^2] < \infty. Then

E[(Y−at)2]=E[(Y−mt)2]+E[(mt−at)2].\begin{aligned} &\mathbb{E}\bigl[(Y - a_t)^2\bigr] \\[0.4em] &\quad = \mathbb{E}\bigl[(Y - m_t)^2\bigr] \\[0.4em] &\qquad + \mathbb{E}\bigl[(m_t - a_t)^2\bigr]. \end{aligned}

To prove it, write Y−at=(Y−mt)+(mt−at)Y - a_t = (Y - m_t) + (m_t - a_t) and expand the square. The predictor mtm_t has a finite second moment by the conditional Jensen inequality, so the cross term is integrable by the Cauchy-Schwarz inequality. Because mt−atm_t - a_t is known given Ft\mathcal{F}_t,

E[(Y−mt)(mt−at)∣Ft]=(mt−at)×E[Y−mt∣Ft]=0,\begin{aligned} &\mathbb{E}\bigl[(Y - m_t)(m_t - a_t) \mid \mathcal{F}_t\bigr] \\[0.4em] &= (m_t - a_t) \\[0.4em] &\quad \times \mathbb{E}[Y - m_t \mid \mathcal{F}_t] \\[0.4em] &= 0 , \end{aligned}

and the tower property makes the unconditional cross term zero as well. This says that the residual Y−mtY - m_t is orthogonal to every square-integrable Ft\mathcal{F}_t-measurable variable, which does not require the two to be independent. The last term of the identity is nonnegative and vanishes exactly when at=mta_t = m_t almost surely, so the conditional mean is the unique optimal predictor up to events of probability zero. For a smaller information set G⊆Ft\mathcal{G} \subseteq \mathcal{F}_t, such as the one generated by the features, the identity with at=E[Y∣G]a_t = \mathbb{E}[Y \mid \mathcal{G}] shows that the risk rises by E[(mt−E[Y∣G])2]\mathbb{E}[(m_t - \mathbb{E}[Y \mid \mathcal{G}])^2]. With G\mathcal{G} trivial this is the law of total variance

Var⁡(Y)=E[(Y−mt)2]+Var⁡(mt).\begin{aligned} \operatorname{Var}(Y) &= \mathbb{E}\bigl[(Y - m_t)^2\bigr] \\[0.4em] &\quad + \operatorname{Var}(m_t) . \end{aligned}

The theorem identifies a population target for estimation. It does not say that a model fitted to finite data recovers it, and it says nothing about other losses or about trading decisions.

In plain words Any admissible forecast pays the unavoidable error of the conditional mean plus its squared distance from the conditional mean. Information helps squared-error prediction only through how much it moves the conditional mean. A forecast is still not a position. Whether a positive forecast justifies a trade also depends on risk, costs, financing and position limits, and changing the objective to, say, expected utility changes that decision problem without touching this theorem.

Example In the two-regime model the gap between the two returns is 0.060.06, so the conditional variances are 0.6⋅0.4⋅0.062=0.0008640.6 \cdot 0.4 \cdot 0.06^2 = 0.000864 in HH and 0.2⋅0.8⋅0.062=0.0005760.2 \cdot 0.8 \cdot 0.06^2 = 0.000576 in LL, in squared decimal return units. Forecasting with the observed regime gives the risk 0.000720.00072, the average of the two. The conditional means lie 0.0120.012 above and below 0.0040.004, so Var⁡(mt)=0.0122=0.000144\operatorname{Var}(m_t) = 0.012^2 = 0.000144, and the constant forecast 0.0040.004 has risk 0.00072+0.000144=0.0008640.00072 + 0.000144 = 0.000864, which is Var⁡(Y)\operatorname{Var}(Y). If the regime were revealed only after the return, it would not be in Ft\mathcal{F}_t, the best admissible forecast would be 0.0040.004 with risk 0.0008640.000864, and a backtest that used the late label would report 0.000720.00072, an error that no admissible rule attains.

Check yourself

  1. In a constructed model, regime A has probability 0.30.3 and regime B probability 0.70.7, and the regime is observed before the return. The return is 0.050.05 or −0.03-0.03, and the up move has probability 0.80.8 in A and 0.30.3 in B. Find the conditional means, the best constant forecast, and the squared-error risk of the best forecast with and without the regime.
Show the answer

The conditional means are 0.8⋅0.05+0.2⋅(−0.03)=0.0340.8 \cdot 0.05 + 0.2 \cdot (-0.03) = 0.034 in A and 0.3⋅0.05+0.7⋅(−0.03)=−0.0060.3 \cdot 0.05 + 0.7 \cdot (-0.03) = -0.006 in B. The best constant is E[Y]=0.3⋅0.034+0.7⋅(−0.006)=0.006\mathbb{E}[Y] = 0.3 \cdot 0.034 + 0.7 \cdot (-0.006) = 0.006. The gap between the returns is 0.080.08, so the conditional variances are 0.8⋅0.2⋅0.0064=0.0010240.8 \cdot 0.2 \cdot 0.0064 = 0.001024 and 0.3⋅0.7⋅0.0064=0.0013440.3 \cdot 0.7 \cdot 0.0064 = 0.001344, and the risk with the regime is

0.3⋅0.001024+0.7⋅0.001344=0.001248.\begin{aligned} &0.3 \cdot 0.001024 \\[0.4em] &\quad + 0.7 \cdot 0.001344 \\[0.4em] &= 0.001248 . \end{aligned}

The conditional means differ from 0.0060.006 by 0.0280.028 and −0.012-0.012, so Var⁡(mt)=0.3⋅0.0282+0.7⋅0.0122=0.000336\operatorname{Var}(m_t) = 0.3 \cdot 0.028^2 + 0.7 \cdot 0.012^2 = 0.000336. The risk without the regime is 0.001248+0.000336=0.0015840.001248 + 0.000336 = 0.001584. As a check, the up move has overall probability 0.450.45, and Var⁡(Y)=0.45⋅0.55⋅0.0064=0.001584\operatorname{Var}(Y) = 0.45 \cdot 0.55 \cdot 0.0064 = 0.001584.

  1. Two equally likely regimes are observed before the return. In the first the return is 0.040.04 or −0.02-0.02 with probability 0.50.5 each, and in the second it is 0.070.07 or −0.05-0.05 with probability 0.50.5 each. Does observing the regime lower the squared-error risk of the best forecast? Is the regime uninformative?
Show the answer

Both conditional means equal 0.010.01, so the conditional mean predictor is the constant 0.01=E[Y]0.01 = \mathbb{E}[Y] and Var⁡(mt)=0\operatorname{Var}(m_t) = 0. The risk is the same with or without the regime, the average conditional variance 0.5⋅0.0009+0.5⋅0.0036=0.002250.5 \cdot 0.0009 + 0.5 \cdot 0.0036 = 0.00225, which equals Var⁡(Y)\operatorname{Var}(Y). Observing the regime does not lower squared-error risk, because it does not move the conditional mean. It is still informative, since the conditional standard deviation is 0.030.03 in the first regime and 0.060.06 in the second. That matters for a target such as the squared return, for a risk forecast or for sizing a position, which are different questions from the point forecast of the return.

  1. Daily rows carry five-day log return labels, and daily log returns are independent and identically distributed with variance s2s^2. A researcher estimates the mean label from 250250 consecutive rows and reports the standard error as if the rows were independent. Find the correlation of labels one day and three days apart, and the factor by which the independent-rows formula understates the variance of the sample mean.
Show the answer

Labels one day apart share four daily returns and labels three days apart share two, so the correlations are 4/5=0.84/5 = 0.8 and 2/5=0.42/5 = 0.4. The 250250 labels cover 254254 days. The sum of the labels is ∑jcjεj\sum_j c_j \varepsilon_j, where εj\varepsilon_j is the log return of day jj and cjc_j counts the labels that contain day jj. That count is 55 for the 246246 interior days and 1,2,3,41, 2, 3, 4 at each end, so

∑jcj2=246⋅25+2⋅30=6210.\begin{aligned} \sum_j c_j^2 &= 246 \cdot 25 + 2 \cdot 30 \\[0.4em] &= 6210 . \end{aligned}

The variance of the sample mean is 6210 s2/25026210\, s^2/250^2. The independent-rows formula gives Var⁡(Y)/250=5s2/250=1250 s2/2502\operatorname{Var}(Y)/250 = 5 s^2/250 = 1250\, s^2/250^2. The ratio is 6210/1250=4.9686210/1250 = 4.968, so the true standard error is about 4.968≈2.23\sqrt{4.968} \approx 2.23 times the reported one, and the 250250 overlapping labels carry about as much information about the mean as 5050 labels that do not overlap.

How this lesson connects