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

Revert "Release 0.7.2" #60

Merged
merged 1 commit into from
Jan 19, 2023
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
18 changes: 3 additions & 15 deletions src/fit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,16 @@ end

# Calculate dof from assign
"""
dof_asgn(assign::Vector{Int})
dof_asgn(v::Vector{Int})

Calculate degrees of freedom of each predictors. 'assign' can be obtained by `StatsModels.asgn(f::FormulaTerm)`. For a given `trm::RegressionModel`, it is as same as `trm.mm.assign`.

The index of the output matches values in the orinal `assign`. If any index value is not in `assign`, the default is 0.

# Examples
```julia
julia> dof_asgn([1, 2, 2, 3, 3, 3])
(1, 2, 3)

julia> dof_asgn([2, 2, 3, 3, 3])
(0, 2, 3)

```
Calculate degrees of freedom of each predictors. 'v' can be obtained by `StatsModels.asgn(f::FormulaTerm)`. For a given `trm::RegressionModel`, it is as same as `trm.mm.assign`.
"""
function dof_asgn(v::Vector{Int})
dofv = zeros(Int, maximum(v))
for i in v
@inbounds dofv[i] += 1
end
tuple(dofv...)
dofv
end

@deprecate dof(v::Vector{Int}) dof_asgn(v::Vector{Int})
Expand Down
6 changes: 3 additions & 3 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ predictors(anovamodel::FullModel) = getindex.(Ref(predictors(anovamodel.model)),
anovatable(aov::AnovaResult{<: NestedModels, LRT, N}; rownames = string.(1:N)) where N

Return a table with coefficients and related statistics of ANOVA.
When displaying `aov` in repl, `rownames` will be `prednames(aov)` for `FullModel` and `string.(1:N)` for `NestedModels`.
When displaying `aov` in repl, `rownames` will be `prednames(aov)` for `FullModel` and `"x" .* string.(1:N)` for `NestedModels`.

For nested models, there are two default methods for `FTest` and `LRT`; one can also define new methods dispatching on `::NestedModels{M}` where `M` is a model type.

Expand All @@ -87,7 +87,7 @@ function anovatable(::AnovaResult{T, S, N}; rownames = "x" .* string.(1:N)) wher
end

# default anovatable api for comparing multiple models
function anovatable(aov::AnovaResult{<: NestedModels, FTest, N}; rownames = string.(1:N)) where N
function anovatable(aov::AnovaResult{<: NestedModels, FTest, N}; rownames = "x" .* string.(1:N)) where N
AnovaTable([
dof(aov),
[NaN, _diff(dof(aov))...],
Expand All @@ -101,7 +101,7 @@ function anovatable(aov::AnovaResult{<: NestedModels, FTest, N}; rownames = stri
rownames, 7, 6)
end

function anovatable(aov::AnovaResult{<: NestedModels, LRT, N}; rownames = string.(1:N)) where N
function anovatable(aov::AnovaResult{<: NestedModels, LRT, N}; rownames = "x" .* string.(1:N)) where N
AnovaTable([
dof(aov),
[NaN, _diff(dof(aov))...],
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ anovatable(::AnovaResult{<: FullModel{StatsModels.TableRegressionModel{Int64, Ma
@test canonicalgoodnessoffit(Binomial()) == LRT
@test AnovaBase.lrt_nested(NestedModels{StatsModels.TableRegressionModel}(model1, model1), (1,2), (1.5, 1.5), 0.1).teststat[2] == 0.0
@test AnovaBase.ftest_nested(NestedModels{StatsModels.TableRegressionModel}((model1, model1)), (1,2), (10, 10), (1.5, 1.5), 0.1).teststat[2] == 0.0
@test dof_asgn([1, 2, 2, 2, 3]) == (1, 3, 1)
@test dof_asgn([1, 2, 2, 2, 3]) == [1, 3, 1]
end
global f = FormulaTerm(conterm, MatrixTerm((InterceptTerm{true}(), caterm(), fterm, InteractionTerm((caterm(), fterm)))))
@testset "term.jl" begin
Expand Down