Learn R Programming

directadjusting (version 0.6.1)

directadjusting-package: directadjusting: Directly Adjusted Estimates

Description

Compute estimates and confidence intervals of weighted averages quickly and easily. Weighted averages are computed using data.table for speed. Confidence intervals are approximated using the delta method with either using known formulae or via algorithmic or numerical integration.

Arguments

Recommended installation

devtools::install_github(
  "FinnishCancerRegistry/directadjusting@release"
)

Example

# suppose we have poisson rates that we want to adjust for by age group.
# they are stratified by sex.
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::data.table( sex = rep(1:2, each = 4), ag = rep(1:4, times = 2), e = counts / offsets ) my_stats[, "v" := my_stats[["e"]] / offsets] print(my_stats) # sex ag e v # <int> <int> <num> <num> # 1: 1 1 0.08928141 8.759527e-05 # 2: 1 2 0.10054601 1.175523e-04 # 3: 1 3 0.11987410 1.238776e-04 # 4: 1 4 0.09722692 8.365551e-05 # 5: 2 1 0.18043221 1.937844e-04 # 6: 2 2 0.14781448 1.227479e-04 # 7: 2 3 0.21747515 1.987203e-04 # 8: 2 4 0.21519746 1.781152e-04

# adjusted by age group my_adj_stats <- directadjusting::directly_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) )

print(my_adj_stats) # Key: <sex> # sex e v e_lo e_hi # <int> <num> <num> <num> <num> # 1: 1 0.1056924 3.474049e-05 0.09474912 0.1178996 # 2: 2 0.1889406 5.237509e-05 0.17527556 0.2036710

News

News for version 0.6.1

directadjusting

DESCRIPTION and documentation fixes.

News for version 0.6.0

directadjusting

First CRAN release.

News for version 0.5.0

directadjusting::direct_adjusted_estimates

directadjusting::delta_method_confidence_intervals made a lot more flexible. It now accepts via conf_method a string, a call, and a list of calls that produce the desired confidence intervals.

directadjusting::direct_adjusted_estimates

directadjusting::direct_adjusted_estimates option conf_methods = "boot" removed. Only delta method confidence intervals now possible. Making use of the delta method is now more flexible and accepts e.g. list("log", list(g = quote(qnorm(theta)), g_inv = quote(pnorm(g)))).

directadjusting::direct_adjusted_estimates

directadjusting::direct_adjusted_estimates now allows for the sake of convenience to be called with no adjust_col_nms defined. This results in no adjusting.

News for version 0.4.0

directadjusting::direct_adjusted_estimates

directadjusting::direct_adjusted_estimates now correctly uses the same conf_lvls and conf_methods for all statistics when their length is one.

News for version 0.3.0

directadjusting

Remove deprecated directadjusting::direct_adjusted_estimates. Use directadjusting::directly_adjusted_estimates.

Author

Maintainer: Joonas Miettinen joonas.miettinen@cancer.fi (ORCID)

See Also