GithubHelp home page GithubHelp logo

stopsack / risks Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 7.47 MB

risks: R package for estimating risk ratios and risk differences using regression

Home Page: https://stopsack.github.io/risks

License: GNU General Public License v3.0

R 100.00%
binomial biostatistics epidemiology regression-models

risks's People

Contributors

stopsack avatar tgerke avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

tgerke

risks's Issues

FR: Add support for propensity weights

It would be great to use weights with risks to better estimate causal RDs without using g-computation. The main benefit here is that there are more diagnostics for weights

`confint()` may not behave as intended

risks.Rmd states

  • confint(fit, level = 0.9) returns 90% confidence intervals.

but I'm pretty sure this will only correspond to the delta method confidence intervals (right?). If other types of estimates are in-use, users might want to go to confint with caution. Alternatively, we could roll a confint.risks for risks-type objects that will use the kind of confidence interval that was specified in the model-fitting step.

Write tests for caseduplicate.R

I've linted this one and made an assumption about intended matrix-initialization behavior (e.g. changing coef.table <- matrix(, 0L, 4L) to coef.table <- matrix(0L, 4L) but some unit tests would really help debug and enlighten as to where these functions come into play.

Convergence errors could be described

If we know this is a convergence problem, let's write an informative error that tells the user this is the case.

> riskratio(
+   formula = death ~ stage + receptor, 
+   data = breastcancer, 
+   approach = "glm"
+ )
Error: no valid set of coefficients has been found: please supply starting values

This is relevant to models.Rmd

Tidier UI for all models

Let's think of a less "base-y" way to access the individual models than

Individual models can be accessed as fit$all_models[[1]] through fit$all_models[[6]]

The right solution may also help with the volume of output in tidy(fit_all)

Only getting coefficients for first variable

What happens to the estimates for receptor in the following? Are riskratio and riskdiff implicitly assuming that we're only interested in estimates for the first variable specified, i.e. all following terms are confounders? If so, we should document the functions as such.

> fit_rr <- riskratio(death ~ stage + receptor, data = breastcancer)
> summary(fit_rr)

Risk ratio model, fitted via marginal standardization of a logistic model with delta method (margstd_delta).
Call:
stats::glm(formula = death ~ stage + receptor, family = binomial(link = "logit"), 
    data = breastcancer, start = "(no starting values)")

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
                                        

Coefficients: (3 not defined because of singularities)
               Estimate Std. Error z value Pr(>|z|)    
stageStage I     0.0000     0.0000     NaN      NaN    
stageStage II    0.8989     0.3875   2.320   0.0203 *  
stageStage III   1.8087     0.3783   4.781 1.75e-06 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Does `approach = "all"` option need a progress bar?

The example in models.Rmd runs fairly quickly, but have you encountered other applications where one or more of the methods is very slow? If so, it could be good for us to include a progress bar so that the user can know which method is taking the longest / possibly to avoid that method.

add {logbin} and {addreg} as dependencies

We could save a series of error messages in estimate_risk.R and glm-utils.R assumes their existence. I vote that both become dependencies, unless there's a reason to leave as suggests?

Fitting functions don't handle interactions

Usually a call like this would provide estimates for the interaction, but riskratio() does something unexpected. Perhaps we want to throw an error this kind of call (or do we want to allow this syntax interaction estimates)?

> fit_rr <- riskratio(death ~ stage*receptor, data = breastcancer)
> fit_rr

Risk ratio model
Call:  stats::glm(formula = death ~ stage * receptor, family = binomial(link = "logit"), 
    data = breastcancer, start = "(no starting values)")

Coefficients:
  stageStage I   stageStage II  stageStage III  
        0.0000          0.9161          1.7996  

Undefined coefs

fit_rr <- riskratio(death ~ stage + receptor, data = breastcancer)
summary(fit_rr)

The above block, found in both risks.Rmd and the help file for riskratio provides the following fit.

Coefficients: (3 not defined because of singularities)
               Estimate Std. Error z value Pr(>|z|)    
stageStage I     0.0000     0.0000     NaN      NaN    
stageStage II    0.8989     0.3875   2.320   0.0203 *  
stageStage III   1.8087     0.3783   4.781 1.75e-06 ***

The singularities warning may theoretically be expected, but could be confusing for users. A brief explanation of what's going on here could help; alternatively, we could think of ways to strip the warning from the summary() output if it is indeed the right thing.

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.