Learn R Programming

expandFunctions (version 0.1.0)

Ydiagnostics: Informative plots for Y and Yhat

Description

This function presents diagnostic plots of estimate Yhat and response Y.

Usage

Ydiagnostics(Y, Yhat, ...)

Arguments

Y
R object representing response, coercible to a vector.
Yhat
R object representing estimate, coercible to a vector. The length of Y and Yhat must be equal.
...
Options for cor function. The defaults are use = "everything" and method = "pearson".

Value

Invisibly returns TRUE; this routine is only used for its graphical side effects described in Details.

Details

The plots shown are:

  • Y vs Yhat. Under a perfect noise-free fitting, this would be a straight line with the points lined up on the red line, and the correlation wpuld be 1.0000.
  • Y, Yhat and Y-Yhat (residual) time domain plots. The time steps are in samples.
  • These show the ACF for the original Y, the residual, and |residual|. The latter helps identify nonlinearity in the residual.

See Also

cor

Examples

Run this code
# The order here looks backwards, but is chosen to
# simulate a typical pair - Yhat will normally have
# a smaller range than Y.
set.seed(2)
nObs <- 100 # Number of observations
x <- stats::filter(rnorm(nObs),c(-0.99),
     method="recursive")
x <- x + (x^2) # Nonlinear component
myLags <- 0:2
X <- eTrim(eLag(x,myLags))
Y <- X[,+1,drop=FALSE]
X <- X[,-1,drop=FALSE]
lmObj <- lm(Y ~ X)
Yhat <- predict(lmObj)
Ydiagnostics(Y,Yhat)

Run the code above in your browser using DataLab