Learn R Programming

investr (version 1.1.0)

calibrate: Calibration for the simple linear regression model.

Description

The function calibrate computes the maximum likelihood estimate and a condfidence interval for the unknown predictor value that corresponds to an observed value of the response (or vector thereof) or specified value of the mean response. See the reference listed below for more details.

Usage

calibrate(object, ...)

## S3 method for class 'default': calibrate(object, y0, interval = c("inversion", "Wald"), level = 0.95, mean.response = FALSE, adjust = c("none", "Bonferroni", "Scheffe"), k, ...)

## S3 method for class 'formula': calibrate(formula, data = NULL, ..., subset, na.action = na.fail)

## S3 method for class 'lm': calibrate(object, ...)

Arguments

object
An object that inherits from class lm, a matrix, a list, or a data frame.
formula
A formula of the form y ~ x.
data
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the envi
subset
An optional vector specifying a subset of observations to be used in the fitting process.
na.action
a function which indicates what should happen when the data contain NAs.
y0
The value of the observed response(s) or specified value of the mean response.
interval
The method to use for forming a confidence interval.
level
A numeric scalar between 0 and 1 giving the confidence level for the interval to be calculated.
mean.response
Logicial indicating whether confidence intervals should correspond to an observed response(s) (FALSE) or a specified value of the mean response (TRUE). Default is FALSE.
adjust
A logical value indicating if an adjustment should be made to the critical value used in calculating the confidence interval. This useful for when the calibration curve is to be used multiple, say k, times.
k
The number times the calibration curve is to be used for computing a confidence interval. Only needed when adjust = TRUE.
...
Additional optional arguments. At present, no optional arguments are used.

Value

  • An object of class calibrate containing the following components: [object Object],[object Object],[object Object],[object Object],[object Object]

Warning

You must not call this function unless ...

References

Graybill, F. A., and Iyer, H. K. Regression analysis: Concepts and Applications. Belmont, Calif: Duxbury Press, 1994.

Examples

Run this code
## Inverting a prediction interval for an individual response
arsenic.lm <- lm(measured ~ actual, data = arsenic)
plotFit(arsenic.lm, interval = "prediction", shade = TRUE,
        col.pred = "lightblue")
calibrate(arsenic.lm, y0 = 3, interval = "inversion")

## Inverting a confidence interval for the mean response
crystal.lm <- lm(weight ~ time, data = crystal)
plotFit(crystal.lm, interval = "confidence", shade = TRUE,
        col.conf = "lightblue")
calibrate(crystal.lm, y0 = 8, interval = "inversion", mean.response = TRUE)

## Wald interval and approximate standard error based on the delta method
calibrate(crystal.lm, y0 = 8, interval = "Wald", mean.response = TRUE)

## Alterntively, we can use the car package to compute the standard error (this
## is trickier though when mean.respone = FALSE, hence, it is better to use the
## calibrate function).
library(car)
deltaMethod(crystal.lm, g = "(8 - b0) / b1", parameterNames = c("b0", "b1"))

Run the code above in your browser using DataLab