-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
[Bug]: s_odds_ratio not work with large N #1314
Comments
For me, the code works. Try to install the most recent versions of the package and let us know! Remember also to use |
Update to newest version. With sample size of 2000. Not work, Odds ratio and CI are library(tern)
#> Loading required package: rtables
#> Loading required package: formatters
#> Loading required package: magrittr
#>
#> Attaching package: 'rtables'
#> The following object is masked from 'package:utils':
#>
#> str
#> Registered S3 method overwritten by 'tern':
#> method from
#> tidy.glm broom
library(tidyverse)
nex <- 2000 # Number of example rows
dta <- data.frame(
"rsp" = sample(c(TRUE, FALSE), nex, TRUE),
"grp" = sample(c("A", "B"), nex, TRUE),
"f1" = sample(c("a1", "a2"), nex, TRUE),
"f2" = sample(c("x", "y", "z"), nex, TRUE),
strata = factor(sample(c("C", "D"), nex, TRUE)),
stringsAsFactors = TRUE
)
s_odds_ratio(
df = subset(dta, grp == "A"),
.var = "rsp",
.ref_group = subset(dta, grp == "B"),
.in_ref_col = FALSE,
.df_row = dta,
variables = list(arm = "grp", strata = "strata")
)
#> $or_ci
#> est lcl ucl
#> NA NA NA
#> attr(,"label")
#> [1] "Odds Ratio (95% CI)"
#>
#> $n_tot
#> n_tot
#> 2000
#> attr(,"label")
#> [1] "Total n" Created on 2024-09-30 with reprex v2.0.2 with sample size of 200. Works now. OR and CI were populated. library(tern)
#> Loading required package: rtables
#> Loading required package: formatters
#> Loading required package: magrittr
#>
#> Attaching package: 'rtables'
#> The following object is masked from 'package:utils':
#>
#> str
#> Registered S3 method overwritten by 'tern':
#> method from
#> tidy.glm broom
library(tidyverse)
nex <- 200 # Number of example rows
dta <- data.frame(
"rsp" = sample(c(TRUE, FALSE), nex, TRUE),
"grp" = sample(c("A", "B"), nex, TRUE),
"f1" = sample(c("a1", "a2"), nex, TRUE),
"f2" = sample(c("x", "y", "z"), nex, TRUE),
strata = factor(sample(c("C", "D"), nex, TRUE)),
stringsAsFactors = TRUE
)
s_odds_ratio(
df = subset(dta, grp == "A"),
.var = "rsp",
.ref_group = subset(dta, grp == "B"),
.in_ref_col = FALSE,
.df_row = dta,
variables = list(arm = "grp", strata = "strata")
)
#> $or_ci
#> est lcl ucl
#> 0.7336370 0.4203395 1.2804489
#> attr(,"label")
#> [1] "Odds Ratio (95% CI)"
#>
#> $n_tot
#> n_tot
#> 200
#> attr(,"label")
#> [1] "Total n" Created on 2024-09-30 with reprex v2.0.2 |
Thanks for confirming this. I run different cases and there seems to be a mysterious cutoff at nex > 1950. The following is summarizing my findings with examples. Issue DescriptionIn the first example using the Reproduction StepsExample 1:
|
Thank you. I think it may due to the too many ties and approximate can solve the issue here. |
What happened?
A bug happened!
changing
nex <- 200
makes code work.sessionInfo()
Relevant log output
Code of Conduct
Contribution Guidelines
Security Policy
The text was updated successfully, but these errors were encountered: