简体   繁体   中英

Formula to calculate standard error using 95% confidence interval

I have a column containing 95% confidence intervals as shown below. I would like to calculate standard error using the formula SE = (upper limit – lower limit)/3.92 in R studio.

I would like to know how to calculate SE when the upper limit and lower limit are in the same as shown below:

在此处输入代码

You want to first separate lower bound and upper bound into two columns.

interval <- c("(0.023, 0.031)", "(-0.031, -0.022)")
lim <- do.call("rbind", stringr::str_extract_all(interval, "[+-]?[0-9\\.]+"))
mode(lim) <- "numeric"
lim
#       [,1]   [,2]
#[1,]  0.023  0.031
#[2,] -0.031 -0.022

Then you can use your formula:

(lim[, 2] - lim[, 1]) / 3.92
#[1] 0.002040816 0.002295918

Note for others: 3.96 = 1.96 * 2, and 1.96 is -qnorm(0.025) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM