calibrate: Calibration for the simple linear regression model.

Description Usage Arguments Value Note References Examples

View source: R/calibrate.R

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.

#' @rdname calibrate #' @export #' @method calibrate lm calibrate.lm <- function(object, ...) calibrate(formula(object), data = eval(object$call$data), ...)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
calibrate(object, ...)

## Default S3 method:
calibrate(object, y0, interval = c("inversion", "Wald",
  "none"), 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, y0, interval = c("inversion", "Wald", "none"),
  level = 0.95, mean.response = FALSE, adjust = c("none", "Bonferroni",
  "Scheffe"), k, ...)

Arguments

object

An object that inherits from class "lm", a matrix, a list, or a data frame.

...

Additional optional arguments. At present, no optional arguments are used.

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.

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 environment from which lm is called.

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.

Value

An object of class "invest" containing the following components:

Note

The function invest is more general, but based on numerical techniques to find the solution. When the underlying model is that of the simple linear regression model with normal errors, closed-form expressions exist which are utilized by the function calibrate.

References

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

Miller, R. G. (1981) Simultaneous Statistical Inference. Springer-Verlag.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#
# Arsenic example (simple linear regression with replication)
#

# 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")
(cal <- calibrate(arsenic.lm, y0 = 3, interval = "inversion"))
abline(h = 3)
segments(cal$estimate, 3, cal$estimate, par()$usr[3])
arrows(cal$lower, 3, cal$lower, par()$usr[3])
arrows(cal$upper, 3, cal$upper, par()$usr[3])

#
# Crystal weight example (simple linear regression)
#

# 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")
(cal <- calibrate(crystal.lm, y0 = 8, interval = "inversion", 
                  mean.response = TRUE))
abline(h = 8)
segments(cal$estimate, 8, cal$estimate, par()$usr[3])
arrows(cal$lower, 8, cal$lower, par()$usr[3])
arrows(cal$upper, 8, cal$upper, par()$usr[3])

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

investr documentation built on May 29, 2017, 3:24 p.m.