Informative plots for Y and Yhat

Share:

Description

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

Usage

1
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".

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.

Value

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

See Also

cor

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# 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)