Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yufongpeng committed Jan 19, 2023
1 parent d524c38 commit 6dfa186
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/AnovaGLM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/anova.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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)
Expand Down
13 changes: 6 additions & 7 deletions src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)
],
Expand Down
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ macro test_error(x)
$x
false
catch e
@error e
true
end
end
Expand Down

2 comments on commit 6dfa186

@yufongpeng
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/75958

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.0 -m "<description of version>" 6dfa18641125d77ce0a36a1272c0965186d2148b
git push origin v0.2.0

Please sign in to comment.