-
Notifications
You must be signed in to change notification settings - Fork 194
API for VIF #698
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
API for VIF #698
Changes from all commits
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 |
|---|---|---|
|
|
@@ -205,6 +205,8 @@ export | |
| residuals, | ||
| r2, | ||
| r², | ||
| vif, | ||
| viftable, | ||
|
|
||
| ConvergenceException, | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -423,6 +423,29 @@ Return all parameters of a model. | |||||
| params(model) = error("params is not defined for $(typeof(model))") | ||||||
| function params! end | ||||||
|
|
||||||
| """ | ||||||
| vif(model, param) | ||||||
|
|
||||||
| Return the variance inflation factor for a parameter in a model. | ||||||
|
Member
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. How about saying "coefficient" rather than "parameter"? That's how we call these in general (function
Member
Author
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. 👍 Yeah, |
||||||
|
|
||||||
| The [variance inflation factor (VIF)](https://en.wikipedia.org/wiki/Variance_inflation_factor) measures | ||||||
| the increase in the variance of a parameter's estimate in a model with multiple parameters relative to | ||||||
| the variance in of a paremeter's estimate in a model containing only that parameter. | ||||||
|
Member
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.
Suggested change
|
||||||
| """ | ||||||
| vif(model::StatisticalModel, param) = | ||||||
| error("vif(model::StatisticalModel, param) is not defined for $(typeof(model)).") | ||||||
|
|
||||||
|
|
||||||
| """ | ||||||
| viftable(model) | ||||||
|
|
||||||
| Return the variance inflation factor for all parameters in a model as a `CoefTable`. | ||||||
|
|
||||||
| See also [`vif`](@ref) | ||||||
| """ | ||||||
| viftable(model::StatisticalModel) = | ||||||
|
Comment on lines
+442
to
+446
Member
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'm hesitant about adding this given that we have the
Member
Author
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. Hmmm. Tough one. I see your point, but I'm not sure I like having the kwarg in My motivation for having a table method is:
Maybe having a second
Member
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. Very tricky. Using a single-argument Unfortunately, so far we haven't standardized on a package for arrays with names. Maybe StatsBase could remain agnostic regarding the exact kind of vector which is returned, but packages could choose to return e.g. a
Member
Author
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. Huh, we could do single-argument
Member
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. Why would
Member
Author
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. It seems that you generally don't compute the VIF for the intercept term, which means that vifnames(model) = filter(!=("(Intercept)"), coefnames(model))
Member
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. (Sorry for the delay.) That's a good point, but I'm not sure that justifies adding a method to the API if that's just for convenience. Maybe we can just expect users to skip the intercept manually? Anyway, as I noted above, I hope that we will be able to return a vector with names from
Member
Author
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. Yeah, then I think we can just document that the |
||||||
| error("viftable(model::StatisticalModel) is not defined for $(typeof(model)).") | ||||||
|
|
||||||
| ## coefficient tables with specialized show method | ||||||
|
|
||||||
| mutable struct CoefTable | ||||||
|
|
||||||
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.
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.
Would it make sense to restrict this to
::RegressionModel? AFAIK the VIF is only used for linear regression, right?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.
I think it's used for any model falling within the generalized linear model and there might even be meaningful definitions for a broader class of models. But it's much easier to start narrow and broaden, so I'm fine restricting this to
RegressionModelfor now.