@@ -76,16 +76,19 @@ def __init__(
76
76
param_names , param_dims , param_info = self ._add_inital_state_cov_to_properties (
77
77
param_names , param_dims , param_info , k_states
78
78
)
79
- self ._state_names = state_names .copy ()
80
- self ._data_names = data_names .copy ()
81
- self ._shock_names = shock_names .copy ()
82
- self ._param_names = param_names .copy ()
83
- self ._param_dims = param_dims .copy ()
79
+
80
+ self ._state_names = self ._strip_data_names_if_unambiguous (state_names , k_endog )
81
+ self ._data_names = self ._strip_data_names_if_unambiguous (data_names , k_endog )
82
+ self ._shock_names = self ._strip_data_names_if_unambiguous (shock_names , k_endog )
83
+ self ._param_names = self ._strip_data_names_if_unambiguous (param_names , k_endog )
84
+ self ._param_dims = param_dims
84
85
85
86
default_coords = make_default_coords (self )
86
87
coords .update (default_coords )
87
88
88
- self ._coords = coords
89
+ self ._coords = {
90
+ k : self ._strip_data_names_if_unambiguous (v , k_endog ) for k , v in coords .items ()
91
+ }
89
92
self ._param_info = param_info .copy ()
90
93
self ._data_info = data_info .copy ()
91
94
self .measurement_error = measurement_error
@@ -122,6 +125,25 @@ def __init__(
122
125
P0 = self .make_and_register_variable ("P0" , shape = (self .k_states , self .k_states ))
123
126
self .ssm ["initial_state_cov" ] = P0
124
127
128
+ def _strip_data_names_if_unambiguous (self , names : list [str ], k_endog : int ):
129
+ """
130
+ State names from components should always be of the form name[data_name], in the case that the component is
131
+ associated with multiple observed states. Not doing so leads to ambiguity -- we might have two level states,
132
+ but which goes to which observed component? So we set `level[data_1]` and `level[data_2]`.
133
+
134
+ In cases where there is only one observed state (when k_endog == 1), we can strip the data part and just use
135
+ the state name. This is a bit cleaner.
136
+ """
137
+ if k_endog == 1 :
138
+ [data_name ] = self .observed_states
139
+ return [
140
+ name .replace (f"[{ data_name } ]" , "" ) if isinstance (name , str ) else name
141
+ for name in names
142
+ ]
143
+
144
+ else :
145
+ return names
146
+
125
147
@staticmethod
126
148
def _add_inital_state_cov_to_properties (param_names , param_dims , param_info , k_states ):
127
149
param_names += ["P0" ]
0 commit comments