You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/case_studies/ssm_hurricane_tracking.ipynb
+19-19Lines changed: 19 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@
18
18
"cell_type": "markdown",
19
19
"metadata": {},
20
20
"source": [
21
-
"# Introduction\n",
21
+
"## Introduction\n",
22
22
"In this case study we are going to forecast the paths of hurricanes by applying several State Space Models (SSM). We will begin with a simple two-dimensional constant acceleration tracking model, where we only have one parameter to estimate. Subsequently, we will progressively add complexity and parameters as we develop up our model. \n",
23
23
"\n",
24
24
"As a brief introduction to SSMs, the general idea is that we define our system using two equations.<br> \n",
@@ -79,7 +79,7 @@
79
79
"cell_type": "markdown",
80
80
"metadata": {},
81
81
"source": [
82
-
"# Imports"
82
+
"## Imports"
83
83
]
84
84
},
85
85
{
@@ -137,7 +137,7 @@
137
137
"cell_type": "markdown",
138
138
"metadata": {},
139
139
"source": [
140
-
"# Helper Functions"
140
+
"## Helper Functions"
141
141
]
142
142
},
143
143
{
@@ -484,7 +484,7 @@
484
484
"cell_type": "markdown",
485
485
"metadata": {},
486
486
"source": [
487
-
"# Load and Process the Dataset\n",
487
+
"## Load and Process the Dataset\n",
488
488
"The data comes from the National Oceanic and Atmospheric Administration (NOAA) and is stored in an odd format (likely to save space). We need to wrangle it before we can proceed."
489
489
]
490
490
},
@@ -700,14 +700,14 @@
700
700
"cell_type": "markdown",
701
701
"metadata": {},
702
702
"source": [
703
-
"# Generate visualizations"
703
+
"## Generate visualizations"
704
704
]
705
705
},
706
706
{
707
707
"cell_type": "markdown",
708
708
"metadata": {},
709
709
"source": [
710
-
"## Hurricane Originations\n",
710
+
"### Hurricane Originations\n",
711
711
"Let's plot the origination points of the hurricanes in our dataset. There are a few different origination definitions when looking at the tropical cyclones within the HURDAT dataset:\n",
712
712
"- A tropical depression when the maximum sustained surface wind is $\\le$ 33.89 knots\n",
713
713
"- A tropical cyclone when the maximum sustained surface wind is $\\gt$ 33.89 knots\n",
@@ -8573,7 +8573,7 @@
8573
8573
"cell_type": "markdown",
8574
8574
"metadata": {},
8575
8575
"source": [
8576
-
"## Hurricane Fiona's Path\n",
8576
+
"### Hurricane Fiona's Path\n",
8577
8577
"From here on out our task is to forecast the trajectory of Hurricane Fiona. Let's plot the path it took. We mark the origination point in blue and the last observed location of Fiona in red. We see that Fiona initially travels westward and curves to the right making its way northward. This trajectory is typical for Hurricanes that originate in the Northern Hemisphere of the Atlantic Ocean."
8578
8578
]
8579
8579
},
@@ -12632,7 +12632,7 @@
12632
12632
"\n",
12633
12633
"Where in this case we assume the same stochastic innovations on the acceleration term in both dimensions. You can derive the rest of the entries in $Q$ by taking the variance or covariance of the Newtonian equations.\n",
12634
12634
"\n",
12635
-
"# Optional Material\n",
12635
+
"### Optional Material\n",
12636
12636
"We can also derive the Newtonian equations of motion from a system of ordinary differntial equations (ODE)s. Here we have a system that consists of:\n",
12637
12637
"\n",
12638
12638
"1. $\\dot{p}(t) = v(t)$\n",
@@ -17150,7 +17150,7 @@
17150
17150
"cell_type": "markdown",
17151
17151
"metadata": {},
17152
17152
"source": [
17153
-
"# Generate 24-hour forecasts with our Newtonian model"
17153
+
"### Generate 24-hour forecasts with our Newtonian model"
"In our dataset we have variables that aren't a part of the Newtonian system process, but may carry information that we can leverage to better track the path of the hurricane. We have two options when introducing these exogenous variables into our model. We can add them in as time invariant or time-varying variables. In our case, we are going to add exogenous variables as time invariant. Our aim then is to model our observations as:\n",
21220
21220
"\n",
21221
21221
"$$\n",
@@ -21856,7 +21856,7 @@
21856
21856
"cell_type": "markdown",
21857
21857
"metadata": {},
21858
21858
"source": [
21859
-
"# Make in-sample forecasts with new exogenous model"
21859
+
"## Make in-sample forecasts with new exogenous model"
21860
21860
]
21861
21861
},
21862
21862
{
@@ -25830,7 +25830,7 @@
25830
25830
"cell_type": "markdown",
25831
25831
"metadata": {},
25832
25832
"source": [
25833
-
"# Generate 24-hour forecasts with our Exogenous SSM"
25833
+
"### Generate 24-hour forecasts with our Exogenous SSM"
25834
25834
]
25835
25835
},
25836
25836
{
@@ -29927,7 +29927,7 @@
29927
29927
"cell_type": "markdown",
29928
29928
"metadata": {},
29929
29929
"source": [
29930
-
"# Add B-Splines\n",
29930
+
"## Add B-Splines\n",
29931
29931
"In the previous section, we tried adding an interaction term between the maximum sustained surface wind speed and the minumum central pressure. However, our estimated parameters were not too far off from zero. In this section we are going to attempt to model the non-linear complexities of the path, particularly in the mid-section, using cubic B-splines.\n",
29932
29932
"\n",
29933
29933
"We first need to define what variables we are going to model as a smooth function. In our case, we are going to model the longitude values as a smooth function of the latitude values and vice versa. \n",
@@ -30652,7 +30652,7 @@
30652
30652
"cell_type": "markdown",
30653
30653
"metadata": {},
30654
30654
"source": [
30655
-
"# Make in-sample forecasts with new spline model"
30655
+
"### Make in-sample forecasts with new spline model"
30656
30656
]
30657
30657
},
30658
30658
{
@@ -38701,7 +38701,7 @@
38701
38701
"cell_type": "markdown",
38702
38702
"metadata": {},
38703
38703
"source": [
38704
-
"# Closing Remarks\n",
38704
+
"## Closing Remarks\n",
38705
38705
"In this case study we looked at how we can track a hurricane in two-dimensional space using a state space representation of Newtonian kinematics. We proceeded to expand on the pure Newtonian model and added exogenous variables that may hold information pertintent to the Hurricane's track. We then expanded our model by modeling our variables as smooth functions using cubic B-splines. \n",
38706
38706
"\n",
38707
38707
"Throughout, the case study we have been evaluating our 24-hour forecasts and our overall mean error is smallest with our first Newtonian model. Below you will find the errors from all three models plotting against one another. It seems that (as expected) the exogenous information we included in the exogenous model was not informative with respect to the hurricances' trajectory. However, it is worth noting that in the period (around 40 through 56) where the hurricane manuevers we obtain less spikes in error in that section with our cubic B-spline model. This implies that the model could benefit from some non-linear specification to handle the angular acceleration. Hopefully, someday the `StateSpace` module in `pymc-extras` may support non-linear state space specifications with either the Extended Kalman Filter or with the Unscented Kalman Filter. Until then you can learn more about how to build your own custom state space models with the `StateSpace` module on the `pymc-extras` official GitHub repository."
@@ -38762,15 +38762,15 @@
38762
38762
"cell_type": "markdown",
38763
38763
"metadata": {},
38764
38764
"source": [
38765
-
"# Authors\n",
38765
+
"## Authors\n",
38766
38766
"* Authored by Jonathan Dekermanjian in April, 2025 "
38767
38767
]
38768
38768
},
38769
38769
{
38770
38770
"cell_type": "markdown",
38771
38771
"metadata": {},
38772
38772
"source": [
38773
-
"# Acknowledgements\n",
38773
+
"## Acknowledgements\n",
38774
38774
"* Chris Fonnesbeck who reviewed and provided valueable feedback that improved the text\n",
38775
38775
"* Jesse Grabowski reviewed and provided valueable feedback that improved the text and content, and suggested additional content that improve the overall quality of the work."
Copy file name to clipboardExpand all lines: examples/case_studies/ssm_hurricane_tracking.myst.md
+19-19Lines changed: 19 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ myst:
24
24
25
25
+++
26
26
27
-
# Introduction
27
+
##Introduction
28
28
In this case study we are going to forecast the paths of hurricanes by applying several State Space Models (SSM). We will begin with a simple two-dimensional constant acceleration tracking model, where we only have one parameter to estimate. Subsequently, we will progressively add complexity and parameters as we develop up our model.
29
29
30
30
As a brief introduction to SSMs, the general idea is that we define our system using two equations.<br>
@@ -82,7 +82,7 @@ We wrote the equation for $P_{t\|t}$ above using Joseph form, which is more nume
82
82
83
83
+++
84
84
85
-
# Imports
85
+
##Imports
86
86
87
87
```{code-cell} ipython3
88
88
# Import libraries
@@ -120,7 +120,7 @@ from pymc_extras.statespace.utils.constants import (
The data comes from the National Oceanic and Atmospheric Administration (NOAA) and is stored in an odd format (likely to save space). We need to wrangle it before we can proceed.
442
442
443
443
```{code-cell} ipython3
@@ -580,11 +580,11 @@ df_clean = (
580
580
df_clean.head()
581
581
```
582
582
583
-
# Generate visualizations
583
+
##Generate visualizations
584
584
585
585
+++
586
586
587
-
## Hurricane Originations
587
+
###Hurricane Originations
588
588
Let's plot the origination points of the hurricanes in our dataset. There are a few different origination definitions when looking at the tropical cyclones within the HURDAT dataset:
589
589
- A tropical depression when the maximum sustained surface wind is $\le$ 33.89 knots
590
590
- A tropical cyclone when the maximum sustained surface wind is $\gt$ 33.89 knots
@@ -630,7 +630,7 @@ fig.update_layout(
630
630
fig
631
631
```
632
632
633
-
## Hurricane Fiona's Path
633
+
###Hurricane Fiona's Path
634
634
From here on out our task is to forecast the trajectory of Hurricane Fiona. Let's plot the path it took. We mark the origination point in blue and the last observed location of Fiona in red. We see that Fiona initially travels westward and curves to the right making its way northward. This trajectory is typical for Hurricanes that originate in the Northern Hemisphere of the Atlantic Ocean.
635
635
636
636
```{code-cell} ipython3
@@ -761,7 +761,7 @@ $$
761
761
762
762
Where in this case we assume the same stochastic innovations on the acceleration term in both dimensions. You can derive the rest of the entries in $Q$ by taking the variance or covariance of the Newtonian equations.
763
763
764
-
# Optional Material
764
+
###Optional Material
765
765
We can also derive the Newtonian equations of motion from a system of ordinary differntial equations (ODE)s. Here we have a system that consists of:
766
766
767
767
1. $\dot{p}(t) = v(t)$
@@ -1007,7 +1007,7 @@ plot_model_evaluations(
1007
1007
).show(width=1000, renderer="svg")
1008
1008
```
1009
1009
1010
-
# Generate 24-hour forecasts with our Newtonian model
1010
+
###Generate 24-hour forecasts with our Newtonian model
In our dataset we have variables that aren't a part of the Newtonian system process, but may carry information that we can leverage to better track the path of the hurricane. We have two options when introducing these exogenous variables into our model. We can add them in as time invariant or time-varying variables. In our case, we are going to add exogenous variables as time invariant. Our aim then is to model our observations as:
1040
1040
1041
1041
$$
@@ -1363,7 +1363,7 @@ az.plot_forest(
1363
1363
);
1364
1364
```
1365
1365
1366
-
# Make in-sample forecasts with new exogenous model
1366
+
##Make in-sample forecasts with new exogenous model
# Generate 24-hour forecasts with our Exogenous SSM
1392
+
###Generate 24-hour forecasts with our Exogenous SSM
1393
1393
1394
1394
+++
1395
1395
@@ -1441,7 +1441,7 @@ plot_model_evaluations(
1441
1441
).show(width=1000, renderer="svg")
1442
1442
```
1443
1443
1444
-
# Add B-Splines
1444
+
##Add B-Splines
1445
1445
In the previous section, we tried adding an interaction term between the maximum sustained surface wind speed and the minumum central pressure. However, our estimated parameters were not too far off from zero. In this section we are going to attempt to model the non-linear complexities of the path, particularly in the mid-section, using cubic B-splines.
1446
1446
1447
1447
We first need to define what variables we are going to model as a smooth function. In our case, we are going to model the longitude values as a smooth function of the latitude values and vice versa.
In this case study we looked at how we can track a hurricane in two-dimensional space using a state space representation of Newtonian kinematics. We proceeded to expand on the pure Newtonian model and added exogenous variables that may hold information pertintent to the Hurricane's track. We then expanded our model by modeling our variables as smooth functions using cubic B-splines.
1894
1894
1895
1895
Throughout, the case study we have been evaluating our 24-hour forecasts and our overall mean error is smallest with our first Newtonian model. Below you will find the errors from all three models plotting against one another. It seems that (as expected) the exogenous information we included in the exogenous model was not informative with respect to the hurricances' trajectory. However, it is worth noting that in the period (around 40 through 56) where the hurricane manuevers we obtain less spikes in error in that section with our cubic B-spline model. This implies that the model could benefit from some non-linear specification to handle the angular acceleration. Hopefully, someday the `StateSpace` module in `pymc-extras` may support non-linear state space specifications with either the Extended Kalman Filter or with the Unscented Kalman Filter. Until then you can learn more about how to build your own custom state space models with the `StateSpace` module on the `pymc-extras` official GitHub repository.
@@ -1930,18 +1930,18 @@ fig.update_layout(
1930
1930
fig.show(renderer="svg")
1931
1931
```
1932
1932
1933
-
# Authors
1933
+
##Authors
1934
1934
* Authored by Jonathan Dekermanjian in April, 2025
1935
1935
1936
1936
+++
1937
1937
1938
-
# Acknowledgements
1938
+
##Acknowledgements
1939
1939
* Chris Fonnesbeck who reviewed and provided valueable feedback that improved the text
1940
1940
* Jesse Grabowski reviewed and provided valueable feedback that improved the text and content, and suggested additional content that improve the overall quality of the work.
0 commit comments