Skip to content

Commit

Permalink
Show R^2 for regression models
Browse files Browse the repository at this point in the history
  • Loading branch information
OndrejSlamecka committed Apr 25, 2021
1 parent 4af81b9 commit 950ba92
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
@@ -1,6 +1,6 @@
name = "StatsModels"
uuid = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
version = "0.6.22"
version = "0.6.23"

[deps]
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
Expand Down
2 changes: 1 addition & 1 deletion src/StatsModels.jl
Expand Up @@ -31,7 +31,7 @@ export
SeqDiffCoding,
HypothesisCoding,
ContrastsCoding,

coefnames,
dropterm,
setcontrasts!,
Expand Down
8 changes: 6 additions & 2 deletions src/statsmodel.jl
Expand Up @@ -122,7 +122,7 @@ const TableModels = Union{TableStatisticalModel, TableRegressionModel}
StatsBase.stderror, StatsBase.vcov]
@delegate TableRegressionModel.model [StatsBase.modelmatrix,
StatsBase.residuals, StatsBase.response,
StatsBase.predict, StatsBase.predict!,
StatsBase.predict, StatsBase.predict!,
StatsBase.cooksdistance]
StatsBase.predict(m::TableRegressionModel, new_x::AbstractMatrix; kwargs...) =
predict(m.model, new_x; kwargs...)
Expand Down Expand Up @@ -189,7 +189,11 @@ function Base.show(io::IO, model::TableModels)
println(io, model.mf.f)
println(io)
println(io,"Coefficients:")
show(io, ct)
println(io, ct)
if model isa TableRegressionModel
println(io)
println("R²: ", round(r2(model), sigdigits=4))
end
catch e
if isa(e, ErrorException) && occursin("coeftable is not defined", e.msg)
show(io, model.model)
Expand Down

0 comments on commit 950ba92

Please sign in to comment.