@@ -233,10 +233,9 @@ def __init__(
233
233
self ._fit_coords : dict [str , Sequence [str ]] | None = None
234
234
self ._fit_dims : dict [str , Sequence [str ]] | None = None
235
235
self ._fit_data : pt .TensorVariable | None = None
236
+ self ._fit_exog_data : dict [str , dict ] = {}
236
237
237
238
self ._needs_exog_data = None
238
- self ._exog_names = []
239
- self ._exog_data_info = {}
240
239
self ._name_to_variable = {}
241
240
self ._name_to_data = {}
242
241
@@ -671,7 +670,7 @@ def _save_exogenous_data_info(self):
671
670
pymc_mod = modelcontext (None )
672
671
for data_name in self .data_names :
673
672
data = pymc_mod [data_name ]
674
- self ._exog_data_info [data_name ] = {
673
+ self ._fit_exog_data [data_name ] = {
675
674
"name" : data_name ,
676
675
"value" : data .get_value (),
677
676
"dims" : pymc_mod .named_vars_to_dims .get (data_name , None ),
@@ -685,7 +684,7 @@ def _insert_random_variables(self):
685
684
--------
686
685
.. code:: python
687
686
688
- ss_mod = pmss.BayesianSARIMA (order=(2, 0, 2), verbose=False, stationary_initialization=True)
687
+ ss_mod = pmss.BayesianSARIMAX (order=(2, 0, 2), verbose=False, stationary_initialization=True)
689
688
with pm.Model():
690
689
x0 = pm.Normal('x0', size=ss_mod.k_states)
691
690
ar_params = pm.Normal('ar_params', size=ss_mod.p)
@@ -1082,7 +1081,7 @@ def _kalman_filter_outputs_from_dummy_graph(
1082
1081
1083
1082
for name in self .data_names :
1084
1083
if name not in pm_mod :
1085
- pm .Data (** self ._exog_data_info [name ])
1084
+ pm .Data (** self ._fit_exog_data [name ])
1086
1085
1087
1086
self ._insert_data_variables ()
1088
1087
@@ -1229,7 +1228,7 @@ def _sample_conditional(
1229
1228
method = mvn_method ,
1230
1229
)
1231
1230
1232
- obs_mu = (Z @ mu [..., None ]).squeeze (- 1 )
1231
+ obs_mu = d + (Z @ mu [..., None ]).squeeze (- 1 )
1233
1232
obs_cov = Z @ cov @ pt .swapaxes (Z , - 2 , - 1 ) + H
1234
1233
1235
1234
SequenceMvNormal (
@@ -1351,7 +1350,7 @@ def _sample_unconditional(
1351
1350
self ._insert_random_variables ()
1352
1351
1353
1352
for name in self .data_names :
1354
- pm .Data (** self ._exog_data_info [name ])
1353
+ pm .Data (** self ._fit_exog_data [name ])
1355
1354
1356
1355
self ._insert_data_variables ()
1357
1356
@@ -1651,7 +1650,7 @@ def sample_statespace_matrices(
1651
1650
self ._insert_random_variables ()
1652
1651
1653
1652
for name in self .data_names :
1654
- pm .Data (** self ._exog_data_info [name ])
1653
+ pm .Data (** self .data_info [name ])
1655
1654
1656
1655
self ._insert_data_variables ()
1657
1656
matrices = self .unpack_statespace ()
@@ -1703,7 +1702,7 @@ def sample_filter_outputs(
1703
1702
1704
1703
if self .data_names :
1705
1704
for name in self .data_names :
1706
- pm .Data (** self ._exog_data_info [name ])
1705
+ pm .Data (** self ._fit_exog_data [name ])
1707
1706
1708
1707
self ._insert_data_variables ()
1709
1708
@@ -1846,7 +1845,7 @@ def _validate_scenario_data(
1846
1845
}
1847
1846
1848
1847
if self ._needs_exog_data and scenario is None :
1849
- exog_str = "," .join (self ._exog_names )
1848
+ exog_str = "," .join (self .data_names )
1850
1849
suffix = "s" if len (exog_str ) > 1 else ""
1851
1850
raise ValueError (
1852
1851
f"This model was fit using exogenous data. Forecasting cannot be performed without "
@@ -1855,7 +1854,7 @@ def _validate_scenario_data(
1855
1854
1856
1855
if isinstance (scenario , dict ):
1857
1856
for name , data in scenario .items ():
1858
- if name not in self ._exog_names :
1857
+ if name not in self .data_names :
1859
1858
raise ValueError (
1860
1859
f"Scenario data provided for variable '{ name } ', which is not an exogenous variable "
1861
1860
f"used to fit the model."
@@ -1896,12 +1895,12 @@ def _validate_scenario_data(
1896
1895
# name should only be None on the first non-recursive call. We only arrive to this branch in that case
1897
1896
# if a non-dictionary was passed, which in turn should only happen if only a single exogenous data
1898
1897
# needs to be set.
1899
- if len (self ._exog_names ) > 1 :
1898
+ if len (self .data_names ) > 1 :
1900
1899
raise ValueError (
1901
1900
"Multiple exogenous variables were used to fit the model. Provide a dictionary of "
1902
1901
"scenario data instead."
1903
1902
)
1904
- name = self ._exog_names [0 ]
1903
+ name = self .data_names [0 ]
1905
1904
1906
1905
# Omit dataframe from this basic shape check so we can give more detailed information about missing columns
1907
1906
# in the next check
@@ -2103,7 +2102,7 @@ def _finalize_scenario_initialization(
2103
2102
return scenario
2104
2103
2105
2104
# This was already checked as valid
2106
- name = self ._exog_names [0 ] if name is None else name
2105
+ name = self .data_names [0 ] if name is None else name
2107
2106
2108
2107
# Small tidying up in the case we just have a single scenario that's already a dataframe.
2109
2108
if isinstance (scenario , pd .DataFrame | pd .Series ):
0 commit comments