jinseob2kim / jstable

Regression Tables from 'GLM', 'GEE', 'GLMM', 'Cox' and 'survey' Results.
https://jinseob2kim.github.io/jstable/
Apache License 2.0
23 stars 13 forks source link

TableSubgroupMultiGLM #46

Closed Jone-wuy closed 2 months ago

Jone-wuy commented 2 months ago

Thank you for your excellent work; it is very convenient to use. However, I encountered a problem during the subgroup analysis process and need your help. Problem description: An error occurs in TableSubgroupMultiGLM when the covariates in var_cov contain categorical variables. The results for the subgroups are all empty, but the overall results are available.

Warning message: 1: In formula.character(object, env = baseenv()): Using formula(x) is deprecated when x is a character vector of length > 1. Consider formula(paste(x, collapse = " ")) instead. I tried a few times and there is no problem when categorical variables are not included in the covariates, but once categorical covariates are added, an error is reported.

jinseob2kim commented 2 months ago

Could you share the reproducible example?

I try the below & get appropriate result

library(survival)
library(dplyr)
lung %>%
  mutate(
    status = as.integer(status == 1),
    sex = factor(sex),
    kk = factor(as.integer(pat.karno >= 70)),
    kk1 = factor(as.integer(pat.karno >= 60))
  ) -> lung
## Categorical
lung$ag <- factor(as.integer(lung$age > 60) + as.integer(lung$age > 70))

TableSubgroupMultiGLM(status ~ sex,
                      var_subgroups = c("kk", "kk1"), var_cov = c("ag"),
                      data = lung, line = TRUE, family = "binomial"
)
+ )
     Variable Count Percent           OR Lower  Upper P value P for interaction
sex2  Overall   228     100         2.93   1.6   5.38   0.001              <NA>
1        <NA>  <NA>    <NA>         <NA>  <NA>   <NA>    <NA>              <NA>
2          kk  <NA>    <NA>         <NA>  <NA>   <NA>    <NA>             0.462
3           0    38    16.9         9.09  0.81 102.13   0.074              <NA>
4           1   187    83.1          2.8  1.46   5.38   0.002              <NA>
5        <NA>  <NA>    <NA>         <NA>  <NA>   <NA>    <NA>              <NA>
6         kk1  <NA>    <NA>         <NA>  <NA>   <NA>    <NA>             0.984
7           0     8     3.6 314366015.45     0    Inf   0.997              <NA>
8           1   217    96.4         2.78  1.49   5.16   0.001              <NA>
Jone-wuy commented 2 months ago

Thank you for your response. I tried your suggestion, but it didn't resolve the issue. Here is my case: when I don't include categorical covariates, the results are fine. However, when I include categorical covariates, the subgroup results turn out to be NA. Below are the run results, and the attachment contains my case data.

Thank you very much!

data <-data %>% mutate(status = as.integer(status==1), sex=factor(sex), pa_d=factor(pa_d), diet_d=factor(diet_d)) res1 <- TableSubgroupMultiGLM(formula=status~ln_oh, var_subgroups = c("pa_d", "diet_d"), data=data, var_cov = c("age", "bmi"), family = "binomial", decimal.estimate = 2,

res1 Variable Count Percent OR Lower Upper P value P for interaction ln_oh Overall 1200 100 1.17 0.9 1.52 0.247 1 pa_d NA 0.069 2 1 600 50 0.81 0.51 1.28 0.372 3 2 600 50 1.32 0.95 1.83 0.097 4 diet_d NA 0.539 5 1 600 50 1.02 0.63 1.64 0.95 6 2 600 50 1.17 0.85 1.62 0.336

res2 <- TableSubgroupMultiGLM(formula=status~ln_oh, var_subgroups = c("pa_d", "diet_d"), data=data, var_cov = c("age", "bmi","sex"), family = "binomial", decimal.estimate = 2, decimal.percent = 1, decimal.pvalue = 3)

res2 Variable Count Percent OR Lower Upper P value P for interaction ln_oh Overall 1200 100 1.36 1.03 1.8 0.028 1 pa_d 0.119 2 1 600 50 3 2 600 50 4 diet_d 0.547 5 1 600 50 6 2 600 50

data_example.csv

jinseob2kim commented 2 months ago

Sorry. I fix the issue. Please install the latest version via

remotes::install_github(“jinseob2kim/jstable”)
Jone-wuy commented 2 months ago

Thank you for your fix. The issue has been perfectly resolved. Thanks again for your outstanding work!