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

Release 0.2.4 #13

Merged
merged 3 commits into from
Feb 28, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AnovaGLM"
uuid = "0a47a8e3-ec57-451e-bddb-e0be9d22772b"
authors = ["Yu-Fong Peng <[email protected]>"]
version = "0.2.3"
version = "0.2.4"

[deps]
AnovaBase = "946dddda-6a23-4b48-8e70-8e60d9b8d680"
Expand All @@ -15,10 +15,10 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d"

[compat]
AnovaBase = "0.7"
AnovaBase = "0.8"
Distributions = "0.23, 0.24, 0.25"
GLM = "1.9"
Reexport = "0.2, 1"
StatsBase = "0.33, 0.34"
StatsModels = "0.7"
julia = "1.6, 1.7, 1.8, 1.9"
julia = "1.6, 1.7, 1.8, 1.9, 1.10"
18 changes: 9 additions & 9 deletions src/anova.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ function anova(::Type{FTest}, aovm::FullModel{<: TRM_LM})
end
elseif aovm.type == 2
fstat = ntuple(last(fullasgn) - offset) do fix
select1 = sort!(collect(select_super_interaction(fullpred, fix + offset)))
select2 = setdiff(select1, fix + offset)
select1 = findall(in(select1), fullasgn)
select2 = findall(in(select2), fullasgn)
s1 = sort!(collect(select_super_interaction(fullpred, fix + offset)))
s2 = setdiff(s1, fix + offset)
select1 = findall(in(s1), fullasgn)
select2 = findall(in(s2), fullasgn)
(β[select1]' * (varβ[select1, select1] \ β[select1]) - β[select2]' * (varβ[select2, select2] \ β[select2])) / df[fix]
end
else
Expand All @@ -102,7 +102,7 @@ function anova(::Type{FTest}, aovm::FullModel{<: TRM_LM})
devs = @. fstat * σ² * df
dfr = round(Int, dof_residual(aovm.model))
pvalue = @. ccdf(FDist(df, dfr), abs(fstat))
AnovaResult{FTest}(aovm, df, devs, fstat, pvalue, NamedTuple())
AnovaResult(aovm, FTest, df, devs, fstat, pvalue, NamedTuple())
end

function anova(::Type{FTest},
Expand All @@ -115,7 +115,7 @@ function anova(::Type{FTest},
fstat = msr ./ dispersion(aovm.model.model, true)
dfr = round(Int, dof_residual(aovm.model))
pvalue = @. ccdf(FDist(df, dfr), abs(fstat))
AnovaResult{FTest}(aovm, df, devs, fstat, pvalue, NamedTuple())
AnovaResult(aovm, FTest, df, devs, fstat, pvalue, NamedTuple())
end

# ----------------------------------------------------------------------------------------
Expand Down Expand Up @@ -143,7 +143,7 @@ function anova(::Type{LRT},
i -= 1
end
pval = @. ccdf(Chisq(df), abs(lrstat))
AnovaResult{LRT}(aovm, df, tuple(dev[2:end]...), lrstat, pval, NamedTuple())
AnovaResult(aovm, LRT, df, tuple(dev[2:end]...), lrstat, pval, NamedTuple())
end

# =================================================================================================================
Expand All @@ -160,7 +160,7 @@ function anova(::Type{FTest},
# May exist some floating point error from dof_residual
# check comparable and nested
check && @warn "Could not check whether models are nested: results may not be meaningful"
ftest_nested(NestedModels{M}(trms), df, dfr, deviance.(trms), dispersion(last(trms).model, true))
ftest_nested(NestedModels(trms), df, dfr, deviance.(trms), dispersion(last(trms).model, true))
end

function anova(::Type{LRT},
Expand All @@ -172,7 +172,7 @@ function anova(::Type{LRT},
df = df[ord]
# check comparable and nested
check && @warn "Could not check whether models are nested: results may not be meaningful"
lrt_nested(NestedModels{M}(trms), df, deviance.(trms), dispersion(last(trms).model, true))
lrt_nested(NestedModels(trms), df, deviance.(trms), dispersion(last(trms).model, true))
end

anova(::Type{FTest}, aovm::NestedModels{M}) where {M <: TableRegressionModel{<: Union{LinearModel, GeneralizedLinearModel}}} =
Expand Down
4 changes: 2 additions & 2 deletions src/fit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ function nestedmodels(trm::M; null::Bool = true, kwargs...) where {M <: TableReg
y = response(mf)
TableRegressionModel(fit(trm.mf.model, mm.m, y; wts, dropcollinear, kwargs...), mf, mm)
end
NestedModels{M}(trms..., trm)
NestedModels(trms..., trm)
end

function nestedmodels(trm::M; null::Bool = true, kwargs...) where {M <: TableRegressionModel{<: GeneralizedLinearModel}}
Expand All @@ -262,7 +262,7 @@ function nestedmodels(trm::M; null::Bool = true, kwargs...) where {M <: TableReg
y = response(mf)
TableRegressionModel(fit(trm.mf.model, mm.m, y, distr, link; wts, offset, kwargs...), mf, mm)
end
NestedModels{M}(trms..., trm)
NestedModels(trms..., trm)
end

nestedmodels(::Type{LinearModel}, formula::FormulaTerm, data; null::Bool = true, kwargs...) =
Expand Down
Loading