Skip to content

Commit 4fc8db2

Browse files
committed
Make code for state cov when no innov clearer
1 parent 505b7d0 commit 4fc8db2

File tree

1 file changed

+5
-0
lines changed
  • pymc_extras/statespace/models/structural/components

1 file changed

+5
-0
lines changed

pymc_extras/statespace/models/structural/components/cycle.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ def make_symbolic_graph(self) -> None:
193193
design_matrix = block_diag(*[Z for _ in range(self.k_endog)])
194194
self.ssm["design", :, :] = pt.as_tensor_variable(design_matrix)
195195

196+
# selection matrix R defines structure of innovations (always identity for cycle components)
197+
# when innovations=False, state cov Q=0, hence R @ Q @ R.T = 0
196198
R = np.eye(2) # 2x2 identity for each cycle component
197199
selection_matrix = block_diag(*[R for _ in range(self.k_endog)])
198200
self.ssm["selection", :, :] = pt.as_tensor_variable(selection_matrix)
@@ -228,6 +230,9 @@ def make_symbolic_graph(self) -> None:
228230
*[pt.eye(2) * sigma_cycle[i] ** 2 for i in range(self.k_endog)]
229231
)
230232
self.ssm["state_cov"] = pt.specify_shape(state_cov, (self.k_states, self.k_states))
233+
else:
234+
# explicitly set state cov to 0 when no innovations
235+
self.ssm["state_cov", :, :] = pt.zeros((self.k_posdef, self.k_posdef))
231236

232237
def populate_component_properties(self):
233238
self.state_names = [

0 commit comments

Comments
 (0)