##
## 1. simple examples
##
(CI.v <- confint.var(c(1,1,4), c(1, 9, 9)))
(CI.s <- confint.sd(c(1,1,2), c(1, 9, 9)))
# Compare with the examples on Wikipedia
stopifnot(
all.equal(CI.s, sqrt(CI.v))
)
WikipEx <- t(matrix(c(0.45, 31.9, 0.69, 1.83, 1.38, 3.66),
nrow=2))
colnames(WikipEx) <- c('lower', 'upper')
(dCI <- (CI.s-WikipEx))
#Confirm within 2-digit roundoff
stopifnot(
max(abs(dCI))<0.0102
)
##
## 2. test df attributes
##
v <- c(1,1,4)
attr(v, 'df.') <- c(1, 9, 9)
class(v) <- 'var'
vCI <- confint(v)
# check
stopifnot(
all.equal(vCI, CI.v)
)
s <- sqrt(v)
class(s) <- 'sd'
sCI <- confint(s)
# check
stopifnot(
all.equal(sCI, CI.s)
)
Run the code above in your browser using DataLab