Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upMixing of model[["coefficients"]] and coef(model) #91
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
leeper
Apr 2, 2018
Owner
This is a good point but one I need to think about a bit more. The challenge is not all model classes implement a coef()
method and even more, understandably, do not implement a coef<-()
method. I suspect the best solution is to write a new generic (something like set_coef()
) and then test that it behaves correctly on all classes.
This is a good point but one I need to think about a bit more. The challenge is not all model classes implement a |
leeper
added
the
enhancement
label
Apr 2, 2018
added a commit
that referenced
this issue
May 10, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
leeper
May 11, 2018
Owner
Thanks, again, for raising this issue. I've made two changes in response:
- The addition of a
reset_coefs()
generic with methods that modify the relevant part of the object, which is now used insidegradient_factory()
. - The addition of a test suite that assess both that
reset_coefs()
is narrowly successful in modifying the model object (such that thecoef()
method returns what was put into the object) but also - and more importantly - that the predictions that come out of the modified object are correct.
This should ensure that the clobbering at least produces the correct behavior. I can imagine there might be better ways to do this, but the tests will at least ensure that behavior is correct.
Thanks, again, for raising this issue. I've made two changes in response:
This should ensure that the clobbering at least produces the correct behavior. I can imagine there might be better ways to do this, but the tests will at least ensure that behavior is correct. |
lukesonnet commentedMar 19, 2018
•
edited
Edited 5 times
-
lukesonnet
edited Mar 19, 2018 (most recent)
-
lukesonnet
edited Mar 19, 2018
-
lukesonnet
edited Mar 19, 2018
-
lukesonnet
edited Mar 19, 2018
-
lukesonnet
edited Mar 19, 2018
Please specify whether your issue is about:
Hi @leeper. Thanks again for your work on this. In general, I think expecting
"coefficients"
to be in the output of a model object should be deprecated in favor of using s3 methods like"coef"
. You have done this in some places in your package (since the last CRAN submission).However, in a crucial location you still overrwite
model[["coefficients"]]
and then expectcoef(model)
to extract that object. For example, in get_effect_variances.R, see the following lines:Now, in
gradient_factory.default
, you do the following:So if while in the gradient factory you think you are clobbering
model[["coefficients"]]
, the next line in get_effect_variances usescoef(model)
and won't get those new coefficients ifcoef.model_class != model$coefficients
.