@@ -272,7 +272,7 @@ def param_info(self) -> dict[str, dict[str, Any]]:
272
272
273
273
@property
274
274
def state_names (self ):
275
- states = ["data " , "level" ]
275
+ states = ["innovation " , "level" ]
276
276
if self .trend :
277
277
states += ["trend" ]
278
278
if self .seasonal :
@@ -282,7 +282,7 @@ def state_names(self):
282
282
283
283
@property
284
284
def observed_states (self ):
285
- return [self . state_names [ 0 ] ]
285
+ return ["data" ]
286
286
287
287
@property
288
288
def shock_names (self ):
@@ -326,20 +326,15 @@ def make_symbolic_graph(self) -> None:
326
326
self .ssm ["initial_state" , :] = x0
327
327
self .ssm ["initial_state_cov" ] = P0
328
328
329
- # Only the first state is ever observed
330
- Z = np .zeros ((self .k_endog , self .k_states ))
331
- Z [0 , 0 ] = 1
332
- self .ssm ["design" ] = Z
333
-
334
329
# The shape of R can be pre-allocated, then filled with the required parameters
335
330
R = pt .zeros ((self .k_states , self .k_posdef ))
336
331
R = pt .set_subtensor (R [0 , :], 1.0 ) # We will always have y_t = ... + e_t
337
332
338
333
alpha = self .make_and_register_variable ("alpha" , shape = (), dtype = floatX )
339
334
R = pt .set_subtensor (R [1 , 0 ], alpha ) # and l_t = ... + alpha * e_t
340
335
341
- # Data and level component always exists, the base case is y_t = l_{t-1} and l_t = l_{t-1}
342
- T_base = pt .as_tensor_variable (np .array ([[0.0 , 1 .0 ], [0.0 , 1.0 ]]))
336
+ # Shock and level component always exists, the base case is e_t = e_t and l_t = l_{t-1}
337
+ T_base = pt .as_tensor_variable (np .array ([[0.0 , 0 .0 ], [0.0 , 1.0 ]]))
343
338
344
339
if self .trend :
345
340
beta = self .make_and_register_variable ("beta" , shape = (), dtype = floatX )
@@ -349,7 +344,7 @@ def make_symbolic_graph(self) -> None:
349
344
# y_t = l_{t-1} + b_{t-1}
350
345
# l_t = l_{t-1} + b_{t-1}
351
346
# b_t = b_{t-1}
352
- T_base = pt .as_tensor_variable (([0.0 , 1 .0 , 1 .0 ], [0.0 , 1.0 , 1.0 ], [0.0 , 0.0 , 1.0 ]))
347
+ T_base = pt .as_tensor_variable (([0.0 , 0 .0 , 0 .0 ], [0.0 , 1.0 , 1.0 ], [0.0 , 0.0 , 1.0 ]))
353
348
354
349
if self .damped_trend :
355
350
phi = self .make_and_register_variable ("phi" , shape = (), dtype = floatX )
@@ -358,7 +353,7 @@ def make_symbolic_graph(self) -> None:
358
353
# y_t = l_{t-1} + phi * b_{t-1}
359
354
# l_t = l_{t-1} + phi * b_{t-1}
360
355
# b_t = phi * b_{t-1}
361
- T_base = pt .set_subtensor (T_base [:, 2 ], phi )
356
+ T_base = pt .set_subtensor (T_base [1 :, 2 ], phi )
362
357
363
358
T_components = [T_base ]
364
359
@@ -375,10 +370,17 @@ def make_symbolic_graph(self) -> None:
375
370
self .ssm ["selection" ] = R
376
371
377
372
T = pt .linalg .block_diag (* T_components )
378
- if self .seasonal :
379
- T = pt .set_subtensor (T [0 , 2 + int (self .trend ) + 1 ], 1.0 )
380
373
self .ssm ["transition" ] = pt .specify_shape (T , (self .k_states , self .k_states ))
381
374
375
+ Z = np .zeros ((self .k_endog , self .k_states ))
376
+ Z [0 , 0 ] = 1.0 # innovation
377
+ Z [0 , 1 ] = 1.0 # level
378
+ if self .trend :
379
+ Z [0 , 2 ] = 1.0
380
+ if self .seasonal :
381
+ Z [0 , 2 + int (self .trend )] = 1.0
382
+ self .ssm ["design" ] = Z
383
+
382
384
# Set up the state covariance matrix
383
385
state_cov_idx = ("state_cov" ,) + np .diag_indices (self .k_posdef )
384
386
state_cov = self .make_and_register_variable (
0 commit comments