‚Z”Šw‚ÌŽ¿–âƒXƒŒiˆãŽÒE“Œ‘呲ê—pj Part438 (893Ú½)
㉺‘OŽŸ1-V
’Šo‰ðœ •KŽ€Áª¯¶°(–{‰Æ) (‚×) Ž©ID Ú½žx ‚ ‚Ú[‚ñ

826: 05/05(ŒŽ)19:07 ID:LDY1RQtT(1/4) AAS
# This R function, riskratio.boot, calculates the risk ratio and its Highest Density Interval (HDI)
# using a bootstrap method. It takes the number of events and the total number of observations
# for two groups as input.

riskratio.boot <- function(r1, r2, n1, n2, nboot = 5000, conf.level = 0.95, verbose = FALSE){
# Combine the number of events and total observations for both groups.
r <- c(r1, r2)
n <- c(n1, n2)
È26
827: 05/05(ŒŽ)19:08 ID:LDY1RQtT(2/4) AAS
Description:

The `riskratio.boot` function in R estimates the risk ratio between two groups and provides its Highest Density Interval (HDI) using a bootstrap resampling approach. It takes the counts of events and the total number of observations for each of the two groups as input.

Usage:

riskratio.boot(r1, r2, n1, n2, nboot = 5000, conf.level = 0.95, verbose = FALSE)

Arguments:
È7
828: 05/05(ŒŽ)19:09 ID:LDY1RQtT(3/4) AAS
Details:

The function works by simulating the event outcomes in each group through bootstrap resampling. For each group, it draws `n1` (or `n2`) samples with replacement from a hypothetical population that has the observed proportion of events (`r1/n1` or `r2/n2`). The number of events in each resampled set (`R1` and `R2`) is then used to calculate a bootstrapped risk ratio `(R1/n1) / (R2/n2)`. This process is repeated `nboot` times to generate a distribution of risk ratios. The function then calculates the mean of this distribution and its Highest Density Interval (HDI), which represents the most credible range for the true risk ratio given the data and the bootstrap procedure.

If `verbose` is set to `TRUE`, the function attempts to plot the distribution of the bootstrapped risk ratios using a script named `plotpost.R`. This requires that the `plotpost.R` script exists in the current working directory and is capable of handling the vector of bootstrapped risk ratios.

Value:

The function returns a list with the following components:
È4
829: 05/05(ŒŽ)19:23 ID:LDY1RQtT(4/4) AAS
> riskratio.boot(244,282,2345,2333,nboot=10000)
$b_mean
[1] 0.8641319

$b_ci
lower upper
0.7312212 1.0106121
attr(,"credMass")
È1
㉺‘OŽŸ1-VŠÖŽÊ”——õÝžx—ð
½Úî•ñ ÔÚ½’Šo ‰æ‘œÚ½’Šo —ð‚Ì–¢“Ç½Ú AA»ÑȲÙ

‚Ê‚±‚ÌŽè ‚Ê‚±TOP 0.025s