regression.with.ci <- function(regress.out, level=0.95) { ################################################################ # # # This function takes the output from an lm # # (linear model) command in R and provides not # # only the usual output from the summary command, but # # adds confidence intervals for intercept and slope. # # # ################################################################ usual.output <- summary(regress.out) t.quantile <- qt(1-(1-level)/2, df=regress.out$df) intercept.ci <- summary(regress.out)$coefficients[1] + c(-1, 1) * t.quantile * summary(regress.out)$coefficients[3] slope.ci <- summary(regress.out)$coefficients[2] + c(-1, 1) * t.quantile * summary(regress.out)$coefficients[4] output <- list(regression.table = usual.output, intercept.ci = intercept.ci, slope.ci = slope.ci) return(output) }