Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ftest printing #252

Merged
merged 1 commit into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/ftest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,18 @@ julia> dat = DataFrame(Treatment=[1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2.],
Result=[1.1, 1.2, 1, 2.2, 1.9, 2, .9, 1, 1, 2.2, 2, 2],
Other=[1, 1, 2, 1, 2, 1, 3, 1, 1, 2, 2, 1]);

julia> mod = lm(@formula(Result ~ 1 + Treatment), dat);
julia> model = lm(@formula(Result ~ 1 + Treatment), dat);

julia> nullmod = lm(@formula(Result ~ 1), dat);
julia> nullmodel = lm(@formula(Result ~ 1), dat);

julia> bigmod = lm(@formula(Result ~ 1 + Treatment + Other), dat);
julia> bigmodel = lm(@formula(Result ~ 1 + Treatment + Other), dat);

julia> ft = ftest(mod.model, nullmod.model)
julia> ft = ftest(model.model, nullmodel.model)
Res. DOF DOF ΔDOF SSR ΔSSR R² ΔR² F* p(>F)
Model 1 10 3 0.1283 0.9603
Model 2 11 2 -1 3.2292 -3.1008 0.0000 0.9603 241.6234 <1e-7


julia> ftest(bigmod.model, mod.model, nullmod.model)
julia> ftest(bigmodel.model, model.model, nullmodel.model)
Res. DOF DOF ΔDOF SSR ΔSSR R² ΔR² F* p(>F)
Model 1 9 4 0.1038 0.9678
Model 2 10 3 -1 0.1283 -0.0245 0.9603 0.0076 2.1236 0.1790
Expand Down Expand Up @@ -107,7 +106,7 @@ function show(io::IO, ftr::FTestResult{N}) where N

nc = 10
nr = N
outrows = Matrix{String}(nr+1, nc)
outrows = Matrix{String}(undef, nr+1, nc)

outrows[1, :] = ["", "Res. DOF", "DOF", "ΔDOF", "SSR", "ΔSSR",
"R²", "ΔR²", "F*", "p(>F)"]
Expand Down
27 changes: 13 additions & 14 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -487,25 +487,24 @@ end

ft = ftest(mod, nullmod)
@test isapprox(ft.pval[1].v, 2.481215056713184e-8)
# Test output - already covered in doctest
# @test sprint(show, ftest(mod, nullmod)) ==
# """
# Res. DOF DOF ΔDOF SSR ΔSSR R² ΔR² F* p(>F)
# Model 1 10 3 0.1283 0.9603
# Model 2 11 2 -1 3.2292 -3.1008 -0.0000 0.9603 241.6234 <1e-7
# """
@test sprint(show, ftest(mod, nullmod)) ==
"""
Res. DOF DOF ΔDOF SSR ΔSSR R² ΔR² F* p(>F)
Model 1 10 3 0.1283 0.9603
Model 2 11 2 -1 3.2292 -3.1008 -0.0000 0.9603 241.6234 <1e-7
"""

bigmod = lm(@formula(Result~Treatment+Other), d).model
ft2 = ftest(bigmod, mod, nullmod)
@test isapprox(ft2.pval[2].v, 2.481215056713184e-8)
@test isapprox(ft2.pval[1].v, 0.17903437900958952)
# @test sprint(show, ftest(bigmod, mod, nullmod)) ==
# """
# Res. DOF DOF ΔDOF SSR ΔSSR R² ΔR² F* p(>F)
# Model 1 9 4 0.1038 0.9678
# Model 2 10 3 -1 0.1283 -0.0245 0.9603 0.0076 2.1236 0.1790
# Model 3 11 2 -1 3.2292 -3.1008 -0.0000 0.9603 241.6234 <1e-7
# """
@test sprint(show, ftest(bigmod, mod, nullmod)) ==
"""
Res. DOF DOF ΔDOF SSR ΔSSR R² ΔR² F* p(>F)
Model 1 9 4 0.1038 0.9678
Model 2 10 3 -1 0.1283 -0.0245 0.9603 0.0076 2.1236 0.1790
Model 3 11 2 -1 3.2292 -3.1008 -0.0000 0.9603 241.6234 <1e-7
"""
end

@testset "F test rounding error" begin
Expand Down