https://github.com/finnishcancerregistry/directadjusting
Compute estimates of weighted averages with confidence intervals.
https://github.com/finnishcancerregistry/directadjusting
biostatistics confidence-intervals data-analysis direct-adjusting direct-adjustment epidemiology health-statistics r r-package statistical-adjusting statistical-adjustment weighted-analysis weighted-average weighted-averages
Last synced: about 1 year ago
JSON representation
Compute estimates of weighted averages with confidence intervals.
- Host: GitHub
- URL: https://github.com/finnishcancerregistry/directadjusting
- Owner: FinnishCancerRegistry
- License: other
- Created: 2019-08-21T18:08:25.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-12-12T10:26:05.000Z (over 1 year ago)
- Last Synced: 2025-01-31T14:38:05.540Z (over 1 year ago)
- Topics: biostatistics, confidence-intervals, data-analysis, direct-adjusting, direct-adjustment, epidemiology, health-statistics, r, r-package, statistical-adjusting, statistical-adjustment, weighted-analysis, weighted-average, weighted-averages
- Language: R
- Homepage:
- Size: 67.4 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Package `directadjusting`
Compute estimates and confidence intervals of weighted averages quickly and easily.
[](https://github.com/FinnishCancerRegistry/directadjusting/actions/workflows/R-CMD-check.yaml)
# Recommended installation
```r
devtools::install_github(
"FinnishCancerRegistry/directadjusting",
ref = readline("enter latest tag on github: ")
)
```
# Example
```r
library("directadjusting")
# suppose we have poisson rates that we want to adjust for by age group.
# they are stratified by sex.
library("data.table")
set.seed(1337)
offsets <- rnorm(8, mean = 1000, sd = 100)
baseline <- 100
sex_hrs <- rep(1:2, each = 4)
age_group_hrs <- rep(c(0.75, 0.90, 1.10, 1.25), times = 2)
counts <- rpois(8, baseline * sex_hrs * age_group_hrs)
# raw estimates
my_stats <- data.table(
sex = rep(1:2, each = 4),
ag = rep(1:4, times = 2),
e = counts / offsets
)
my_stats[["v"]] <- my_stats[["e"]] / offsets
# adjusted by age group
my_adj_stats <- direct_adjusted_estimates(
stats_dt = my_stats,
stat_col_nms = "e",
var_col_nms = "v",
conf_lvls = 0.95,
conf_methods = "log",
stratum_col_nms = "sex",
adjust_col_nms = "ag",
weights = c(200, 300, 400, 100)
)
```