Skip to content

Commit

Permalink
Merge pull request #165 from jmboehm/fix-single-rhs-fixedeffectsmodels
Browse files Browse the repository at this point in the history
Switch to broadcasting to fix no length issue on rhs in formula
  • Loading branch information
junder873 authored Sep 9, 2024
2 parents b24f80a + fc15c79 commit 60d6945
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RegressionTables"
uuid = "d519eb52-b820-54da-95a6-98e1306fdade"
authors = ["Johannes Boehm <[email protected]>"]
version = "0.7.6"
version = "0.7.7"

[deps]
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Expand Down
15 changes: 6 additions & 9 deletions ext/RegressionTablesFixedEffectModelsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,12 @@ function RegressionTables.other_stats(rr::FixedEffectModel, s::Symbol)
if !isdefined(rr, :formula)
return Dict{Symbol, Vector{Pair}}()
end
rhs_itr = if isa(rr.formula.rhs, StatsModels.Term)
[rr.formula.rhs]
else
rr.formula.rhs
end

for t in rhs_itr
if has_fe(t)
push!(out, RegressionTables.FixedEffectCoefName(RegressionTables.get_coefname(t)))
fe_set = has_fe.(rr.formula.rhs)
for (i, v) in enumerate(fe_set)
if v && !isa(fe_set, Bool)
push!(out, RegressionTables.FixedEffectCoefName(RegressionTables.get_coefname(rr.formula.rhs[i])))
elseif v
push!(out, RegressionTables.FixedEffectCoefName(RegressionTables.get_coefname(rr.formula.rhs)))
end
end
if length(out) > 0
Expand Down
9 changes: 6 additions & 3 deletions ext/RegressionTablesGLFixedEffectModelsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ function RegressionTables.other_stats(rr::GLFixedEffectModel, s::Symbol)
if !isdefined(rr, :formula)
return Dict{Symbol, Vector{Pair}}()
end
for t in rr.formula.rhs
if has_fe(t)
push!(out, RegressionTables.FixedEffectCoefName(RegressionTables.get_coefname(t)))
fe_set = has_fe.(rr.formula.rhs)
for (i, v) in enumerate(fe_set)
if v && !isa(fe_set, Bool)
push!(out, RegressionTables.FixedEffectCoefName(RegressionTables.get_coefname(rr.formula.rhs[i])))
elseif v
push!(out, RegressionTables.FixedEffectCoefName(RegressionTables.get_coefname(rr.formula.rhs)))
end
end
if length(out) > 0
Expand Down
4 changes: 4 additions & 0 deletions test/RegressionTables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ function checkfilesarethesame(file1::String, file2::String)
end

##
rr_short = reg(df, @formula(SepalLength ~ log1p(SepalWidth)))
tab = regtable(rr_short)
@test tab[4, 1] == "log1p(SepalWidth)"



tab = regtable(rr4,rr5,lm1, lm2, gm1; renderSettings = asciiOutput(joinpath(dirname(@__FILE__), "tables", "ftest1.txt")), regression_statistics = [:nobs, :r2, :adjr2, :r2_within, :f, :p, :f_kp, :p_kp, :dof])
Expand Down

2 comments on commit 60d6945

@junder873
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/114866

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.7.7 -m "<description of version>" 60d6945eeb45952453aa22cc0cb344a74178c7d5
git push origin v0.7.7

Please sign in to comment.