Learn R Programming

carx (version 0.7.1)

residuals.carx: Residuals of a fitted carx object

Description

Computes the residuals of fitted carx object. When no censoring is present, the ordinary residuals will be computed. Otherwise, the simulated residuals (Gourieroux, Monfort, Renault, and Trognon 1987) of a fitted carx object will be computed, as suggested in Wang and Chan (2017).

Usage

# S3 method for carx
residuals(object, type = c("raw", "pearson"), seed = NULL,
  ...)

Arguments

object

a fitted carx object.

type

a string indicates which type of residual is to be returned. "raw" returns the (simulated) residuals; "pearson" returns the raw residuals divided by estimated standard error of the residuals.

seed

the seed for the random number generator.

...

not used.

Value

the simulated residuals.

Details

The simulated residuals are constructed as follows. First, impute each unobserved \(Y_t^*\) by a (random) realization from the conditional distribution \(D(Y_t^*|\{(Y_s,X_s)\}_{s=1}^t)\), evaluated at the parameter estimate. Then, refit the model with \((Y_t^* , X_t)\) so obtained, via the method of conditional maximum likelihood; the residuals from the latter model are the simulated residuals \(\varepsilon_t\).

References

Gourieroux C, Monfort A, Renault E, Trognon A (1987). "Simulated residuals." Journal of Econometrics, 34(1), 201-252.

Wang C, Chan KS (2017). "Quasi-likelihood estimation of a censored autoregressive model with exogenous variables." Journal of the American Statistical Association. 2017 Mar 20(just-accepted).

Examples

Run this code
# NOT RUN {
dat = carxSim(nObs=100,seed=0)
mdl <- carx(y~X1+X2-1,data=dat, p=2, CI.compute = FALSE)
#compute the raw residuals
res = residuals(mdl,type="raw")
#compute the Pearson residuals
res = residuals(mdl,type="pearson")
# }

Run the code above in your browser using DataLab