@@ -105,6 +105,8 @@ def test_gaussian_lmm():
105
105
assert np .allclose (model .coefs ["Estimate" ], estimates , atol = 0.001 )
106
106
107
107
assert isinstance (model .fixef , list )
108
+ assert (model .fixef [0 ].index .astype (int ) == df .Group .unique ()).all ()
109
+ assert (model .fixef [1 ].index .astype (float ) == df .IV3 .unique ()).all ()
108
110
assert model .fixef [0 ].shape == (47 , 3 )
109
111
assert model .fixef [1 ].shape == (3 , 3 )
110
112
@@ -133,6 +135,24 @@ def test_gaussian_lmm():
133
135
# Smoketest for old_optimizer
134
136
model .fit (summarize = False , old_optimizer = True )
135
137
138
+ # test fixef code for 1 fixed effect
139
+ model = Lmer ("DV ~ IV3 + IV2 + (IV2|Group)" , data = df )
140
+ model .fit (summarize = False , control = opt_opts )
141
+
142
+ assert (model .fixef .index .astype (int ) == df .Group .unique ()).all ()
143
+ assert model .fixef .shape == (47 , 3 )
144
+ assert np .allclose (model .coefs .loc [:, "Estimate" ], model .fixef .mean (), atol = 0.01 )
145
+
146
+ # test fixef code for 0 fixed effects
147
+ model = Lmer ("DV ~ (IV2|Group) + (1|IV3)" , data = df )
148
+ model .fit (summarize = False , control = opt_opts )
149
+
150
+ assert isinstance (model .fixef , list )
151
+ assert (model .fixef [0 ].index .astype (int ) == df .Group .unique ()).all ()
152
+ assert (model .fixef [1 ].index .astype (float ) == df .IV3 .unique ()).all ()
153
+ assert model .fixef [0 ].shape == (47 , 2 )
154
+ assert model .fixef [1 ].shape == (3 , 2 )
155
+
136
156
137
157
def test_contrasts ():
138
158
df = sns .load_dataset ("gammas" ).rename (columns = {"BOLD signal" : "bold" })
0 commit comments