@@ -66,7 +66,9 @@ def test_ref_cov(data):
66
66
assert covmodel .ref_cat is None
67
67
assert np .isinf (covmodel .prior_beta_uniform ).all ()
68
68
69
- covmodel = CatCovModel (alt_cov = "alt_cat" , use_re_intercept = False )
69
+ covmodel = CatCovModel (
70
+ alt_cov = "alt_cat" , use_re = True , use_re_intercept = False
71
+ )
70
72
covmodel .attach_data (data )
71
73
assert covmodel .ref_cat is None
72
74
assert np .isinf (covmodel .prior_beta_uniform ).all ()
@@ -83,6 +85,7 @@ def test_ref_cov(data):
83
85
alt_cov = "alt_cat" ,
84
86
ref_cov = "ref_cat" ,
85
87
ref_cat = "B" ,
88
+ use_re = True ,
86
89
use_re_intercept = False ,
87
90
)
88
91
covmodel .attach_data (data )
@@ -188,3 +191,73 @@ def test_order_prior(data):
188
191
prior_order = [["A" , "B" ], ["B" , "C" , "E" ]],
189
192
)
190
193
covmodel .attach_data (data )
194
+
195
+
196
+ def test_num_x_vars (data ):
197
+ covmodel = CatCovModel (alt_cov = "alt_cat" , ref_cov = "ref_cat" , ref_cat = "A" )
198
+ assert covmodel .num_x_vars == 0
199
+ covmodel .attach_data (data )
200
+ assert covmodel .num_x_vars == 4
201
+
202
+
203
+ def test_num_z_vars (data ):
204
+ covmodel = CatCovModel (alt_cov = "alt_cat" , ref_cov = "ref_cat" , ref_cat = "A" )
205
+ assert covmodel .num_z_vars == 0
206
+
207
+ covmodel = CatCovModel (
208
+ alt_cov = "alt_cat" , ref_cov = "ref_cat" , ref_cat = "A" , use_re = True
209
+ )
210
+ assert covmodel .num_z_vars == 1
211
+
212
+ covmodel = CatCovModel (
213
+ alt_cov = "alt_cat" ,
214
+ ref_cov = "ref_cat" ,
215
+ ref_cat = "A" ,
216
+ use_re = True ,
217
+ use_re_intercept = False ,
218
+ )
219
+ assert covmodel .num_z_vars == 0
220
+ covmodel .attach_data (data )
221
+ assert covmodel .num_z_vars == 4
222
+
223
+
224
+ def test_num_constraints (data ):
225
+ covmodel = CatCovModel (alt_cov = "alt_cat" , ref_cov = "ref_cat" , ref_cat = "A" )
226
+ assert covmodel .num_constraints == 0
227
+ covmodel = CatCovModel (
228
+ alt_cov = "alt_cat" ,
229
+ ref_cov = "ref_cat" ,
230
+ ref_cat = "A" ,
231
+ prior_order = [["A" , "B" , "C" ]],
232
+ )
233
+ assert covmodel .num_constraints == 2
234
+
235
+
236
+ def test_create_constraint_mat (data ):
237
+ covmodel = CatCovModel (
238
+ alt_cov = "alt_cat" ,
239
+ ref_cov = "ref_cat" ,
240
+ ref_cat = "A" ,
241
+ prior_order = [["A" , "B" , "C" ]],
242
+ )
243
+ covmodel .attach_data (data )
244
+ c_mat , c_val = covmodel .create_constraint_mat ()
245
+ assert np .allclose (
246
+ c_mat ,
247
+ np .array (
248
+ [
249
+ [1.0 , - 1.0 , 0.0 , 0.0 ],
250
+ [0.0 , 1.0 , - 1.0 , 0.0 ],
251
+ ]
252
+ ),
253
+ )
254
+
255
+ assert np .allclose (
256
+ c_val ,
257
+ np .array (
258
+ [
259
+ [- np .inf , - np .inf ],
260
+ [0.0 , 0.0 ],
261
+ ]
262
+ ),
263
+ )
0 commit comments