-
Notifications
You must be signed in to change notification settings - Fork 32
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
Show R^2 and F-statistic for regression models #225
base: master
Are you sure you want to change the base?
Conversation
c41a7e8
to
950ba92
Compare
b953553
to
8060e86
Compare
8060e86
to
9b59c4e
Compare
Thanks @palday for the good suggestions, I implemented them. |
Co-authored-by: Phillip Alday <palday@users.noreply.github.com>
424391c
to
88490cf
Compare
How about printing also the number of observations and degrees of freedom? Can you also add tests? |
println("R²: ", round(r2(model), sigdigits=4), | ||
"\t Adjusted R²: ", round(adjr2(model), sigdigits=4)) |
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.
This should ensure that 4 digits are always used, and that "Ajusted" is aligned with the value of the F-statistic on the next line.
println("R²: ", round(r2(model), sigdigits=4), | |
"\t Adjusted R²: ", round(adjr2(model), sigdigits=4)) | |
@printf(io, "R²: %.4f Adjusted R²: %.4f", r2(model), adjr2(model)) |
fstat = fstatistic(model) | ||
println(io, fstat) |
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.
fstatistic
doesn't exist anywhere currently, and only GLM provides the needed functionality via ftest
(JuliaStats/GLM.jl#424). An empty ftest
definition should be added to StatsAPI first. Probably the API can just require that the returned object has the dof
, fstat
and pval
properties so that you can extract them and print them.
fstat = fstatistic(model) | |
println(io, fstat) | |
ftr = ftest(model) | |
@printf(io, "F-statistic: %.4f on %s degrees of freedom, p-value %s", | |
ftr.fstat, ftr.dof, PValue(ftr.pvalue)) |
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.
@nalimilan what if adding a print API to StatsAPI so packages can implement their own printing?
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.
@xgdgsc every package is free to implement Base.show
methods for their own types
Adds R² and F-statistic for regression models, bringing the output closer to what users might expect when coming from R.
An example implementation of
fstatistic
is in JuliaStats/GLM.jl#424 -- I am unsure aboutimport/export/using/...
and welcome advice, thanks!Example output: