Code Monkey home page Code Monkey logo

Comments (3)

larmarange avatar larmarange commented on July 19, 2024 1

Should be noted, that then you specify manually a treatment contrast, R is not using anymore the level but the position of it. But it remains explicit and the label column is still correct.

library(broom.helpers)
library(gtsummary)

mod <- glm(age ~ grade, data = trial, family = gaussian, contrasts = list(grade = contr.treatment(3, base = 2)))

mod %>%
  tidy_and_attach() %>%
  tidy_identify_variables() %>%
  tidy_add_variable_labels() %>%
  tidy_add_reference_rows() %>%
  tidy_add_header_rows() %>% 
  select(variable, term, reference_row, label, header_row)

#> # A tibble: 5 x 5
#>   variable term        reference_row label       header_row
#>   <chr>    <chr>       <lgl>         <chr>       <lgl>     
#> 1 <NA>     (Intercept) NA            (Intercept) NA        
#> 2 grade    <NA>        NA            Grade       TRUE      
#> 3 grade    grade1      FALSE         I           FALSE     
#> 4 grade    gradeII     TRUE          II          FALSE     
#> 5 grade    grade3      FALSE         III         FALSE

from broom.helpers.

larmarange avatar larmarange commented on July 19, 2024

The issue with "gradeI" is that naming convention is valid only for contr.treatment, while contr.sum and contr.SAS adopt another approach (with the number instead of the level instead of its value).

However, should be possible to do something. I just need to reread properly the code

from broom.helpers.

larmarange avatar larmarange commented on July 19, 2024

OK it has been fixed:

library(broom.helpers)
library(gtsummary)

mod <- glm(age ~ grade, data = trial, family = gaussian)

mod %>%
  tidy_and_attach() %>%
  tidy_identify_variables() %>%
  tidy_add_variable_labels() %>%
  tidy_add_reference_rows() %>%
  tidy_add_header_rows() %>% 
  select(variable, term, reference_row, label, header_row)
#> # A tibble: 5 x 5
#>   variable term        reference_row label       header_row
#>   <chr>    <chr>       <lgl>         <chr>       <lgl>     
#> 1 <NA>     (Intercept) NA            (Intercept) NA        
#> 2 grade    <NA>        NA            Grade       TRUE      
#> 3 grade    gradeI      TRUE          I           FALSE     
#> 4 grade    gradeII     FALSE         II          FALSE     
#> 5 grade    gradeIII    FALSE         III         FALSE

from broom.helpers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.