-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Residuals in GLM #540
base: pa/resid
Are you sure you want to change the base?
Residuals in GLM #540
Changes from all commits
0fda742
60a62c6
564a1f9
673e15d
b1ba4c5
1a2b8a1
b3cdf32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -360,9 +360,21 @@ response(obj::LinPredModel) = obj.rr.y | |
|
||
fitted(m::LinPredModel) = m.rr.mu | ||
predict(mm::LinPredModel) = fitted(mm) | ||
residuals(obj::LinPredModel) = residuals(obj.rr) | ||
|
||
function formula(obj::LinPredModel) | ||
function residuals(model::LinPredModel; type=:deviance) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not know the details of the implementation, but is the |
||
type in _RESIDUAL_TYPES || | ||
throw(ArgumentError("Unsupported type `$(type)``; supported types are" * | ||
"$(_RESIDUAL_TYPES)")) | ||
|
||
resid = response(model) - fitted(model) | ||
if length(model.rr.wts) > 0 && (type === :deviance || type === :pearson) | ||
return resid .* sqrt.(model.rr.wts) | ||
else | ||
return resid | ||
end | ||
end | ||
|
||
function StatsModels.formula(obj::LinPredModel) | ||
obj.formula === nothing && throw(ArgumentError("model was fitted without a formula")) | ||
return obj.formula | ||
end | ||
|
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be in
using
part