Skip to content

Commit 70c61d1

Browse files
Show R^2 for regression models
1 parent bbd0b86 commit 70c61d1

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "StatsModels"
22
uuid = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
3-
version = "0.6.29"
3+
version = "0.6.30"
44

55
[deps]
66
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"

src/StatsModels.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export
3333
SeqDiffCoding,
3434
HypothesisCoding,
3535
ContrastsCoding,
36-
36+
3737
coefnames,
3838
setcontrasts!,
3939
formula,

src/statsmodel.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ function StatsBase.coeftable(model::TableModels; kwargs...)
193193
ct
194194
end
195195

196+
_show_fit_stats(io::IO, model::TableModels) = nothing
197+
198+
function _show_fit_stats(io::IO, model::TableRegressionModel)
199+
println("R²: ", round(r2(model), sigdigits=4))
200+
end
201+
196202
# show function that delegates to coeftable
197203
function Base.show(io::IO, model::TableModels)
198204
println(io, typeof(model))
@@ -202,6 +208,7 @@ function Base.show(io::IO, model::TableModels)
202208
try
203209
println(io,"Coefficients:")
204210
show(io, coeftable(model))
211+
_show_fit_stats(io, model)
205212
catch e
206213
if isa(e, MethodError) || isa(e, ErrorException) && occursin("coeftable is not defined", e.msg)
207214
show(io, model.model)

0 commit comments

Comments
 (0)