[1] CADFtest.default CADFtest.formula
see '?methods' for accessing help and source code
[[1]]
A single object matching 'CADFtest.default' was found
It was found in the following places
package:CADFtest
registered S3 method for CADFtest from namespace CADFtest
namespace:CADFtest
with value
function (model, X = NULL, type = c("trend", "drift", "none"),
data = list(), max.lag.y = 1, min.lag.X = 0, max.lag.X = 0,
dname = NULL, criterion = c("none", "BIC", "AIC", "HQC",
"MAIC"), ...)
{
if (is.null(dname)) {
dname <- deparse(substitute(model))
}
method <- "CADF test"
y <- model
if (is.null(X))
method <- "ADF test"
type <- match.arg(type)
switch(type, trend = urtype <- "ct", drift = urtype <- "c",
none = urtype <- "nc")
criterion <- match.arg(criterion)
rho2 <- NULL
nX <- 0
if (is.ts(y) == FALSE)
y <- ts(y)
trnd <- ts(1:length(y), start = start(y), frequency = frequency(y))
if (criterion == "none") {
test.results <- estmodel(y = y, X = X, trnd = trnd, type = type,
max.lag.y = max.lag.y, min.lag.X = min.lag.X, max.lag.X = max.lag.X,
dname = dname, criterion = criterion, obs.1 = NULL,
obs.T = NULL, ...)
}
if (criterion != "none") {
all.models <- expand.grid(max.lag.y:0, min.lag.X:0, max.lag.X:0)
models.num <- dim(all.models)[1]
ICmatrix <- matrix(NA, models.num, 7)
max.lag.y <- all.models[1, 1]
min.lag.X <- all.models[1, 2]
max.lag.X <- all.models[1, 3]
interm.res <- estmodel(y = y, X = X, trnd = trnd, type = type,
max.lag.y = max.lag.y, min.lag.X = min.lag.X, max.lag.X = max.lag.X,
dname = dname, criterion = criterion, obs.1 = NULL,
obs.T = NULL, ...)
ICmatrix[1, ] <- c(max.lag.y, min.lag.X, max.lag.X, interm.res$AIC,
interm.res$BIC, interm.res$HQC, interm.res$MAIC)
t.1 <- interm.res$est.model$index[1]
t.T <- interm.res$est.model$index[length(interm.res$est.model$index)]
for (modeln in 2:models.num) {
max.lag.y <- all.models[modeln, 1]
min.lag.X <- all.models[modeln, 2]
max.lag.X <- all.models[modeln, 3]
interm.res <- estmodel(y = y, X = X, trnd = trnd,
type = type, max.lag.y = max.lag.y, min.lag.X = min.lag.X,
max.lag.X = max.lag.X, dname = dname, criterion = criterion,
obs.1 = t.1, obs.T = t.T, ...)
ICmatrix[modeln, ] <- c(max.lag.y, min.lag.X, max.lag.X,
interm.res$AIC, interm.res$BIC, interm.res$HQC,
interm.res$MAIC)
}
if (criterion == "AIC")
selected.model <- which(ICmatrix[, 4] == min(ICmatrix[,
4]))
if (criterion == "BIC")
selected.model <- which(ICmatrix[, 5] == min(ICmatrix[,
5]))
if (criterion == "HQC")
selected.model <- which(ICmatrix[, 6] == min(ICmatrix[,
6]))
if (criterion == "MAIC")
selected.model <- which(ICmatrix[, 7] == min(ICmatrix[,
7]))
if (length(selected.model) > 1)
selected.model <- selected.model[length(selected.model)]
max.lag.y <- ICmatrix[selected.model, 1]
min.lag.X <- ICmatrix[selected.model, 2]
max.lag.X <- ICmatrix[selected.model, 3]
test.results <- estmodel(y = y, X = X, trnd = trnd, type = type,
max.lag.y = max.lag.y, min.lag.X = min.lag.X, max.lag.X = max.lag.X,
dname = dname, criterion = criterion, obs.1 = t.1,
obs.T = t.T, ...)
}
class(test.results) <- c("CADFtest", "htest")
if (is.null(X)) {
names(test.results$statistic) <- paste("ADF(", max.lag.y,
")", sep = "")
}
else {
names(test.results$statistic) <- paste("CADF(", max.lag.y,
",", max.lag.X, ",", min.lag.X, ")", sep = "")
}
test.results$estimate <- c(delta = as.vector(test.results$est.model$coefficients[(2 -
as.numeric(type == "none") + as.numeric(type == "trend"))]))
test.results$null.value <- c(delta = 0)
test.results$alternative <- "less"
test.results$type <- type
return(test.results)
}
<bytecode: 0x00000000559c94a8>
<environment: namespace:CADFtest>
[[2]]
A single object matching 'CADFtest.formula' was found
It was found in the following places
package:CADFtest
registered S3 method for CADFtest from namespace CADFtest
namespace:CADFtest
with value
function (model, X = NULL, type = c("trend", "drift", "none"),
data = list(), max.lag.y = 1, min.lag.X = 0, max.lag.X = 0,
dname = NULL, criterion = c("none", "BIC", "AIC", "HQC",
"MAIC"), ...)
{
if (is.null(dname)) {
dname <- deparse(substitute(model))
}
if ((model[3] == ".()") | (model[3] == "1()")) {
model[3] <- 1
mf <- model.frame(model, data = data)
y <- model.response(mf)
X <- NULL
}
else {
mf <- model.frame(model, data = data)
y <- model.response(mf)
X <- model.matrix(model, data = data)
X <- X[, 2:dim(X)[2]]
}
call <- match.call(CADFtest)
test.results <- CADFtest.default(model = y, X = X, type = type,
max.lag.y = max.lag.y, data = data, min.lag.X = min.lag.X,
max.lag.X = max.lag.X, dname = dname, criterion = criterion,
...)
test.results$call <- call
return(test.results)
}
<bytecode: 0x0000000053565108>
<environment: namespace:CADFtest>
CADFtest | R Documentation |
This function is an interface to CADFtest.default
that computes the CADF unit root test proposed in Hansen (1995). The asymptotic p-values of the test are also computed along the lines proposed in Costantini et al. (2007). Automatic model selection is allowed. A full description and some applications can be found in Lupi (2009).
CADFtest(model, X=NULL, type=c("trend", "drift", "none"), data=list(), max.lag.y=1, min.lag.X=0, max.lag.X=0, dname=NULL, criterion=c("none", "BIC", "AIC", "HQC", "MAIC"), ...)
model
|
a formula of the kind |
X
|
if |
type
|
defines the deterministic kernel used in the test. It accepts the values used in package |
data
|
data to be used (optional). This argument is effective only when |
max.lag.y
|
maximum number of lags allowed for the lagged differences of the variable to be tested. |
min.lag.X
|
if negative it is maximum lead allowed for the covariates. If zero, it is the minimum lag allowed for the covariates. |
max.lag.X
|
maximum lag allowed for the covariates. |
dname
|
NULL or character. It can be used to give a special name to the model. If the NULL default is accepted and the model is specified using a formula notation, then dname is computed according to the used formula. |
criterion
|
it can be either |
…
|
Extra arguments that can be set to use special kernels, prewhitening, etc. in the estimation of ρ^2. A Quadratic kernel with a VAR(1) prewhitening is the default choice. To set these extra arguments to different values, see |
The function returns an object of class c(“CADFtest”, “htest”)
containing:
statistic
|
the t test statistic. |
parameter
|
the estimated nuisance parameter ρ^2 (see Hansen, 1995, p. 1150). |
method
|
the test performed: it can be either |
p.value
|
the p-value of the test. |
data.name
|
the data name. |
max.lag.y
|
the maximum lag of the differences of the dependent variable. |
min.lag.X
|
the maximum lead of the stationary covariate(s). |
max.lag.X
|
the maximum lag of the stationary covariate(s). |
AIC
|
the value of the AIC for the selected model. |
BIC
|
the value of the BIC for the selected model. |
HQC
|
the value of the HQC for the selected model. |
MAIC
|
the value of the MAIC for the selected model. |
est.model
|
the estimated model. |
estimate
|
the estimated value of the parameter of the lagged dependent variable. |
null.value
|
the value of the parameter of the lagged dependent variable under the null. |
alternative
|
the alternative hypothesis. |
call
|
the call to the function. |
type
|
the deterministic kernel used. |
Claudio Lupi
Costantini M, Lupi C, Popp S (2007). A Panel-CADF Test for Unit Roots, University of Molise, Economics & Statistics Discussion Paper 39/07. http://econpapers.repec.org/paper/molecsdps/esdp07039.htm
Hansen BE (1995). Rethinking the Univariate Approach to Unit Root Testing: Using Covariates to Increase Power, Econometric Theory, 11(5), 1148–1171.
Lupi C (2009). Unit Root CADF Testing with R, Journal of Statistical Software, 32(2), 1–19. http://www.jstatsoft.org/v32/i02/
Zeileis A (2004). Econometric Computing with HC and HAC Covariance Matrix Estimators, Journal of Statistical Software, 11(10), 1–17. http://www.jstatsoft.org/v11/i10/
Zeileis A (2006). Object-Oriented Computation of Sandwich Estimators, Journal of Statistical Software, 16(9), 1–16. http://www.jstatsoft.org/v16/i09/.
fUnitRoots
, urca
##---- ADF test on extended Nelson-Plosser data ---- ##-- Data taken from package urca data(npext, package="urca") ADFt <- CADFtest(npext$gnpperca, max.lag.y=3, type="trend") ##---- CADF test on extended Nelson-Plosser data ---- data(npext, package="urca") npext$unemrate <- exp(npext$unemploy) # compute unemployment rate L <- ts(npext, start=1860) # time series of levels D <- diff(L) # time series of diffs S <- window(ts.intersect(L,D), start=1909) # select same sample as Hansen's CADFt <- CADFtest(L.gnpperca~D.unemrate, data=S, max.lag.y=3, kernel="Parzen", prewhite=FALSE)