Skip to content

Commit cc7a402

Browse files
committed
Deprecate has_intercept, doc update
1 parent 60ef4c8 commit cc7a402

File tree

4 files changed

+10
-21
lines changed

4 files changed

+10
-21
lines changed

docs/make.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ makedocs(
1111
"Examples_MixedModels.md",
1212
"Examples_FixedEffectModels.md"
1313
],
14-
"Interfacing AnovaBase.jl" => [
15-
"Interface.md"
16-
],
14+
"Interface.md",
1715
"Algorithm" => [
1816
"Algorithm_AnovaGLM.md",
1917
"Algorithm_AnovaMixedModels.md",

docs/src/Interface.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Interface
1+
# Interfacing AnovaBase.jl
22
Given model types `SomeModel` and `OtherModel`, the following functions have to be defined or used.
33

44
## [anova](./AnovaBase.md#AnovaBase.anova-Tuple{Type{<:GoodnessOfFit},%20AnovaModel})
@@ -62,4 +62,4 @@ This function is not essential for ANOVA; it is just for convenience to create n
6262
`AnovaBase` provides a lot of functions to work on formula, terms and contrasts. See [Developer utility](./AnovaBase.md#Developer-utility)
6363

6464
## Other function
65-
* [`dof_residual`](./AnovaBase.md#AnovaBase.dof_residual-Tuple{AnovaResult}) applies `dof_residual` to all models by default. If `dof_residual(::SomeModel)` is not valid for ANOVA, customize `dof_residual(::AnovaResult{<: AnovaModel{SomeModel}})` alternatively.
65+
* [`dof_residual`](./AnovaBase.md#StatsAPI.dof_residual-Tuple{AnovaResult}) applies `dof_residual` to all models by default. If `dof_residual(::SomeModel)` is not valid for ANOVA, customize `dof_residual(::AnovaResult{<: AnovaModel{SomeModel}})` alternatively.

src/AnovaBase.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module AnovaBase
33
using Statistics, Distributions, Reexport, Printf
44
@reexport using StatsModels
55
import StatsBase: fit!, fit, dof, dof_residual, deviance, nobs, vcov, coeftable
6-
import StatsModels: TableRegressionModel, vectorize, collect_matrix_terms, coefnames, formula, asgn, TupleTerm
6+
import StatsModels: TableRegressionModel, vectorize, collect_matrix_terms, coefnames, formula, asgn, TupleTerm, hasintercept
77
import Base: show
88

99
export
@@ -132,7 +132,7 @@ function FullModel(model::RegressionModel, type::Int, null::Bool, test_intercept
132132
#err2 = ArgumentError("Invalid set of model specification for ANOVA; all coefficents are aliased with 1.")
133133
preds = predictors(model)
134134
pred_id = collect(eachindex(preds))
135-
has_intercept(preds) || popfirst!(pred_id)
135+
hasintercept(preds) || popfirst!(pred_id)
136136
isempty(pred_id) && throw(err1) # ~ 0
137137
if type 1
138138
# ~ 0 + A + B..., ~ 1 + B..., ~ B as null

src/term.jl

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
# Function related to terms
2-
"""
3-
has_intercept(<terms>)
4-
5-
Return `true` if `InterceptTerm{true}` is in the terms.
6-
"""
7-
has_intercept(f::FormulaTerm) = has_intercept(f.rhs)
8-
has_intercept(f::MatrixTerm) = has_intercept(f.terms)
9-
has_intercept(f::TupleTerm) = has_intercept(first(f))
10-
has_intercept(::InterceptTerm{H}) where H = H
11-
has_intercept(::AbstractTerm) = false
2+
@deprecate has_intercept hasintercept
123

134
"""
145
any_not_aliased_with_1(<terms>)
@@ -201,31 +192,31 @@ Set{Int64} with 3 elements:
201192
select_super_interaction(f::MatrixTerm, id::Int) = select_super_interaction(f.terms, id)
202193
function select_super_interaction(f::TupleTerm, id::Int)
203194
s = id 1 ? Set(eachindex(f)) : Set([idn for idn in eachindex(f) if isinteract(f, id, idn)])
204-
has_intercept(f) || filter!(!=(1), s)
195+
hasintercept(f) || filter!(!=(1), s)
205196
s
206197
end
207198

208199
@doc doc_select_interaction
209200
select_sub_interaction(f::MatrixTerm, id::Int) = select_sub_interaction(f.terms, id)
210201
function select_sub_interaction(f::TupleTerm, id::Int)
211202
s = id 1 ? Set(Int[]) : Set([idn for idn in eachindex(f) if isinteract(f, idn, id)])
212-
has_intercept(f) || filter!(!=(1), s)
203+
hasintercept(f) || filter!(!=(1), s)
213204
s
214205
end
215206

216207
@doc doc_select_interaction
217208
select_not_super_interaction(f::MatrixTerm, id::Int) = select_not_super_interaction(f.terms, id)
218209
function select_not_super_interaction(f::TupleTerm, id::Int)
219210
s = id 1 ? Set(Int[]) : Set([idn for idn in eachindex(f) if !isinteract(f, id, idn)])
220-
has_intercept(f) || filter!(!=(1), s)
211+
hasintercept(f) || filter!(!=(1), s)
221212
s
222213
end
223214

224215
@doc doc_select_interaction
225216
select_not_sub_interaction(f::MatrixTerm, id::Int) = select_not_sub_interaction(f.terms, id)
226217
function select_not_sub_interaction(f::TupleTerm, id::Int)
227218
s = id 1 ? Set(eachindex(f)) : Set([idn for idn in eachindex(f) if !isinteract(f, idn, id)])
228-
has_intercept(f) || filter!(!=(1), s)
219+
hasintercept(f) || filter!(!=(1), s)
229220
s
230221
end
231222

0 commit comments

Comments
 (0)