You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if profile_fe:
params.fe_params = self.get_fe_params(params.cov_re, params.vcomp)
Is there a reason why params gets altered in one case but not in the other?
It looks like the not profile_fe case in score is not hit in the tests.
Similarly, each of loglike, score, and hessian check for isinstance(params, MixedLMParams), and if not create a new instance. But the kwargs they pass are slightly different. Specifically, hessian sets has_fe=True while the others set has_fe=False.
Editing the behavior of loglike to match score by setting params.fe_params does not appear to break any tests.
However editing hessian to use has_fe=False like the other methods does break test_lme.TestMixedLM.test_regularized and test_lme.TestMixedLM.test_regularized1.
I will try to find time to look into this. I should have noted that the
regularized fitting code for MixedLM should probably be considered
experimental. I don't know of an established approach to regularization
for mixed models, although there may be something out there.
On further tinkering, I found a workaround that lets me get rid of the troublesome asymmetry (though I still don't grok what's going on, hopefully this will be obvious to you). First, I've refactored out from fit everything between if start_params is None through raise ValueError("invalid start_params" into a function creatively called _unpack_start_params.
Then the if type(params) is not MixedLMParams: blocks in loglike, score, and hessian can use _unpack_start_params instead of MixedLMParams.from_packed. Doing this avoids the need to make a decision about the has_fe kwarg, since it is determined based on dimension matching.
This last assertion is flaky, can be made to fail more reliably by decreasing the n_grps parameter at the top of this test. The reason I think this flakiness is related to this issue is because the conversion from params to params_vec does not round-trip correctly when params_vec is passed to loglike above.
Activity
jbrockmendel commentedon May 23, 2017
An update on this:
Editing the behavior of
logliketo matchscoreby settingparams.fe_paramsdoes not appear to break any tests.However editing
hessianto usehas_fe=Falselike the other methods does breaktest_lme.TestMixedLM.test_regularizedandtest_lme.TestMixedLM.test_regularized1.kshedden commentedon May 23, 2017
jbrockmendel commentedon May 24, 2017
Excellent, thanks.
On further tinkering, I found a workaround that lets me get rid of the troublesome asymmetry (though I still don't grok what's going on, hopefully this will be obvious to you). First, I've refactored out from
fiteverything betweenif start_params is Nonethroughraise ValueError("invalid start_params"into a function creatively called_unpack_start_params.Then the
if type(params) is not MixedLMParams:blocks inloglike,score, andhessiancan use_unpack_start_paramsinstead ofMixedLMParams.from_packed. Doing this avoids the need to make a decision about thehas_fekwarg, since it is determined based on dimension matching.jbrockmendel commentedon Mar 31, 2018
@kshedden this appears to be relevant in troubleshooting #4396 downstream.
The relevant point in the test is here:
This last assertion is flaky, can be made to fail more reliably by decreasing the
n_grpsparameter at the top of this test. The reason I think this flakiness is related to this issue is because the conversion fromparamstoparams_vecdoes not round-trip correctly whenparams_vecis passed tologlikeabove.