Conversation
|
Changed base branch to |
| library(risks) # provides riskratio(), riskdiff(), postestimation functions | ||
| library(dplyr) # For data handling | ||
| library(broom) # For tidy() model summaries | ||
| data(breastcancer) |
There was a problem hiding this comment.
Should we say somewhere what package breastcancer comes from?
| ```{r allmodels2} | ||
| tidy(fit_all) %>% | ||
| select(-statistic, -p.value) %>% | ||
| tidy(fit_all) |> |
There was a problem hiding this comment.
I am not sure about introducing a dependency on R 4.1. I still see scientists use 4.0 and earlier.
| data <- data |> | ||
| dplyr::mutate(.clusterid = dplyr::row_number()) |> | ||
| dplyr::rename(outc = dplyr::one_of(!!yvar)) |> | ||
| tidyr::uncount(outc + 1) |> |
There was a problem hiding this comment.
The see the elegance in this approach! However, in the spirit of my comment in #10, it would be nice not to rely on tidyverse functions down the road. Let us focus on testing and bug fixes for now.
| dplyr::mutate(outc = 0) %>% | ||
| dplyr::rename(!!yvar := "outc")) | ||
|
|
||
| data <- data |> |
There was a problem hiding this comment.
see earlier comment about base R pipe
| yvar <- as.character(all.vars(formula)[1]) | ||
|
|
||
| #TODO the following assumes that outc is coded as 0/1. We should throw an | ||
| # error when this is not true |
| ... | ||
| ) | ||
| #TODO seeing a pattern: let's make returning a non-converged object | ||
| # an internal function that can be used in all cases like this |
There was a problem hiding this comment.
Right - such a function just exists under different names because it returns slightly different object types depending on what model was supposed to be fit.
risks/R/zestimate_risk-utils.R
Lines 68 to 117 in f48f0a0
| # TODO the below else is a great example of why they are best avoided | ||
| # in favor of explicit "if" conditions. I needed to jump way up to find | ||
| # that this is the "else" that happens when estimand is not equal to "rr". | ||
| # What else can it be? Let's just spell it clearly here instead of else. |
There was a problem hiding this comment.
Good point. Either "rr" or "rd".
| #TODO I think duplicate is only valid for RRs? If so we should add a check | ||
| if(approach[1] == "duplicate") { | ||
| #TODO I think this is supposed to be assigning to the object "fit" or did I | ||
| # lose something in the refactor? |
| if(approach[1] == "glm_cem") { | ||
| #TODO why not just require logbin and addreg as imports? They seem pretty | ||
| # fundamental to key functions in this package. Then these error messages could | ||
| # be removed |
Generally making way through the code base. I'll open the PR and do this iteratively, so that you can review changes per file as we go.