cochorc: Estimating Linear Models under AR(1) with Cochrane-Orcutt...

View source: R/cochorc.R

cochorcR Documentation

Estimating Linear Models under AR(1) with Cochrane-Orcutt Iteration

Description

If autocorrelated errors can be modeled by an AR(1) process (rho as parameter) then this function performs a Cochrane-Orcutt iteration. If model coefficients and the estimated rho value converge with the number of iterations, this procedure provides valid solutions. The object returned by this command can be plotted using the plot() function.

Usage

cochorc(
  mod,
  data = list(),
  iter = 10,
  tol = 0.0001,
  pwt = TRUE,
  details = FALSE
)

Arguments

mod

estimated linear model object or formula.

data

data frame to be specified if mod is a formula.

iter

maximum number of iterations to be performed.

tol

iterations are carried out until difference in rho values is not larger than tol.

pwt

build first observation using Prais-Whinston transformation. If pwt = FALSE then the first observation is dropped, Default value: pwt = TRUE.

details

logical value, indicating whether details should be printed.

Value

A list object including:

results data frame of iterated regression results.
niter number of iterated regressions performed.
rho.opt rho-value at last iteration performed..
y.trans transformed y-values at last iteration performed.
X.trans transformed x-values (incl. z) at last iteration performed.
resid residuals of transformed model estimation.
all.regs data frame of regression results for all considered rho-values.

References

Cochrane, E. & Orcutt, G.H. (1949): Application of Least Squares Regressions to Relationships Containing Autocorrelated Error Terms. Journal of the American Statistical Association 44, 32-61.

Examples

## In this example only 2 iterations are needed to achieve (convergence of rho at the 5th digit)
sales.est <- ols(sales ~ price, data = data.filter)
cochorc(sales.est)

## For a higher precision we need 6 iterations
cochorc(sales.est, tol = 0.0000000000001)

## Direct usage of a model formula
X <- cochorc(sick ~ jobless, data = data.sick[1:14,], details = TRUE)

## See iterated regression results
X$all.regs

## Print full details
X

## Suppress details
print(X, details = FALSE)

## Plot rho over iterations to see convergence
plot(X)

## Example with interaction
dummy <-  as.numeric(data.sick$year >= 2005)
kstand.str.est <- ols(sick ~ dummy + jobless + dummy*jobless, data = data.sick)
cochorc(kstand.str.est)


desk documentation built on May 29, 2024, 6:05 a.m.

Related to cochorc in desk...