Skip to content

Commit 950ba92

Browse files
Show R^2 for regression models
1 parent 4af81b9 commit 950ba92

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
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.22"
3+
version = "0.6.23"
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
@@ -31,7 +31,7 @@ export
3131
SeqDiffCoding,
3232
HypothesisCoding,
3333
ContrastsCoding,
34-
34+
3535
coefnames,
3636
dropterm,
3737
setcontrasts!,

src/statsmodel.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const TableModels = Union{TableStatisticalModel, TableRegressionModel}
122122
StatsBase.stderror, StatsBase.vcov]
123123
@delegate TableRegressionModel.model [StatsBase.modelmatrix,
124124
StatsBase.residuals, StatsBase.response,
125-
StatsBase.predict, StatsBase.predict!,
125+
StatsBase.predict, StatsBase.predict!,
126126
StatsBase.cooksdistance]
127127
StatsBase.predict(m::TableRegressionModel, new_x::AbstractMatrix; kwargs...) =
128128
predict(m.model, new_x; kwargs...)
@@ -189,7 +189,11 @@ function Base.show(io::IO, model::TableModels)
189189
println(io, model.mf.f)
190190
println(io)
191191
println(io,"Coefficients:")
192-
show(io, ct)
192+
println(io, ct)
193+
if model isa TableRegressionModel
194+
println(io)
195+
println("R²: ", round(r2(model), sigdigits=4))
196+
end
193197
catch e
194198
if isa(e, ErrorException) && occursin("coeftable is not defined", e.msg)
195199
show(io, model.model)

0 commit comments

Comments
 (0)