stopsack / risks Goto Github PK
View Code? Open in Web Editor NEWrisks: 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
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
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
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.
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.
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
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.
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?
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
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
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]]
throughfit$all_models[[6]]
The right solution may also help with the volume of output in tidy(fit_all)
After I refactored to remove "else" blocks per https://speakerdeck.com/jennybc/code-smells-and-feels?slide=30 (for example), I see that I've eliminated the preferred behavior to run all methods when "all" is on
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.