Learn R Programming

survJamda (version 1.1.4)

ci.gm: Confidence interval of a Geometric mean

Description

Calculate the Confidence Interval (CI) of a geometric mean.

Usage

ci.gm(x)

Arguments

x
Vector of numeric values. For example, a vector of HRs.

Value

Vector of the CI of a geometric mean.

See Also

gm

Examples

Run this code
v = c(1.5,2.5,7,4)
ci.gm(v)

## The function is currently defined as
function(x){
          gm1 = mean(log(x), na.rm = T)
          cil = exp(gm1-(1.96*(sd(log(x), na.rm = T)/sqrt(length(x)))))
          ciupp = exp(gm1+(1.96*(sd(log(x), na.rm = T)/sqrt(length(x)))))
          vec = c(round(cil,2), round(ciupp,2))
          return (vec)
}

Run the code above in your browser using DataLab