ols.interval {desk}R Documentation

Calculate Different Types of Intervals in a Linear Model

Description

Calculates different types of intervals in a linear model.

Usage

ols.interval(
  mod,
  data = list(),
  type = c("confidence", "prediction", "acceptance"),
  which.coef = "all",
  sig.level = 0.05,
  q = 0,
  dir = c("both", "left", "right"),
  xnew,
  details = FALSE
)

Arguments

mod

linear model object generated by ols().

data

name of data frame to be specified if mod is a formula.

type

string value indicating the type of interval to be calculated. Default is "confidence".

which.coef

strings of variable name(s) or vector of indices indicating the coefficients in the linear model for which confidence or acceptance intervals should be calculated. By default all coefficients are selected. Ignored for prediction intervals.

sig.level

significance level.

q

value against which null hypothesis is tested. Only to be specified if type = "acceptance".

dir

direction of the alternative hypothesis underlying the acceptance intervals. One sided confidence- and prediction intervals are not (yet) supported.

xnew

(T x K) matrix of new values of the exogenous variables, at which interval should be calculated, where T is the number of exogenous data points at which intervals should be calculated K is the number of exogenous variables in the model If type = "prediction" then prediction intervals are calculated at xnew, if type = "confidence" then confidence intervals around the unknown true y-values are calculated at xnew (ak.a. confidence band). Ignored if type = "acceptance". In multiple regression models variable names must be specified.

details

logical value indicating whether details (estimated standard deviations) should be printed out.

Value

A list object including:

results interval borders (lower and upper) and center of interval (if dir = "both").
std.err estimated standard deviations.
t.value critical t-value.

Examples

fert.est <- ols(barley ~ phos + nit, data = log(data.fertilizer))
my.mat = cbind(x1 = log(c(6,3,9)), x2 = log(c(5,3,10)))

## 95% CI for all parameters
ols.interval(fert.est)

## 95% CI for intercept and beta2
ols.interval(fert.est, which.coef = c(1,3))

## 95% CI around three true, constant y-values
ols.interval(fert.est, xnew = my.mat)

## AI for H0:beta1 = 0.5 and H0:beta2 = 0.5
ols.interval(fert.est, type = "acc", which.coef = c(2,3), q = 0.5)

## AI for H0:beta1 <= 0.5
ols.interval(fert.est, type = "acc", which.coef = 2, dir = "right", q = 0.5)

## PI (Textbook p. 285)
ols.interval(fert.est, type = "pred", xnew = c(x1 = log(29), x2 = log(120)), details = TRUE)

## Three PI
ols.interval(fert.est, type = "pred", xnew = my.mat, details = TRUE)


[Package desk version 1.1.1 Index]