Learn R Programming

DescTools (version 0.99.56)

RSqCI: Confidence Intervals for the R squared of a Linear Model

Description

Calculate bootstrap intervals for the the R squared of a linear model as returned by lm.

Usage

RSqCI(
  object,
  conf.level = 0.95,
  sides = c("two.sided", "left", "right"),
  adjusted = TRUE,
  ...
)

Value

a numeric vector with 3 elements:

mean

mean

lwr.ci

lower bound of the confidence interval

upr.ci

upper bound of the confidence interval

Arguments

object

the model object as returned by glm.

conf.level

confidence level of the interval.

sides

a character string specifying the side of the confidence interval, must be one of "two.sided" (default), "left" or "right". "left" would be analogue to a hypothesis of "greater" in a t.test. You can specify just the initial letter.

adjusted

logical, defining if the R squared or the adjusted R squared should be used. Default is TRUE, returning the latter.

...

further arguments are passed to the boot function. Supported arguments are type ("norm", "basic", "stud", "perc", "bca"), parallel and the number of bootstrap replicates R. If not defined those will be set to their defaults, being "basic" for type, option "boot.parallel" (and if that is not set, "no") for parallel and 999 for R.

Author

Andri Signorell andri@signorell.net

See Also

BrierScore

Examples

Run this code

# get linear model
r.lm <- lm(Fertility ~ Agriculture + Examination + Education
                         + Catholic + Infant.Mortality, data=swiss)

# calculate confidence intervals for the R2
summary(r.lm)$r.squared

RSqCI(r.lm, R=99)   # use higher R in real life!

Run the code above in your browser using DataLab