Residuals in GLM#540
Conversation
|
This PR seems to be picking up some older commits and needs cleaning up. |
|
Thanks, Viral. |
* [G]VIF * add reference value source * more tests * glm tests
|
The PR is now cleaned up and merged with the latest master branch. |
| import Base: (\), convert, show, size | ||
| import LinearAlgebra: cholesky, cholesky! | ||
| import Statistics: cor | ||
| using StatsAPI |
| residuals(obj::LinPredModel) = residuals(obj.rr) | ||
|
|
||
| function formula(obj::LinPredModel) | ||
| function residuals(model::LinPredModel; type=:deviance) |
There was a problem hiding this comment.
I do not know the details of the implementation, but is the residuals method properly documented (as it is not documented here). I.e. that it supports type kwarg and what is the behavior depending on the value of the kwarg.
There was a problem hiding this comment.
It is documented on line 847 of glmfit.jl
There was a problem hiding this comment.
That docstring is attached only to the method for GeneralizedLinearModel. It should be attached to a method for a more general type (probably LinPredModel).
BTW, I don't think this method is correct as LinPredModel includes GeneralizedLinearModel. It should be restricted to LinearModel, and moved to lm.jl.
|
what's the status of this PR? Can it get a bit of love? |
| function formula(obj::LinPredModel) | ||
| function residuals(model::LinPredModel; type=:deviance) | ||
| type in _RESIDUAL_TYPES || | ||
| throw(ArgumentError("Unsupported type `$(type)``; supported types are" * |
There was a problem hiding this comment.
| throw(ArgumentError("Unsupported type `$(type)``; supported types are" * | |
| throw(ArgumentError("Unsupported type `$(type)`; supported types are " * |
(Could be fixed in the GLM method too BTW.)
| residuals(obj::LinPredModel) = residuals(obj.rr) | ||
|
|
||
| function formula(obj::LinPredModel) | ||
| function residuals(model::LinPredModel; type=:deviance) |
There was a problem hiding this comment.
That docstring is attached only to the method for GeneralizedLinearModel. It should be attached to a method for a more general type (probably LinPredModel).
BTW, I don't think this method is correct as LinPredModel includes GeneralizedLinearModel. It should be restricted to LinearModel, and moved to lm.jl.
I have added most of the test cases as discussed in #499.
Also, I have changed the residuals function for
lm. Now the residuals function forlmis similar to residuals function in 'glm'.Although, I am not sure about applicability of
:workingtype residuals inlm.Rsupports:workingtype residuals inlmand which is same as:responsetype.