@@ -272,7 +272,7 @@ def param_info(self) -> dict[str, dict[str, Any]]:
272272
273273 @property
274274 def state_names (self ):
275- states = ["data " , "level" ]
275+ states = ["innovation " , "level" ]
276276 if self .trend :
277277 states += ["trend" ]
278278 if self .seasonal :
@@ -282,7 +282,7 @@ def state_names(self):
282282
283283 @property
284284 def observed_states (self ):
285- return [self . state_names [ 0 ] ]
285+ return ["data" ]
286286
287287 @property
288288 def shock_names (self ):
@@ -326,20 +326,15 @@ def make_symbolic_graph(self) -> None:
326326 self .ssm ["initial_state" , :] = x0
327327 self .ssm ["initial_state_cov" ] = P0
328328
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-
334329 # The shape of R can be pre-allocated, then filled with the required parameters
335330 R = pt .zeros ((self .k_states , self .k_posdef ))
336331 R = pt .set_subtensor (R [0 , :], 1.0 ) # We will always have y_t = ... + e_t
337332
338333 alpha = self .make_and_register_variable ("alpha" , shape = (), dtype = floatX )
339334 R = pt .set_subtensor (R [1 , 0 ], alpha ) # and l_t = ... + alpha * e_t
340335
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 ]]))
343338
344339 if self .trend :
345340 beta = self .make_and_register_variable ("beta" , shape = (), dtype = floatX )
@@ -349,7 +344,7 @@ def make_symbolic_graph(self) -> None:
349344 # y_t = l_{t-1} + b_{t-1}
350345 # l_t = l_{t-1} + b_{t-1}
351346 # 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 ]))
353348
354349 if self .damped_trend :
355350 phi = self .make_and_register_variable ("phi" , shape = (), dtype = floatX )
@@ -358,7 +353,7 @@ def make_symbolic_graph(self) -> None:
358353 # y_t = l_{t-1} + phi * b_{t-1}
359354 # l_t = l_{t-1} + phi * b_{t-1}
360355 # 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 )
362357
363358 T_components = [T_base ]
364359
@@ -375,10 +370,17 @@ def make_symbolic_graph(self) -> None:
375370 self .ssm ["selection" ] = R
376371
377372 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 )
380373 self .ssm ["transition" ] = pt .specify_shape (T , (self .k_states , self .k_states ))
381374
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+
382384 # Set up the state covariance matrix
383385 state_cov_idx = ("state_cov" ,) + np .diag_indices (self .k_posdef )
384386 state_cov = self .make_and_register_variable (
0 commit comments