diff --git a/src/ftest.jl b/src/ftest.jl index d3ee8866..722acce9 100644 --- a/src/ftest.jl +++ b/src/ftest.jl @@ -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 @@ -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)"] diff --git a/test/runtests.jl b/test/runtests.jl index 367350ca..89319505 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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