AnovaMixedModels.jl

AnovaBase.anovaMethod
anova(<mixedmodels>...; test::Type{<: GoodnessOfFit}, <keyword arguments>)
anova(<anovamodel>; test::Type{<: GoodnessOfFit}, <keyword arguments>)
anova(test::Type{<: GoodnessOfFit}, <mixedmodels>...; <keyword arguments>)
anova(test::Type{<: GoodnessOfFit}, <anovamodel>; <keyword arguments>)

Analysis of variance.

Return AnovaResult{M, test, N}. See AnovaResult for details.

Arguments

  • mixedmodels: model objects
    1. LinearMixedModel fitted by AnovaMixedModels.lme or fit(LinearMixedModel, ...)
    2. GeneralizedLinearMixedModel fitted by AnovaMixedModels.glme or fit(GeneralizedLinearMixedModel, ...)
    If mutiple models are provided, they should be nested and the last one is the most complex. The first model can also be the corresponding GLM object without random effects.
  • anovamodel: wrapped model objects; FullModel and NestedModels.
  • test: test statistics for goodness of fit. Available tests are LikelihoodRatioTest (LRT) and FTest. The default is based on the model type.
    1. LinearMixedModel: FTest for one model; LRT for nested models.
    2. GeneralizedLinearMixedModel: LRT for nested models.

Other keyword arguments

  • When one model is provided:
    1. type: type of anova (1, 2 or 3). Default value is 1.
    2. adjust_sigma: whether adjust σ to match that of linear mixed-effect model fitted by REML. The result will be slightly deviated from that of model fitted by REML.
  • When multiple models are provided:
    1. check: allows to check if models are nested. Defalut value is true. Some checkers are not implemented now.
Note

For fitting new models and conducting anova at the same time, see anova_lme for LinearMixedModel.

Note

The result with adjust_sigma will be slightly deviated from that of model fitted directly by REML.

Note

For the computation of degrees of freedom, please see dof_residual_pred.

AnovaMixedModels.anova_lmeFunction
anova_lme(f::FormulaTerm, tbl; test::Type{<: GoodnessOfFit} = FTest, <keyword arguments>)

anova_lme(test::Type{<: GoodnessOfFit}, f::FormulaTerm, tbl; <keyword arguments>)

anova(test::Type{<: GoodnessOfFit}, ::Type{<: LinearMixedModel}, f::FormulaTerm, tbl; <keyword arguments>)

ANOVA for linear mixed-effect models.

Arguments

  • f: a Formula.
  • tbl: a Tables.jl compatible data.
  • test: GoodnessOfFit. The default is FTest.

Keyword arguments

  • test: GoodnessOfFit. The default is FTest.
  • type: type of anova (1, 2 or 3). Default value is 1.
  • adjust_sigma: whether adjust σ to match that of linear mixed-effect model fitted by REML. The result will be slightly deviated from that of model fitted by REML.

Other keyword arguments

  • wts = []
  • contrasts = Dict{Symbol,Any}()
  • progress::Bool = true
  • REML::Bool = true

anova_lme generate a LinearMixedModel fitted with REML if applying FTest; otherwise, a model fitted with ML.

Note

The result with adjust_sigma will be slightly deviated from that of model fitted directly by REML.

AnovaBase.nestedmodelsMethod
nestedmodels(model::LinearMixedModel; null::Bool = true, <keyword arguments>)

nestedmodels(::Type{LinearMixedModel}, f::FormulaTerm, tbl; null::Bool = true, wts = [], contrasts = Dict{Symbol, Any}(), verbose::Bool = false, REML::Bool = false)

Generate nested models from a model or modeltype, formula and data. The null model will be an empty model if the keyword argument null is true (default).

AnovaMixedModels.lmeFunction
lme(f::FormulaTerm, tbl; wts, contrasts, progress, REML)

An alias for fit(LinearMixedModel, f, tbl; wts, contrasts, progress, REML).

AnovaMixedModels.glmeFunction
glme(f::FormulaTerm, tbl, d::Distribution, l::Link; kwargs...)

An alias for fit(GeneralizedLinearMixedModel, f, tbl, d, l; kwargs...)

AnovaMixedModels.dof_residual_predFunction
dof_residual_pred(model::LinearMixedModel)
dof_residual_pred(aovm::FullModel{LinearMixedModel})

Compute degrees of freedom (DOF) of residuals for each predictors in a linear mixed effect models.

DOF of residuals are estimated by between-within method. For details, please refer to the documentation or GLMM FAQ for details.

To be noticed, my implementation is a little different from the reference one. When intercept is not in fix effects, the reference algorithm regards the first term as intercept; however, there is no such replacement here.