diff --git a/Project.toml b/Project.toml index 95fdbda8..556892fd 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "StatsModels" uuid = "3eaba693-59b7-5ba5-a881-562e759f1c8d" -version = "0.6.29" +version = "0.6.30" [deps] DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" diff --git a/src/StatsModels.jl b/src/StatsModels.jl index 6555ec23..cafe8e61 100644 --- a/src/StatsModels.jl +++ b/src/StatsModels.jl @@ -33,7 +33,7 @@ export SeqDiffCoding, HypothesisCoding, ContrastsCoding, - + coefnames, setcontrasts!, formula, diff --git a/src/statsmodel.jl b/src/statsmodel.jl index 0bb67c7c..a229a451 100644 --- a/src/statsmodel.jl +++ b/src/statsmodel.jl @@ -133,7 +133,7 @@ const TableModels = Union{TableStatisticalModel, TableRegressionModel} @delegate TableRegressionModel.model [StatsBase.modelmatrix, StatsBase.residuals, StatsBase.response, StatsBase.predict, StatsBase.predict!, - StatsBase.cooksdistance] + StatsBase.cooksdistance, fstatistic] StatsBase.predict(m::TableRegressionModel, new_x::AbstractMatrix; kwargs...) = predict(m.model, new_x; kwargs...) # Need to define these manually because of ambiguity using @delegate @@ -193,6 +193,22 @@ function StatsBase.coeftable(model::TableModels; kwargs...) ct end +_show_fit_stats(io::IO, model::TableModels) = nothing + +function _show_fit_stats(io::IO, model::TableRegressionModel) + try + println("R²: ", round(r2(model), sigdigits=4), + "\t Adjusted R²: ", round(adjr2(model), sigdigits=4)) + + fstat = fstatistic(model) + println(io, fstat) + catch e + if !(isa(e, MethodError) && (e.f == r2 || e.f == adjr2 || e.f == fstatistic)) + rethrow(e) + end + end +end + # show function that delegates to coeftable function Base.show(io::IO, model::TableModels) println(io, typeof(model)) @@ -202,6 +218,7 @@ function Base.show(io::IO, model::TableModels) try println(io,"Coefficients:") show(io, coeftable(model)) + _show_fit_stats(io, model) catch e if isa(e, MethodError) || isa(e, ErrorException) && occursin("coeftable is not defined", e.msg) show(io, model.model)