Skip to content

Commit

Permalink
Show F-statistic for regression models
Browse files Browse the repository at this point in the history
Co-authored-by: Phillip Alday <palday@users.noreply.github.com>
  • Loading branch information
OndrejSlamecka and palday committed Apr 26, 2021
1 parent dc45b6a commit 9b59c4e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/statsmodel.jl
Expand Up @@ -123,7 +123,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
Expand Down Expand Up @@ -184,6 +184,14 @@ _show_fit_stats(io::IO, model::TableModels) = nothing

function _show_fit_stats(io::IO, model::TableRegressionModel)
println("R²: ", round(r2(model), sigdigits=4))
try
fstat = fstatistic(model)
println(io, fstat)
catch e
if !(isa(e, MethodError) && e.f == fstatistic)
rethrow(e)
end
end
end

# show function that delegates to coeftable
Expand Down

0 comments on commit 9b59c4e

Please sign in to comment.