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

tbl_regression does not work with geeglm if using rcspline.eval in formula #338

Closed
emilyvertosick opened this issue Jan 9, 2020 · 1 comment
Milestone

Comments

@emilyvertosick
Copy link
Contributor

emilyvertosick commented Jan 9, 2020

tbl_regression will work for a geeglm model if the splines are manually created, but if the function rcspline.eval is included in the formula, tbl_regression gives an error

library(tidyverse)
library(gtsummary)

# Creating model with manually-calculated splines
gee_manualsplines <-
  geepack::geeglm(
    #we are interested in the relationship between weight and time
    as.formula("weight ~ Time + sp2Time + sp3Time"),
    data = ChickWeight %>% 
      #we need to add spline terms for Time
      left_join(
        Hmisc::rcspline.eval(ChickWeight$Time, nk = 4, inclx = TRUE, norm = 0) %>%
          as_tibble(.name_repair = "unique") %>%
          set_names("Time", "sp2Time", "sp3Time") %>%
          unique(),
        by = c("Time") 
      ),
    family = gaussian,
    #we have multiple of weight over time for each chick
    id = Chick,
    corstr = "exchangeable"
  )
#> New names:
#> * `` -> ...2
#> * `` -> ...3
#> New names:
#> * `` -> ...2
#> * `` -> ...3
#> New names:
#> * `` -> ...2
#> * `` -> ...3
#> New names:
#> * `` -> ...2
#> * `` -> ...3

gee_manualsplines %>%
  tbl_regression()

image

# Creating model with rcspline.eval in formula
gee_with_splines <-
  geepack::geeglm(
    #we are interested in the relationship between weight and time
    as.formula("weight ~ Diet + rcspline.eval(Time, nk = 4, inclx = TRUE, norm = 0)"),
    data = ChickWeight,
    family = gaussian,
    #we have multiple of weight over time for each chick
    id = Chick,
    corstr = "exchangeable"
  )

gee_with_splines %>%
  tbl_regression()
#> Warning: non-unique value when setting 'row.names': 'rcspline.eval(Time, nk = 4,
#> inclx = TRUE, norm = 0)'
#> Error in `.rowNamesDF<-`(x, value = value): duplicate 'row.names' are not allowed

Created on 2020-01-09 by the reprex package (v0.3.0)

@ddsjoberg
Copy link
Owner

related to #337. This error occurs because of a failure in tidy(). When the name are not unique, the geepack() summary function also errors causing the tidy() error.

Thoughts @emilyvertosick @margarethannum @karissawhiting

@ddsjoberg ddsjoberg mentioned this issue Jan 9, 2020
9 tasks
@ddsjoberg ddsjoberg added this to the v1.2.5 milestone Jan 11, 2020
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

No branches or pull requests

2 participants