diff --git a/Project.toml b/Project.toml index 3973476..87cab1c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "AnovaGLM" uuid = "0a47a8e3-ec57-451e-bddb-e0be9d22772b" authors = ["Yu-Fong Peng "] -version = "0.2.3" +version = "0.2.4" [deps] AnovaBase = "946dddda-6a23-4b48-8e70-8e60d9b8d680" @@ -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" diff --git a/src/anova.jl b/src/anova.jl index 50da278..0a0c284 100644 --- a/src/anova.jl +++ b/src/anova.jl @@ -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 @@ -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}, @@ -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 # ---------------------------------------------------------------------------------------- @@ -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 # ================================================================================================================= @@ -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}, @@ -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}}} = diff --git a/src/fit.jl b/src/fit.jl index 36e24de..3a23936 100644 --- a/src/fit.jl +++ b/src/fit.jl @@ -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}} @@ -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...) =