Skip to content

Commit cb9fe0b

Browse files
authored
Merge pull request #754 from bashtage/fix-exog-forecast-2
DOC: Fix small issues in notebook
2 parents cc9fb9b + 15bb0f5 commit cb9fe0b

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

examples/univariate_forecasting_with_exogenous_variables.ipynb

+10-8
Original file line numberDiff line numberDiff line change
@@ -589,14 +589,14 @@
589589
"metadata": {},
590590
"source": [
591591
"### Conditional Mean uses target alignment\n",
592-
"When modeling the conditional mean in an AR-X, HAR-X, or LS model, the $X$ data is target-aligned. This requires that when modeling the mean of ``y[t]``, the correct values of $X$ must appear in ``x[t]``. Mathematically, the $X$ matrix used when estimating a model should have the structure\n",
592+
"When modeling the conditional mean in an AR-X, HAR-X, or LS model, the $X$ data is target-aligned. This requires that when modeling the mean of ``y[t]``, the correct values of $X$ must appear in ``x[t]``. Mathematically, the $X$ matrix used when estimating a model should have the structure (using the Python indexing convention of a T-element data set having indices 0, 1, ..., T-1):\n",
593593
"\n",
594594
"$$\n",
595595
"\\left[\\begin{array}{c}\n",
596596
"X_{0}\\\\\n",
597597
"X_{1}\\\\\n",
598598
"\\vdots\\\\\n",
599-
"X_{t-1}\n",
599+
"X_{T-1}\n",
600600
"\\end{array}\\right]\n",
601601
"$$\n",
602602
"\n",
@@ -609,22 +609,24 @@
609609
"\n",
610610
"$$\n",
611611
"\\left[\\begin{array}{cccc}\n",
612-
"E\\left[X_{1|0}\\right] & E\\left[X_{2|0}\\right] & \\ldots & E\\left[X_{h|0}\\right]\\\\\n",
613-
"E\\left[X_{2|1}\\right] & E\\left[X_{3|1}\\right] & \\ldots & E\\left[X_{h+1|1}\\right]\\\\\n",
612+
"E\\left[X_{1}|\\mathcal{F}_0\\right] & E\\left[X_{2}|\\mathcal{F}_0\\right] & \\ldots & E\\left[X_{h|\\mathcal{F}_0}\\right]\\\\\n",
613+
"E\\left[X_{2}|\\mathcal{F}_1\\right] & E\\left[X_{3}|\\mathcal{F}_0\\right] & \\ldots & E\\left[X_{h+1}|\\mathcal{F}_1\\right]\\\\\n",
614614
"\\vdots & \\vdots & \\vdots & \\vdots\\\\\n",
615-
"E\\left[X_{T|T-1}\\right] & E\\left[X_{T+1|T-1}\\right] & \\ldots & E\\left[X_{T+h-1|T-1}\\right]\n",
615+
"E\\left[X_{T}|\\mathcal{F}_{T-1}\\right] & E\\left[X_{T+1}|\\mathcal{F}_{T-1}\\right] & \\ldots & E\\left[X_{T+h-1}|\\mathcal{F}_{T-1}\\right]\n",
616616
"\\end{array}\\right]\n",
617617
"$$\n",
618618
"\n",
619+
"where $|\\mathcal{F}_{s}$ is the time-$s$ information set.\n",
620+
"\n",
619621
"If you use the same ``x`` value in the model when forecasting, you will see different values due to this alignment difference. Naively using the same ``x`` values ie equivalent to setting\n",
620622
"\n",
621-
"$$ E\\left[X_{j|j-1}] \\right] = X_{j-1} $$\n",
623+
"$$ E\\left[X_{s}|\\mathcal{F}_{s-1} \\right] = X_{s-1} $$\n",
622624
"\n",
623625
"In general this would not be correct when forecasting, and will always produce forecasts that differ from the conditional mean. In order to recover the conditional mean using the forecast function, it is necessary to ``shift`` the $X$ values by -1, so that once shifted, the ``x`` values will have the relationship\n",
624626
"\n",
625-
"$$ E\\left[X_{j|j-1}] \\right] = X_{j} .$$\n",
627+
"$$ E\\left[X_{s}|\\mathcal{F}_{s-1} \\right] = X_{s} .$$\n",
626628
"\n",
627-
"Here we shift the $X$ data by ``-1`` so ``x[j]`` is treated as being in the information set for ``y[j-1]``. Also note that the final forecast is ``NaN``. Conceptually this must be the case because the value of $X$ at 999 should be ahead of 999 (i.e., at observation 1,000), and we do not have this value. "
629+
"Here we shift the $X$ data by ``-1`` so ``x[s]`` is treated as being in the information set for ``y[s-1]``. Also, note that the final forecast is ``NaN``. Conceptually this must be the case because the value of $X$ at 999 should be ahead of 999 (i.e., at observation 1,000), and we do not have this value. "
628630
]
629631
},
630632
{

0 commit comments

Comments
 (0)