diff --git a/src/AnovaGLM.jl b/src/AnovaGLM.jl index 933932c..8a8a272 100644 --- a/src/AnovaGLM.jl +++ b/src/AnovaGLM.jl @@ -16,7 +16,7 @@ import GLM: glm, updateμ!, cholfactors, # other FP, BlasReal, Link, dispersion, deviance, dof, dof_residual, nobs -using AnovaBase: select_super_interaction, extract_contrasts, canonicalgoodnessoffit, subformula, predictors, dof_asgn, lrt_nested, ftest_nested +using AnovaBase: select_super_interaction, extract_contrasts, canonicalgoodnessoffit, subformula, predictors, dof_asgn, lrt_nested, ftest_nested, _diff, _diffn import AnovaBase: anova, nestedmodels, anovatable, prednames export anova_lm, anova_glm diff --git a/src/anova.jl b/src/anova.jl index 5fb62fd..cff44e8 100644 --- a/src/anova.jl +++ b/src/anova.jl @@ -52,7 +52,7 @@ function anova(::Type{FTest}, aovm::FullModel{<: TRM_LM}) f = formula(aovm.model) assign = asgn(predictors(aovm)) fullasgn = asgn(f) - df = tuple(dof_asgn(assign)...) + df = dof_asgn(assign) varβ = vcov(aovm.model.model) β = aovm.model.model.pp.beta0 offset = first(assign) + last(fullasgn) - last(assign) - 1 @@ -88,7 +88,7 @@ function anova(::Type{FTest}, devs = deviances(aovm; kwargs...) assign = asgn(collect(predictors(aovm))) #length(vdf) ≡ length(devs) + 1 && popfirst!(vdf) - df = tuple(dof_asgn(assign)...) + df = dof_asgn(assign) msr = devs ./ df fstat = msr ./ dispersion(aovm.model.model, true) dfr = round(Int, dof_residual(aovm.model)) @@ -108,7 +108,7 @@ function anova(::Type{LRT}, Δdev = deviances(aovm) assign = asgn(collect(predictors(aovm))) #isnullable(trm.model) || popfirst!(vdf) - df = tuple(dof_asgn(assign)...) + df = dof_asgn(assign) # den = last(ss) / (nobs(trm) - dof(trm) + 1) # lrstat = ss[1:end - 1] ./ den σ² = dispersion(aovm.model.model, true) diff --git a/src/io.jl b/src/io.jl index 9ebd7c2..bc6554b 100644 --- a/src/io.jl +++ b/src/io.jl @@ -42,15 +42,15 @@ function anovatable(aov::AnovaResult{<: FullModel{<: TableRegressionModel{<: Gen rownames, 4, 3) end -function anovatable(aov::AnovaResult{NestedModels{<: TableRegressionModel{<: LinearModel}, N}, FTest}; - rownames = "x" .* string.(1:N)) where N +function anovatable(aov::AnovaResult{<: NestedModels{<: TableRegressionModel{<: LinearModel}, N}, FTest}; + rownames = string.(1:N)) where N rs = r2.(aov.anovamodel.model) Δrs = _diff(rs) AnovaTable([ dof(aov), [NaN, _diff(dof(aov))...], - round(Int, dof_residual(aov.anovamodel.model)), + repeat([round(Int, dof_residual(last(aov.anovamodel.model)))], N), rs, [NaN, Δrs...], deviance(aov), @@ -62,19 +62,18 @@ function anovatable(aov::AnovaResult{NestedModels{<: TableRegressionModel{<: Lin rownames, 9, 8) end -function anovatable(aov::AnovaResult{NestedModels{<: TableRegressionModel{<: LinearModel}, N}, LRT}; - rownames = "x" .* string.(1:N)) where N +function anovatable(aov::AnovaResult{<: NestedModels{<: TableRegressionModel{<: LinearModel}, N}, LRT}; + rownames = string.(1:N)) where N rs = r2.(aov.anovamodel.model) Δrs = _diff(rs) AnovaTable([ dof(aov), [NaN, _diff(dof(aov))...], - round(Int, dof_residual(aov.anovamodel.model)), + repeat([round(Int, dof_residual(last(aov.anovamodel.model)))], N), rs, [NaN, Δrs...], deviance(aov), - [NaN, _diffn(deviance(aov))...], teststat(aov), pval(aov) ], diff --git a/test/runtests.jl b/test/runtests.jl index 52951be..c93517b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,7 +9,6 @@ macro test_error(x) $x false catch e - @error e true end end