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

Fix tidy_multgee's y.levels (Issue #260) #261

Merged
merged 3 commits into from
Jul 27, 2024
Merged

Conversation

jackmwolf
Copy link
Contributor

  • Defines y.levels in terms of the first J - 1 levels of the outcome instead of the last J - 1 levels.
  • Updates relevant tests

I have ran devtools::test() on this fork and all seems to be working.

Reprex:

library(broom.helpers)
mod <- multgee::nomLORgee(
  y ~ factor(time) * sec,
  data = multgee::housing,
  id = id,
  repeated = time,
)
res <- mod %>% tidy_plus_plus()
#> ℹ multgee model detected.
#> ✔ `tidy_multgee()` used instead.
#> ℹ Add `tidy_fun = broom.helpers::tidy_multgee` to quiet these messages.

# Coefficients are for the 1st and 2nd factor levels (1 and 2) verus the
# reference level (3)
coef(summary(mod))
#>                      Estimate  san.se    san.z Pr(>|san.z|)
#> beta10                1.66073 0.25026  6.63594      0.00000
#> factor(time)6:1      -1.87010 0.31876 -5.86682      0.00000
#> factor(time)12:1     -2.92506 0.36829 -7.94235      0.00000
#> factor(time)24:1     -2.81359 0.34258 -8.21301      0.00000
#> sec:1                -0.53680 0.33704 -1.59271      0.11122
#> factor(time)6:sec:1  -1.18218 0.46036 -2.56797      0.01023
#> factor(time)12:sec:1  0.07916 0.48306  0.16386      0.86984
#> factor(time)24:sec:1  0.03273 0.46558  0.07030      0.94396
#> beta20                1.16643 0.26273  4.43974      0.00001
#> factor(time)6:2      -0.25454 0.30080 -0.84623      0.39742
#> factor(time)12:2     -0.57052 0.31176 -1.83000      0.06725
#> factor(time)24:2     -1.04101 0.30716 -3.38916      0.00070
#> sec:2                -0.10704 0.34759 -0.30796      0.75811
#> factor(time)6:sec:2  -1.62342 0.41349 -3.92613      0.00009
#> factor(time)12:sec:2 -2.04850 0.44543 -4.59898      0.00000
#> factor(time)24:sec:2 -1.04965 0.41831 -2.50925      0.01210

# Expect that values in res$y.level will correspond to the first 2 levels
# of the factor y and the corresponding names from coef(summary(mod))
res$y.level
#>  [1] "1" "1" "1" "1" "1" "1" "1" "1" "2" "2" "2" "2" "2" "2" "2" "2"
levels(factor(multgee::housing$y))
#> [1] "0" "1" "2"

Created on 2024-07-24 with reprex v2.1.0

- Defines `y.levels` in terms of the first J - 1 levels of the outcome instead of the last J - 1 levels.
- Updates relevant tests
@jackmwolf jackmwolf changed the title Resolves #260 Fix tidy_multgee's y.levels (Issue #260) Jul 25, 2024
Copy link

codecov bot commented Jul 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.96%. Comparing base (b7fe7c7) to head (3e5f5b2).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #261   +/-   ##
=======================================
  Coverage   94.96%   94.96%           
=======================================
  Files          43       43           
  Lines        2721     2721           
=======================================
  Hits         2584     2584           
  Misses        137      137           
Files Coverage Δ
R/custom_tidiers.R 84.37% <100.00%> (ø)

@larmarange larmarange merged commit 724b306 into larmarange:main Jul 27, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants