Learn R Programming

carx (version 0.7.1)

outlier.carx: Detect all outliers of a carx object

Description

Detect all outliers of a carx object and update the model if any outlier is detected. It tests for the presence of outliers one at a time, for each time point, adjusted for multiplicity of testing, as described in Wang and Chan (2017).

Usage

# S3 method for carx
outlier(object, outlier.prefix = "OI_", seed = 131)

Arguments

object

a carx object.

outlier.prefix

the prefix used to construct variable name for indicator variables representing the detected outliers, default = "OI_".

seed

the seed for randon number generator, default=NULL.

Value

an updated carx object. If any outlier is detected, its index will be stored in the outlier.indices attribute of the return object, and prefix for variable name is stored in the outlier.prefix attribute. Note that if the original object is fitted through a formula interface, the formula will also be updated.

References

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 {
sigma = 0.6
nObs = 100
dat = carxSimCenTS(nObs=nObs,sigma=sigma,ucl=Inf)
dat$y[as.integer(nObs/2)] = dat$y[as.integer(nObs/2)] + 4*sd(dat$y)
mdl <- carx(y~X1+X2-1,data=dat, p=2, CI.compute = FALSE)
oc = outlier(mdl)
#note the outlier indices in the output:
print(oc)
#note the updated formula:
print(formula(oc))
# }

Run the code above in your browser using DataLab