-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME.Rmd
More file actions
89 lines (64 loc) · 3.11 KB
/
README.Rmd
File metadata and controls
89 lines (64 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# risks: Estimating risk ratios and risk differences using regression
<!-- badges: start -->
[](https://codecov.io/gh/stopsack/risks?branch=master)
[](https://github.com/stopsack/risks/actions/workflows/main.yml)
<!-- badges: end -->
## Installation
The **risks** package can be installed from CRAN:
```{r, eval = FALSE}
install.packages("risks")
```
Development versions can be installed from
[GitHub](https://stopsack.github.io/risks/) using:
```{r, eval = FALSE}
remotes::install_github("stopsack/risks")
```
## Summary
The **risks** package fits regression models for risk ratios (RR) and risk
differences (RD). The package refers to “risk,” but “prevalence” can be
substituted throughout.
What is the association between an exposure (smoker/nonsmoker, age in years, or
underweight/lean/overweight/obese) and the risk of a binary outcome
(dead/alive, disease/healthy), perhaps adjusting for confounders
(men/women, years of education)? For such questions, many
studies default to reporting odds ratios, which may exaggerate
associations when the outcome is common. Odds ratios are often used because they
are easily obtained from logistic regression models. Obtaining risk ratios or
risk differences, especially adjusting for confounders, has typically required
more advanced biostatistics and programming skills, including in R.
The **risks** package makes estimating adjusted risk ratios and risk differences
as simple as fitting a logistic regression model. No advanced programming or
biostatistics skills are required. Risk ratios or risk differences are returned
whenever the data would allow for fitting a logistic model.
## Basic example
The example data stem from a [cohort of women with breast cancer](https://pubmed.ncbi.nlm.nih.gov/15286014). The the categorical exposure is `stage`, the binary outcome is `death`, and the binary confounder is `receptor`.
Fit a risk difference model:
```{r basic_example}
library(risks) # provides riskratio(), riskdiff(), postestimation functions
fit <- riskdiff(formula = death ~ stage + receptor, data = breastcancer)
```
Fitted objects can be used in the usual commands for generalized linear models, such as:
```{r basic_example2}
summary(fit)
```
`tidy()` from the broom package provides easy access to coefficients:
```{r basic_example3}
broom::tidy(fit)
```
## Further reading
- [Get started with the **risks** package](https://stopsack.github.io/risks/articles/risks.html)
- [Models and model comparisons](https://stopsack.github.io/risks/articles/models.html)
- [More on marginal standardization](https://stopsack.github.io/risks/articles/margstd.html)
- [Reporting results with the **rifttable** package](https://stopsack.github.io/rifttable/)