Type: Package
Title: Unit Root Tests with Structural Breaks and Fully-Modified Estimators
Version: 0.0.1
Date: 2025-09-03
Author: Ho Tsung-wu [aut, cre]
Maintainer: Ho Tsung-wu <tsungwu@ntnu.edu.tw>
Description: Procedures include Phillips (1995) FMVAR <doi:10.2307/2171721>, Kitamura and Phillips (1997) FMGMM <doi:10.1016/S0304-4076(97)00004-3>, and Park (1992) CCR <doi:10.2307/2951679>, and so on. Tests with 1 or 2 structural breaks include Gregory and Hansen (1996) <doi:10.1016/0304-4076(69)41685-7>, Zivot and Andrews (1992) <doi:10.2307/1391541>, and Kurozumi (2002) <doi:10.1016/S0304-4076(01)00106-3>.
Encoding: UTF-8
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
LazyData: TRUE
LazyLoad: yes
Depends: R (≥ 3.5)
Imports: timeSeries
Suggests: cointReg, forecast, timeDate, urca, zoo
NeedsCompilation: no
Packaged: 2025-09-02 23:18:31 UTC; badal
Repository: CRAN
Date/Publication: 2025-09-08 19:10:14 UTC

Bartlett Kernel for Consistent Estimate of Long-run Variance

Description

Compute the Bartlett kernel to obtain consistent estimate of long-run variance,univariate time series only.

Usage

 Bartlett_uni(e,v)

Arguments

e

A univariate time series for computing consistent long-run variance, normally, regression residuals.

v

Number of lag terms used to compute the long-run variance.

Value

Return the consistent estimate of long-run variance, that PP and KPSS tests require. This procedure handles single time series only.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Brillinger, David R. (1981) Time Series Data Analysis and Theory. San Francisco, CA: Holden-Day.

Examples

data(macro)
y=macro[,"INF"]
e=y-mean(y)
Bartlett_uni(e,v=15)

Phillips' (1987) Za and Zt test for cointegration

Description

Test the null hypothesis of no cointegration between y and x using Phillips' (1987) Za and Zt statistics and Phillips and Ouliaris (1990) limit theory.

Usage

CZa(y,x,p=1,v=15)

Arguments

y

The data of dependent variable in a regression.

x

The data of independent variables in a regression.

p

Order of the time polynomial in the cointegrating regressio. Critical values are available for p within [1,5].
p =-1: No deterministic term in the cointegrating regression.
p = 0: For a constant term.
p = 1: For a constant term and trend. Default.
P > 2: For time polynomial.

v

Number of autocovariance terms to compute the spectrum at frequency zero, default=15.

Value

alpha

Estimate of the AR(1) coefficient.

cza

Za statistic for non-cointegration.Reject the null hypothesis of no cointegration if the Z statistic < critical value.

cza_cv

Critical values of cza.

czt

Zt statistic for non-cointegration.Reject the null hypothesis of no cointegration if the Z statistic < critical value.

czt_cv

Critical values of czt.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Phillips, P. C. B. (1987) Time Series Regression with a Unit Root. Econometrica, 55, 277-301.
Phillips, P. C. B. and Ouliaris S. (1990) Asymptotic Properties of Residual Based Tests for Cointegration. Econometrica, 58, 165-193.

Examples


data(macro)
y=macro[,1]
x=macro[,-1]
CZa(y,x,p=1,v=10)



Gregory-Hansen Test for Cointegration in Models with Regime Shifts

Description

Conduct the cointegration analysis with regime shifts, proposed by Gregory-Hansen (1996A).

Usage

GHansen(y, x, model,trim=0.1, use=c("nw","ba"))

Arguments

y

The data of dependent variable in a regression.

x

The data of independent variables in a regression.

model

Models for the structural breaks:
1 = C (level shift);
2 = C/T (level shift with trend);
3 = C/S (regime shift);
4 = regime and trend shift.

trim

The trimming percentage. Default is 10 percent.

use

Conditions for pp test for the nonstationarity of regression residuals.

Details

This function calculates three residual-based test for cointegration with regime shifts: ADF, and Za, Zt of pp. Argument use is detailed by the example of pp documentation.

Value

result

Comprehensive results of three tests.

teststat

Time series of three sequential tests.

test.reg.adf

Final regression output for ADF test.

test.reg.za

Final regression output for Za test.

test.reg.zt

Final regression output for Zt test.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Gregory, A.W. and Hansen, B. E. (1996A) Residual-based tests for cointegration in models with regime shifts.Journal of Econometrics, 70, 99-126.
Gregory, A.W. and Hansen, B. E.(1996B). Tests for Cointegration in Models with Regime and Trend Shifts. Oxford Bulletin Economics and Statistics, 58(3), 555-560.

Examples


data(macro)
y=macro[1:300,1]
x=macro[1:300,-1]
output=GHansen(y,x,model=1, use=c("nw","ba"))
output$result
summary(output$test.reg.adf)
head(output$teststat)

#Plotting

test.name=rownames(output$result)[1]
stat=output$teststat[,test.name]
CV=output$result[test.name,1:3]
bpoint=output$result[test.name,5]
main=paste(paste(unlist(strsplit(test.name,"_")),collapse = " "),"test")

plot(stat,main=main,ylab="",xlab="",ylim=range(c(max(stat)+3,min(stat)-1,CV)));grid()
  abline(h=CV[1],col="red")
  abline(h=CV[2],col="blue")
  abline(h=CV[3],col="seagreen")
  abline(v=as.POSIXct(time(y)[bpoint]),col="orange",lty=2)

#  legend(x=as.POSIXct("2010-01-01"), y=max(stat)+3, legend=c("1% cv" , "5% cv", "10% cv"),
#         col=c("red", "blue", "seagreen"),xjust=1, yjust=1, lty=1,
#         horiz=TRUE, cex=0.66, bty="n")



#plot(y,main=colnames(y),ylab="",xlab="");grid()
#abline(v=time(y[output$bpoint,]),col="orange",lty=2)



Bartlett Kernel for Consistent Estimate of Long-run Variance

Description

Compute the Bartlett kernel proposed by Kurozumi (2002) to obtains consistent estimate of long-run variance.

Usage

Kurozumi_Bartlett(e)

Arguments

e

data that needs to compute consistent long-run variance, normally, regression residuals

Value

Return the consistent estimate of long-run variance, Bartlett kernel proposed by Kurozumi (2002).

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Kurozumi, E. (2002) Testing for stationarity with a break. Journal of Econometrics,108(1), 105-127.

Examples

data(macro)
y=macro[,"INF"]
e=y-mean(y)
Kurozumi_Bartlett(e)

Quadratic Spectral Kernel for Consistent Estimate of Long-run Variance

Description

Compute the Quadratic Spectral kernel proposed by Kurozumi (2002) to obtains consistent estimate of long-run variance.

Usage

Kurozumi_QS(e)

Arguments

e

data that needs to compute consistent long-run variance, normally, regression residuals.

Value

Return the consistent estimate of long-run variance, Quadratic Spectral kernel proposed by Kurozumi (2002).

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Kurozumi, E. (2002) Testing for stationarity with a break. Journal of Econometrics,108(1), 105-127.

Examples

data(macro)
y=macro[,"INF"]
e=y-mean(y)
Kurozumi_QS(e)

Parzen Kernel for Consistent Estimate of Long-run Variance

Description

Compute the Parzen kernel to obtain consistent estimate of long-run variance.

Usage

Parzen_uni(e,v)

Arguments

e

A univariate time series for computing consistent long-run variance, normally, regression residuals.

v

Number of lag terms used to compute the long-run variance.

Value

Return the consistent estimate of long-run variance, that PP and KPSS tests require. This procedure handles single time series only.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Brillinger, David R. (1981) Time Series Data Analysis and Theory. San Francisco, CA: Holden-Day.

Examples

data(macro)
y=macro[,"INF"]
e=y-mean(y)
Parzen_uni(e,v=15)

Quadratic Spectral Kernel for Consistent Estimate of Long-run Variance

Description

Compute the QS kernel to obtain consistent estimate of long-run variance.

Usage

QS_uni(e,v)

Arguments

e

A univariate time series for computing consistent long-run variance, normally, regression residuals.

v

Number of lag terms used to compute the long-run variance.

Value

Return the consistent estimate of long-run variance, that PP and KPSS tests require. This procedure handles single time series only.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Brillinger, David R. (1981) Time Series Data Analysis and Theory. San Francisco, CA: Holden-Day.

Examples

data(macro)
y=macro[,"INF"]
e=y-mean(y)
QS_uni(e,v=15)

Bartlett Kernel for Consistent Estimate of Long-run Variance

Description

Compute the Bartlett kernel proposed by Sul, Phillips and Choi (2003) to obtains consistent estimate of long-run variance.

Usage


SPC_Bartlett(e,v)

Arguments

e

data that needs to compute consistent long-run variance, normally, regression residuals.

v

Number of lag terms to use when computing the long-run variance.

Value

Return the consistent estimate of long-run variance, Bartlett kernel proposed by Sul, Phillips and Choi (2003) .

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Carrion-i-Silvestre, J. L. and Sanso, A. (2006) A guide to the computation of stationarity tests.Empirical Economics, 31(2), 433-448.
Carrion-i-Silvestre, J. L. and Sanso, A. (2007) The KPSS test with two structural breaks. Spanish Economic Review, 9(2), 105-127.
Sul, D., Phillips, P.C.B., and Choi, C.Y.(2005) Prewhitening Bias in HAC Estimation. Oxford Bulletin of Economics and Statistics, 67(4), 517-546.

Examples

data(macro)
y=macro[,"INF"]
e=y-mean(y)
SPC_Bartlett(e,v=15)

Quadratic Spectral Kernel for Consistent Estimate of Long-run Variance

Description

Compute the Quadratic Spectral kernel of Sul, Phillips and Choi (2003) to obtains consistent estimate of long-run variance.

Usage


SPC_QS(e,v)

Arguments

e

data that needs to compute consistent long-run variance, normally, regression residuals.

v

Number of lag terms to use when computing the long-run variance.

Value

Return the consistent estimate of long-run variance.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Carrion-i-Silvestre, J. L. and Sanso, A. (2006) A guide to the computation of stationarity tests.Empirical Economics, 31(2), 433-448.
Carrion-i-Silvestre, J. L. and Sanso, A. (2007) The KPSS test with two structural breaks. Spanish Economic Review, 9(2), 105-127.
Sul, D., Phillips, P.C.B., and Choi, C.Y.(2005) Prewhitening Bias in HAC Estimation. Oxford Bulletin of Economics and Statistics, 67(4), 517-546.

Examples

data(macro)
y=macro[,"INF"]
e=y-mean(y)
SPC_QS(e,v=15)

Zivot-Andrews unit root test with unknown one structural break.

Description

This function implements Zivot-Andrews sequential ADF unit root test with unknown one structural break. Handling two outlier models: "Innovational outlier" and "Additive outlier".

Usage

ZA_1br(y,
      model=c("intercept", "trend", "both"),
      outlier=1,
      pmax=8,
      ic=c("AIC","BIC"),
      fixed=FALSE,
      trim=0.1,
      eq=1,
      season=FALSE)

Arguments

y

Univariate time series data, a preferable format is ts when season=TRUE.

model

Modelling where the unknown structural change occurs.
intercept= structural change occurs at the intercept.
trend= structural change occurs at the trend.
both= structural changes occur at both the intercept and the trend.

outlier

The outlier model.
1=Innovational outlier model.
2=Additive outlier model.

pmax

The maximal lags that are either included in the test regression or lag selection searches its optimal lag via "ic".

ic

Information criteria, "AIC" or "BIC". The default is "AIC".

fixed

Logical. If TURE, pmax is the fixed inputed lags. If FALSE, pmax is the maximal lags where lag selection searches its optimal lag.

trim

The trimming percentage. Default is 10

eq

The type of dependent variable in ADF equation.
1= original y. 2= differenced y.

season

Logical. If TURE,then seasonal dummies will be included in the test regression.

Value

teststat

The Zivot-Andrews test statistic, which is the min(tstats).

cval

The critical values that are tabulated in Zivot and Andrews(1992)

p

The number of lags that are included in the test regression.

bpoint

The breaking point that corresponds to the teststat.

tstats

The sequential ADF test statistic.

testreg

The lm() output that corresponds to teststat.

timeElapse

Time elapsed for sequential search.

Note

This code modifies function ur.za of package urca. We add "season", "eq", "outlier",and "trim". Specifically, "outlier" is crucial, "season" is left to advanced research.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Zivot,E. and Andrews, W.K. (1992) Further Evidence on the Great Crasch, the Oil-Price Shock, and the Unit-Root Hypothesis. Journal of Business & Economic Statistics,10(3), 251-270.

Examples

data(macro) #US inflation rate, 1958M1-2025M7
y=macro[1:200,"INF"]
za1=ZA_1br(y,
           ic=c("AIC","BIC")[2],
           outlier=1,
           pmax=8,
           fixed=TRUE,
           model=c("intercept","trend","both")[1],
           trim=0.01,
           eq=1,
           season=TRUE)
za1$timeElapse[3]
za1$teststat
za1$cval
y[za1$bpoint,]
za1$tstats
za1$p

#plotting
plot.ts(za1$tstats,ylim=range(c(za1$tstats,za1$cval)))
abline(h=za1$cval[1],col="red")
abline(h=za1$cval[2],col="blue")
abline(h=za1$cval[3],col="green")
abline(v=za1$bpoint,col="red",lty=2)



Zivot-Andrews unit root test with unknown one structural break.

Description

This function implements Zivot-Andrews sequential ADF unit root test with one unknown structural break. Handling two outlier models: "Innovational outlier" and "Additive outlier".

Usage

ZA_2br(y,
      model=c("intercept", "both"),
      pmax=8,
      ic=c("AIC","BIC"),
      fixed=TRUE,
      trim=0.1,
      eq=1,
      trace=TRUE,
      season=FALSE)

Arguments

y

Univariate time series data, a preferable format is ts when "season=TRUE".

model

Modelling where the unknown structural change occurs.
intercept= structural change occurs at the intercept.
trend= structural change occurs at the trend.
both= structural changes occur at both the intercept and the trend.

pmax

The maximal lags that are either included in the test regression or lag selection searches its optimal lag via "ic".

ic

Information criteria, "AIC" or "BIC". The default is "AIC".

fixed

Logical. If TURE, pmax is the fixed inputed lags, and the default is TRUE.
If FALSE, pmax is the maximal lags where lag selection searches its optimal lag.

trim

The trimming percentage. Default is 10

eq

The type of dependent variable in ADF equation.
1= original y.
2= differenced y.

trace

Logical. If TURE, then screen displays the sequential progress.

season

Logical. If TURE,then seasonal dummies will be included in the test regression, and y must be in ts format.

Details

This code entends Zivot-Andrews (1992) sequential procedure to two unknown structural changes. Critical values are from Narayan and Popp (2010).

Value

teststat

The ADF test statistic in the presence of two structural breaks.

cval

The critical values that are tabulated in Narayan and Popp (2010).

p

The number of lags that are included in the test regression.

bpoint1

The first breaking point that corresponds to the teststat.

bpoint2

The second breaking point that corresponds to the teststat.

timeElapse

Time elapsed for sequential search.

Note

This code modifies function ur.za of package urca. We add "season", "eq", "outlier",and "trim". Specifically, "outlier" is crucial, "season" is left to advanced research.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Narayan, P. K. and Popp, S. (2010) A new unit root test with two structural breaks in level and slope at unknown time. Journal of Applied Statistics,37, 1425-1438.

Zivot,E. and Andrews, W.K. (1992),Further Evidence on the Great Crasch, the Oil-Price Shock, and the Unit-Root Hypothesis. Journal of Business & Economic Statistics,10(3), 251-270.

Examples

data(macro) # US macro data, 1967M1-2025M7
# It takes time

y=macro[1:200,"INF"]
za2=ZA_2br(y,
           ic=c("AIC","BIC")[2],
           pmax=8,
           fixed=TRUE,
           model=c("intercept","trend","both")[1],
           trim=0.1,
           eq=1,
           season=TRUE)
za2$timeElapse[3]/60
za2$teststat
za2$cval
y[za2$bpoint1,] #The first dated strictural change
y[za2$bpoint2,] #The second dated strictural change


Phillips' (1987) Za and Zt Test for Unit Root

Description

Compute Phillips' (1987) Za and Zt statistics for the null hypothesis that y has a unit root.

Usage

Za(y,p=1,v=15,ker_fun="parzen",aband=0,filter=0)

Arguments

y

The data of dependent variable in a regression.

p

Order of the time polynomial in the cointegrating regressio.
p =-1: No deterministic term in the cointegrating regression.
p = 0: For a constant term.
p = 1: For a constant term and trend. Default.
P > 2: For time polynomial.
Critical values are available for p within [1,5].

v

Number of autocovariance terms to compute the spectrum at frequency zero, default=15.

ker_fun

Set kernel function to one of the available kernels, default="parzen". See section details below.

aband

Whether to activate the automatic bandwidth selection.
aband=1. To activate.
aband=0. Do not activate.The default.

filter

Whether to use an AR(1) filter to compute the spectrum at frequency zero.
filter=1. To use.
filter=0. Do not use. The default.

Value

alpha

Estimate of the AR(1) coefficient.

za

Za statistic for the series under the null has a unit root. Reject the null hypothesis of a unit root if the test statistic < critical value.

za_cv

Critical values of Za.

zt

Zt statistic for the series under the null has a unit root. Reject the null hypothesis of a unit root if the test statistic < critical value.

zt_cv

Critical values of Zt.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Ouliaris, S., J. Y. Park, and P. C. B. Phillips (1989) Testing for a Unit Root in the Presence of a Maintained Trend. Ch. 1 in Baldev Raj (ed.), Advances in Econometrics and Modelling. Netherlands: Kluwer Academic Publishers.
Phillips, P. C. B. (1987) Time Series Regression with a Unit Root. Econometrica, 55, 277-301.

Examples


data(macro)
y=macro[,1]
Za(y,p=1,v=10)


Bartlett Kernel for Consistent Estimate of Long-run Variance

Description

Compute the Bartlett kernel to obtain consistent estimate of long-run variance of multivariate time series.

Usage

bartlett(data,v)

Arguments

data

Data matrix for computing consistent long-run variance, normally, multivariate regression residuals.

v

Number of autocovariance terms in the kernel.

Value

Return the consistent estimate of long-run variance. This procedure handles both multivariate and single time series, which is basically designed for "fmvar","fmgmm" and "fmols".

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Brillinger, David R. (1981) Time Series Data Analysis and Theory. San Francisco, CA: Holden-Day.

Examples

data(macro)
e=apply(macro, 2, function(x) x-mean(x))
bartlett(e,v=15)

Bohman Kernel for Consistent Estimate of Long-run Variance

Description

Computes the Bohman window to obtain consistent estimate of long-run variance of multivariate time series.

Usage

bohman(data,v)

Arguments

data

Data matrix for computing consistent long-run variance, normally, multivariate regression residuals.

v

Number of autocovariance terms in the kernel.

Value

Return the consistent estimate of long-run variance. This procedure handles both multivariate and single time series, which is basically designed for "fmvar","fmgmm" and "fmols".

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Brillinger, David R. (1981) Time Series Data Analysis and Theory. San Francisco, CA: Holden-Day.

Examples

data(macro)
e=apply(macro, 2, function(x) x-mean(x))
bohman(e,v=15)

Cauchy Kernel for Consistent Estimate of Long-run Variance

Description

Compute the Cauchy window to obtain consistent estimate of long-run variance of multivariate time series.

Usage

cauchy(data,v)

Arguments

data

Data matrix for computing consistent long-run variance, normally, multivariate regression residuals.

v

Number of autocovariance terms in the kernel.

Value

Return the consistent estimate of long-run variance. This procedure handles both multivariate and single time series, which is basically designed for "fmvar","fmgmm" and "fmols".

Author(s)

Ho Tsung-wu

References

Brillinger, David R. (1981) Time Series Data Analysis and Theory. San Francisco, CA: Holden-Day.

Examples

data(macro)
e=apply(macro, 2, function(x) x-mean(x))
cauchy(e,v=15)

Canonical Cointegrating Regression Estimator

Description

Computes Park's (1992) Canonical Cointegrating Regression estimator for cointegrated regression models, using OLS for the first stage regression.

Usage

ccr(y,x,type=c("const","trend","season","all"),
    v=15,ker_fun="parzen",aband=0,filter=0)

Arguments

y

The data of dependent variable in a regression.

x

The data of independent variables in a regression.

type

The deterministic parts in the regression.
const = intercept;
trend = lnear trend;
season = seasonal dummies, this option requires ts format;
all = all three options, which requires ts format.

v

Number of autocovariance terms to compute the spectrum at frequency zero, default=15.

ker_fun

Set kernel function to one of the available kernels, default="parzen". See section details below.

aband

Whether to activate the automatic bandwidth selection.
aband=1. To activate.
aband=0. Do not activate.The default.

filter

Whether to use an AR(1) filter to compute the spectrum at frequency zero.
filter=1. To use.
filter=0. Do not use.The default.

Details

1. Available kernels. Technical details are referred to Brillinger (1981,P.55)
"parzen"=Parzen kernel
"bartlett"=Bartlett kernel
"dchlet"= Dirichlet kernel
"mdchlet"= Modified Dirichlet kernel
"tukham"=Tukey-Hamming kernel
"tukhan"=Tukey-Hanning kernel
"cauchy"=Cauchy kernel
"bohman"=Bohman kernel
"reisz"=Riesz,Bochner kernel
"gw"= Gauss-Weierstrass kernel
"qs"= Andrews (1991) Quadratic-Spectral

These kernels are written for ccr procedures, technically different from those used in pp and kpss tests.

2. Andrews (1991) has developed data based (or automatic) bandwidth procedures for computing the spectrum. COINT implements these procedures for the Parzen, Bartlette, Tukey-Hamming, and the Quadratic-Spectral kernels. When aband is active, COINT ignores the value you specify for the band-width parameter and automatically substitutes the data-based value.
3. The aim of the AR(1) filter is to flatten the spectrum of residual around the zero frequency, thereby making it easier to estimate the true spectrum by simple averaging of the periodogram.

Value

coefTable

Coefficients table.

vcov

Variance-covariance matrix for the parameter estimates.

sigma

Standard error of the residuals.

rss

Residual sum of squares.

fit

The fitted values, or conditional mean, of the regression.

resid

Estimated residuals.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Park, J. Y. (1992) Canonical Cointegrating Regressions. Econometrica, 60, 119-144.

Examples


data(macro)
y=macro[,1]
x=macro[,-1]
out=ccr(y,x,type=c("const","trend","season","all")[2],v=15,ker_fun="bartlett")
out$coefTable
out$vcov
tail(out$fit)
tail(out$resid)


Canonical Cointegrating Regression with Time Polynomial

Description

Computes Park's (1992) canonical cointegrating regression estimator for cointegrated regressions with time polynomial, using OLS for the first stage regression.

Usage

ccrQ(y,
      x,
      type=c("trend","all"),
      v=15,
      q=2,
      ker_fun="parzen",
      aband=0,
      filter=0)

Arguments

y

The data of dependent variable in a regression.

x

The data of independent variables in a regression.

type

The deterministic parts in the regression.
const = intercept;
trend = lnear trend;
season = seasonal dummies, this option requires ts format;
all = all three options, which requires ts format.

v

Number of autocovariance terms to compute the spectrum at frequency zero, default=15.

q

degree of time polynomial, default=2.

ker_fun

Set kernel function to one of the available kernels, default="parzen". See section details below.

aband

Whether to activate the automatic bandwidth selection.
aband=1. To activate.
aband=0. Do not activate.The default.

filter

Whether to use an AR(1) filter to compute the spectrum at frequency zero.
filter=1. To use.
filter=0. Do not use.The default.

Details

1. Available kernels. Technical details are referred to Brillinger (1981,P.55)
"parzen"=Parzen kernel
"bartlett"=Bartlett kernel
"dchlet"= Dirichlet kernel
"mdchlet"= Modified Dirichlet kernel
"tukham"=Tukey-Hamming kernel
"tukhan"=Tukey-Hanning kernel
"cauchy"=Cauchy kernel
"bohman"=Bohman kernel
"reisz"=Riesz,Bochner kernel
"gw"= Gauss-Weierstrass kernel
"qs"= Andrews (1991) Quadratic-Spectral

These kernels are written for ccrQ procedures, technically different from those used in pp and kpss tests.

2. Andrews (1991) has developed data based (or automatic) bandwidth procedures for computing the spectrum. COINT implements these procedures for the Parzen, Bartlette, Tukey-Hamming, and the Quadratic-Spectral kernels. When aband is active, COINT ignores the value you specify for the band-width parameter and automatically substitutes the data-based value.
3. The aim of the AR(1) filter is to flatten the spectrum of residual around the zero frequency, thereby making it easier to estimate the true spectrum by simple averaging of the periodogram.

Value

coefTable

Coefficients table.

vcov

Variance-covariance matrix for the parameter estimates.

sigma

Standard error of the residuals.

rss

Residual sum of squares.

fit

The fitted values, or conditional mean, of the regression.

resid

Estimated residuals.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Park, J. Y. (1992) Canonical Cointegrating Regressions. Econometrica, 60, 119-144.

Examples


data(macro)
y=macro[,1]
x=macro[,-1]
out=ccrQ(y,x,q=3,type=c("trend","all")[1],v=15,ker_fun="parzen")
out$coefTable
out$vcov
tail(out$fit)
tail(out$resid)

Macroeconomic Time Series Data Sets, 1967M1-2025M7

Description

macro contains monthly observations from 1967M1 to 2025M7 for the unemployment rate (the dependent variable), IC (Initial Claims of unemployment insurance), inflation rate (seasonal growth rate of CPI), industrial growth (seasonal growth rate of the industrial production index).r

Usage

data(macro)

Value

macro is an object of class timeSeries.


Dirichlet Kernel for Consistent Estimate of Long-run Variance

Description

Computes the Dirichlet window to obtain consistent estimate of long-run variance of multivariate time series.

Usage

dchlet(data,v)

Arguments

data

Data matrix for computing consistent long-run variance, normally, multivariate regression residuals.

v

Number of autocovariance terms in the kernel.

Value

Return the consistent estimate of long-run variance. This procedure handles both multivariate and single time series, which is basically designed for "fmvar","fmgmm" and "fmols".

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Brillinger, David R. (1981) Time Series Data Analysis and Theory. San Francisco, CA: Holden-Day.

Examples

data(macro)
e=apply(macro, 2, function(x) x-mean(x))
dchlet(e,v=15)

Fully-Modified OLS Estimator

Description

Computes the Phillips-Hansen (1990) Fully-Modified estimator for cointegrated regressions, using OLS for the first stage regression.

Usage

fm(y,
    x,
    type=c("const","trend","season","all"),
    v=15,
    ker_fun="parzen",
    aband=0,
    filter=0,
    sb_start=0.15)

Arguments

y

The data of dependent variable in a regression.

x

The data of independent variables in a regression.

type

The deterministic parts in the regression.
const = intercept;
trend = lnear trend;
season = seasonal dummies, this option requires ts format;
all = all three options, which requires ts format.

v

Number of autocovariance terms to compute the spectrum at frequency zero, default=15.

ker_fun

Set kernel function to one of the available kernels, default="parzen". See section details below.

aband

Whether to use the automatic bandwidth selection.
aband=1. To use.
aband=0. Do not use.The default.

filter

Whether to activate an AR(1) filter to compute the spectrum at frequency zero.
filter=1. To activate.
filter=0. Do not activate.The default.

sb_start

The percentage specifies the beginning of sub-sample for stability test, and the end sample is (1-sb_start).

Details

1. Available kernels. Technical details are referred to Brillinger (1981,P.55)
"parzen"=Parzen kernel
"bartlett"=Bartlett kernel
"dchlet"= Dirichlet kernel
"mdchlet"= Modified Dirichlet kernel
"tukham"=Tukey-Hamming kernel
"tukhan"=Tukey-Hanning kernel
"cauchy"=Cauchy kernel
"bohman"=Bohman kernel
"reisz"=Riesz,Bochner kernel
"gw"= Gauss-Weierstrass kernel
"qs"= Andrews (1991) Quadratic-Spectral

These kernels are written for FM procedures, technically different from those used in pp and kpss tests.

2. Andrews (1991) has developed data based (or automatic) bandwidth procedures for computing the spectrum. COINT implements these procedures for the Parzen, Bartlette, Tukey-Hamming, and the Quadratic-Spectral kernels. When aband is active, COINT ignores the value you specify for the band-width parameter and automatically substitutes the data-based value.
3. The aim of the AR(1) filter is to flatten the spectrum of residual around the zero frequency, thereby making it easier to estimate the true spectrum by simple averaging of the periodogram.

Value

coefTable

Coefficients table.

vcov

Variance-covariance matrix for the parameter estimates.

sigma

Standard error of the residuals.

rss

Residual sum of squares.

fit

The fitted values, or conditional mean, of the regression.

stests

3x1 vector containing Hansen's (1992) Lc, MeanF, and SupF (in this order) statistics for testing the null hypothesis that the cointegrating vector is stable over the sample period.

resid

Estimated residuals.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Andrews, D. W. K. (1991) Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Estimation.Econometrica, 59: 817-858.

Brillinger, David R. (1981) Time Series Data Analysis and Theory. San Francisco, CA: Holden-Day.

Hansen, B. E. (1992) Tests for Parameter Instability in Regressions with I(1) Processes. Journal of Business and Economic Statistics, 10, 321-335.

Phillips, P. C. B. and Hansen B. E.(1990) Statistical Inference in Instrumental Variables Regression with I(1) Processes. Review of Economic Studies, 57, 99-125.

Examples


data(macro)
y=macro[,1]
x=macro[,-1]
out=fm(y,x,type=c("const","trend","season","all")[2],v=15,ker_fun="parzen")
out$coefTable
out$vcov
out$stests
tail(out$fit)
tail(out$resid)




Fully-Modified OLS Estimator with Time Polynomial

Description

Computes the Phillips-Hansen (1990) Fully-Modified estimator for cointegrated regressions with Time Polynomial, using OLS for the first stage regression.

Usage

fmQ(y,x,type=c("trend","all"),v=15,
    q=2, ker_fun="parzen",aband=0,filter=0,sb_start=0.15)

Arguments

y

The data of dependent variable in a regression.

x

The data of independent variables in a regression.

type

The deterministic parts in the regression.
trend = lnear trend;
all = all three options, which requires ts format.

v

Number of autocovariance terms to compute the spectrum at frequency zero, default=15.

q

degree of time polynomial, default=2.

ker_fun

Set kernel function to one of the available kernels, default="parzen". See section details below.

aband

Whether to activate the automatic bandwidth selection.
aband=1. To activate.
aband=0. Do not activate.The default.

filter

Whether to use an AR(1) filter to compute the spectrum at frequency zero.
filter=1. To use.
filter=0. Do not use. The default.

sb_start

The percentage specifies the beginning of sub-sample for stability test, and the end sample is (1-sb_start).

Details

1. Available kernels. Technical details are referred to Brillinger (1981,P.55)
"parzen"=Parzen kernel
"bartlett"=Bartlett kernel
"dchlet"= Dirichlet kernel
"mdchlet"= Modified Dirichlet kernel
"tukham"=Tukey-Hamming kernel
"tukhan"=Tukey-Hanning kernel
"cauchy"=Cauchy kernel
"bohman"=Bohman kernel
"reisz"=Riesz,Bochner kernel
"gw"= Gauss-Weierstrass kernel
"qs"= Andrews (1991) Quadratic-Spectral

These kernels are written for fmQ procedures, technically different from those used in pp and kpss tests.

2. Andrews (1991) has developed data based (or automatic) bandwidth procedures for computing the spectrum. COINT implements these procedures for the Parzen, Bartlette, Tukey-Hamming, and the Quadratic-Spectral kernels. When aband is active, COINT ignores the value you specify for the band-width parameter and automatically substitutes the data-based value.
3. The aim of the AR(1) filter is to flatten the spectrum of residual around the zero frequency, thereby making it easier to estimate the true spectrum by simple averaging of the periodogram.

Value

coefTable

Coefficients table.

vcov

Variance-covariance matrix for the parameter estimates.

sigma

Standard error of the residuals.

rss

Residual sum of squares.

fit

The fitted values, or conditional mean, of the regression.

resid

Estimated residuals.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Andrews, D. W. K. (1991) Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Estimation.Econometrica, 59: 817-858.
Brillinger, David R. (1981) Time Series Data Analysis and Theory. San Francisco, CA: Holden-Day.
Hansen, B. E. (1992) Tests for Parameter Instability in Regressions with I(1) Processes. Journal of Business and Economic Statistics, 10, 321-335.
Phillips, P. C. B. and Hansen B. E.(1990) Statistical Inference in Instrumental Variables Regression with I(1) Processes. Review of Economic Studies, 57, 99-125.

Examples


data(macro)
y=macro[,1]
x=macro[,-1]
out=fmQ(y,x,type=c("trend","all")[1],v=15,q=3,ker_fun="parzen")
out$coefTable
out$vcov
out$stests
tail(out$fit)
tail(out$resid)



Fully-Modified GMM Estimator

Description

Computes the Kitamura-Phillips (1997) Fully-Modified GMM estimator for single equation and multivariate cointegrated regression models.

Usage

fmgmm(y,x,z,v,ker_fun="parzen",aband=0,times=5) 

Arguments

y

The data of dependent variable(s) in a regression.

x

The data of independent variables in a regression.

z

Instruments

v

Number of autocovariance terms to compute the spectrum at frequency zero, default=15.

ker_fun

Set kernel function to one of the available kernels, default="parzen". See section details below.

aband

Whether to activate the automatic bandwidth selection.
aband=1. To activate.
aband=0. Do not activate.The default.

times

Number of iteration to compute GMM residuals, default =5.

Details

1. Like FMOLS, fmgmm allows both single equation and multivariate system of equations. The multvariate case is a system that many dependent variables to common Xs.
2. Available kernels. Technical details are referred to Brillinger (1981,P.55)
"parzen"=Parzen kernel
"bartlett"=Bartlett kernel
"dchlet"= Dirichlet kernel
"mdchlet"= Modified Dirichlet kernel
"tukham"=Tukey-Hamming kernel
"tukhan"=Tukey-Hanning kernel
"cauchy"=Cauchy kernel
"bohman"=Bohman kernel
"reisz"=Riesz,Bochner kernel
"gw"= Gauss-Weierstrass kernel
"qs"= Andrews (1991) Quadratic-Spectral

These kernels are written for FM procedures, technically different from those used in pp and kpss tests.

3. Andrews (1991) has developed data based (or automatic) bandwidth procedures for computing the spectrum. COINT implements these procedures for the Parzen, Bartlette, Tukey-Hamming, and the Quadratic-Spectral kernels. When aband is active, COINT ignores the value you specify for the band-width parameter and automatically substitutes the data-based value.
4. The aim of the AR(1) filter is to flatten the spectrum of residual around the zero frequency, thereby making it easier to estimate the true spectrum by simple averaging of the periodogram.

Value

beta

Coefficient estimates.

stderr

Standard error of the residuals.

tstat

t-statistics of parameter estimates.

vcov

Variance-covariance matrix for the parameter estimates.

lromega

long-run variance-covariance matrix of residuals.

s1

The first statistic for testing validity of overidentifying restrictions.

s2

The second statistic for testing validity of overidentifying restrictions.

pvalue

The p-value for s1+s2.

fit

The fitted values, or conditional mean, of the regression.

resid

GMM residuals.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Kitamura, Y. and P. C. B. Phillips (1997) Fully-Modified IV, GIVE and GMM Estimation with Possibly Nonstationary Regressors and Instruments. Journal of Econometrics, 80, 85-123.

Examples


data(macro)

y=macro[-1,c(1,4)]
x=macro[-1,c(2,3)]
z=as.matrix(na.omit(diff(macro))) #IV

out=fmgmm(y,x,z,v=15,ker_fun="parzen")
out$beta
out$vcov
out$stderr
out$tstat #t-ratio
tail(out$fit)
tail(out$resid)



Multivariate Fully-Modified OLS Estimator

Description

Phillips' (1995) Fully-Modified OLS estimator for single equation and multivariate cointegrated regression models.

Usage

fmols(y,
      x,
      type=c("const","trend","season","all"),
      v=15,
      ker_fun="parzen",
      aband=0,
      filter=1)

Arguments

y

The data of dependent variable(s) in a regression.

x

The data of independent variables in a regression.

type

The deterministic parts in the regression.
const = intercept;
trend = lnear trend;
season = seasonal dummies, this option requires ts format;
all = all three options, which requires ts format.

v

Number of autocovariance terms to compute the spectrum at frequency zero, default=15.

ker_fun

Set kernel function to one of the available kernels, default="parzen". See section details below.

aband

Whether to activate the automatic bandwidth selection.
aband=1. To activate.
aband=0. Do not activate.The default.

filter

Whether to use an AR(1) filter to compute the spectrum at frequency zero.
filter=1. To use.The default.
filter=0. Do not use.

Details

1. This fmols allows both single equation and multivariate system of equations. The multvariate case is a system that many dependent variables to common Xs. 2. Available kernels. Technical details are referred to Brillinger (1981,P.55)
"parzen"=Parzen kernel
"bartlett"=Bartlett kernel
"dchlet"= Dirichlet kernel
"mdchlet"= Modified Dirichlet kernel
"tukham"=Tukey-Hamming kernel
"tukhan"=Tukey-Hanning kernel
"cauchy"=Cauchy kernel
"bohman"=Bohman kernel
"reisz"=Riesz,Bochner kernel
"gw"= Gauss-Weierstrass kernel
"qs"= Andrews (1991) Quadratic-Spectral

These kernels are written for fmols procedures, technically different from those used in pp and kpss tests.

3. Andrews (1991) has developed data based (or automatic) bandwidth procedures for computing the spectrum. COINT implements these procedures for the Parzen, Bartlette, Tukey-Hamming, and the Quadratic-Spectral kernels. When aband is active, COINT ignores the value you specify for the band-width parameter and automatically substitutes the data-based value.
4. The aim of the AR(1) filter is to flatten the spectrum of residual around the zero frequency, thereby making it easier to estimate the true spectrum by simple averaging of the periodogram.

Value

beta

Coefficient estimates.

stderr

Standard error of the residuals.

tstat

t-statistics of parameter estimates.

vcov

Variance-covariance matrix for the parameter estimates.

fit

The fitted values, or conditional mean, of the regression.

resid

Estimated residuals.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Phillips, P. C. B (1995) Fully Modified Least Squares and Vector Autoregression, Econometrica, 63, 1023-1078.

Examples


data(macro)
y=macro[,1:2]
x=macro[,3:4]
out=fmols(y,x,type=c("const","trend","season","all")[2],v=15,ker_fun="bartlett")
out$beta
out$stderr
out$tstat #t-ratio
out$vcov
tail(out$fit)
tail(out$resid)

Fully-Modified VAR Estimator

Description

Computes the Phillips' (1995) Fully-Modified" VAR estimator for cointegrated regressions, using OLS for the first stage regression.

Usage

fmvar(data,p=1,q=5,v=15,type=c("const","trend","season","all"),
                   ker_fun="parzen",aband=0,filter=0)

Arguments

data

The dependent variables for a VAR system.

p

The number of lags for dependent variables, as in a VAR(p).

q

The number of lagged innovation terms to include in the fitted FMVAR(p,q).

v

Number of autocovariance terms to compute the spectrum at frequency zero, default=15.

type

The deterministic parts in the regression. Please note that fmvar will "de-" before inclusion, for example, trend is to pre-detrend the data.
const = intercept;
trend = lnear trend;
season = seasonal dummies, this option requires ts format;
all = all three options, which requires ts format.

ker_fun

Set kernel function to one of the available kernels, default="parzen". See section details below.

aband

Whether to activate the automatic bandwidth selection.
aband=1. To activate.
aband=0. Do not activate.The default.

filter

Whether to use an AR(1) filter to compute the spectrum at frequency zero.
filter=1. To use.
filter=0. Do not use. The default.

Details

1. Available kernels. Technical details are referred to Brillinger (1981,P.55)
"parzen"=Parzen kernel
"bartlett"=Bartlett kernel
"dchlet"= Dirichlet kernel
"mdchlet"= Modified Dirichlet kernel
"tukham"=Tukey-Hamming kernel
"tukhan"=Tukey-Hanning kernel
"cauchy"=Cauchy kernel
"bohman"=Bohman kernel
"reisz"=Riesz,Bochner kernel
"gw"= Gauss-Weierstrass kernel
"qs"= Andrews (1991) Quadratic-Spectral

These kernels are written for FM procedures, technically different from those used in pp and kpss tests.

2. Andrews (1991) has developed data based (or automatic) bandwidth procedures for computing the spectrum. COINT implements these procedures for the Parzen, Bartlette, Tukey-Hamming, and the Quadratic-Spectral kernels. When aband is active, COINT ignores the value you specify for the band-width parameter and automatically substitutes the data-based value.
3. The aim of the AR(1) filter is to flatten the spectrum of residual around the zero frequency, thereby making it easier to estimate the true spectrum by simple averaging of the periodogram.

Value

beta

Coefficient estimates.

stderr

Standard error of the residuals.

tstat

t-statistics of parameter estimates.

vcov

Variance-covariance matrix for the parameter estimates.

fit

The fitted values, or conditional mean, of the regression.

resid

Estimated residuals.

data

The data used in fmvar

type

The type used in fmvar

p

The p argument used in fmvar

q

The q argument used in fmvar

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Phillips, P. C. B (1995) Fully Modified Least Squares and Vector Autoregression. Econometrica, 63, 1023-1078.

Examples


data(macro)
out=fmvar(macro,p=1,q=6,v=15,type="trend",ker_fun="parzen",aband=0,filter=0)
out$beta
out$stderr
out$tstat
out$vcov
tail(out$data)
tail(out$resid)

ID1=grep(rownames(out$beta),pattern="_dL")
ID2=grep(rownames(out$beta),pattern="_L")
ID3=rownames(out$beta)[-c(ID1,ID2)]

out$beta[ID1,]; #innovation terms
out$beta[ID2,]; #VAR(1)
out$beta[ID3,]; #deterministic parts



Forecast a FM-VAR System

Description

Forecast a VAR generated by fmvar_forecast.

Usage

fmvar_forecast(output, n.ahead=6)

Arguments

output

The output object of fmvar_forecast.

n.ahead

The steps of out-of-sample forecasting.

Details

This function recursively computes the n.ahead steps of out-of-sample forecasting.

Value

Forecasted values of all endogenous variables.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

Examples

data(macro)
out=fmvar(macro,p=1,q=6,v=10,type="trend",ker_fun="parzen")
fmvar_forecast(out,n.ahead=6)


Select the q in a FMVAR(p,q) by Specific Criterion

Description

Select the q for a FMVAR(p,q) for cointegrated regressions.

Usage

fmvar_plag(data,
          p=1,
          lag.max=12,
          v=15,
          type=c("const","trend","season","all"),
          ker_fun="parzen",
          aband=0,
          filter=0)

Arguments

data

The dependent variables for a VAR system.

p

The number of lags for dependent variables, as in a standard VAR(p).

lag.max

The maxum number of lags used to search for optimal q in fmvar(p,q).

v

Number of autocovariance terms to compute the spectrum at frequency zero, default=15.

type

The deterministic parts in the regression.
const = intercept;
trend = lnear trend;
season = seasonal dummies, this option requires ts format;
all = all three options, which requires ts format.

ker_fun

Set kernel function to one of the available kernels, default="parzen". See section details below.

aband

Whether to activate the automatic bandwidth selection.
aband=1. To activate.
aband=0. Do not activate.The default.

filter

Whether to use an AR(1) filter to compute the spectrum at frequency zero.
filter=1. To use.
filter=0. Do not use. The default.

Details

1. Available kernels. Technical details are referred to Brillinger (1981,P.55)
"parzen"=Parzen kernel
"bartlett"=Bartlett kernel
"dchlet"= Dirichlet kernel
"mdchlet"= Modified Dirichlet kernel
"tukham"=Tukey-Hamming kernel
"tukhan"=Tukey-Hanning kernel
"cauchy"=Cauchy kernel
"bohman"=Bohman kernel
"reisz"=Riesz,Bochner kernel
"gw"= Gauss-Weierstrass kernel
"qs"= Andrews (1991) Quadratic-Spectral

These kernels are written for fm.ols procedures, technically different from those used in pp and kpss tests.

2. Andrews (1991) has developed data based (or automatic) bandwidth procedures for computing the spectrum. COINT implements these procedures for the Parzen, Bartlette, Tukey-Hamming, and the Quadratic-Spectral kernels. When aband is active, COINT ignores the value you specify for the band-width parameter and automatically substitutes the data-based value.
3. The aim of the AR(1) filter is to flatten the spectrum of residual around the zero frequency, thereby making it easier to estimate the true spectrum by simple averaging of the periodogram.

Value

selection

The selected order of q: the selected lagged innovation terms to include in the fitted FMVAR(p,q)

criteria

The matrix of all lags and the values of four criteria: "AIC(q)", "HQ(q)", "SC(q)", "FPE(q)".

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Phillips, P. C. B (1995) Fully Modified Least Squares and Vector Autoregression. Econometrica, 63, 1023-1078.

Examples


data(macro)

Q=fmvar_plag(macro,
            p=1,
            v=15,
            lag.max=16,type="trend",
            ker_fun="parzen")$selection[1]

out=fmvar(macro,p=1,q=Q,v=15,type="trend", ker_fun="parzen")


Gauss-Weierstrass Kernel for Consistent Estimate of Long-run Variance

Description

Computes the Gauss-Weierstrass window to obtain consistent estimate of long-run variance of multivariate time series.

Usage

gw(data,v)

Arguments

data

Data matrix for computing consistent long-run variance, normally, multivariate regression residuals.

v

Number of autocovariance terms in the kernel.

Value

Return the consistent estimate of long-run variance. This procedure handles both multivariate and single time series, which is basically designed for "fmvar","fmgmm" and "fmols".

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Brillinger, David R. (1981) Time Series Data Analysis and Theory. San Francisco, CA: Holden-Day.

Examples

data(macro)
e=apply(macro, 2, function(x) x-mean(x))
gw(e,v=15)

KPSS Unit Root Test for the null of stationarity

Description

Implement the KPSS unit root test for the null of I(0) stationarity. The test type as deterministic component is specified as x, see example below.

Usage

kpss(y, x, lags = c("short", "long", "nil"), use=c("nw","ba"))

Arguments

y

Vector to be tested for a unit root.

x

data matrix for deterministic component. For example a vector of one for intercept, or trend. The default is "x=NULL", which is the same of a vector of one

lags

Lags used for correction of error term.

use

User specified lags for correction of error term. See section details below.The default is the lag determined by Newey-West bandwidth ("nw") with Bartlettkernel ("ba").

Details

lags="short" sets the number of lags to \sqrt[4]{4 \times (n/100)}, whereas lags="long" sets the number of lags to \sqrt[4]{12 \times (n/100)}. If lags="nil" is choosen, no error correction is made.

Furthermore, "lags" and "use" are mutually exclusive: As long as "use" is not NULL, its argument will be chosen first. One can specify a different number of maximum lags by setting "use" accordingly. Users can input number of your souce. This version suports two bandwidth functions: "nw" for Newey-West and "and" for Andrews. The kernel functions are supported: "ba"=Bartlett, "pa"=Parzen, "qs"=Qudratic Spectral

Value

teststat

The KPSS test statistic.

cval

Critical values.

lag

Number of lags used for kernel function.

resid

Regression residuals.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Kwiatkowski, D., Phillips, P.C.B., Schmidt, P. and Shin, Y. (1992) Testing the Null Hypothesis of Stationarity Against the Alternative of a Unit Root: How Sure Are We That Economic Time Series Have a Unit Root? Journal of Econometrics, 54,159-178.
Phillips, P.C.B. and Sainan Jin (2002) The KPSS test with seasonal dummies. Economics Letters, 77, 239-243.

Examples


data(macro)
y=macro[,"INF"]
const=rep(1,nrow(y))
trend=seq(nrow(y))/nrow(y)
D=cbind(const,trend) #seasonal dummies can be specified here
KPSS=kpss(y,x=D,lags = c("short", "long", "nil")[2],
          use=c("nw","ba")) # If argument use isn't NULL, the argument "lags" will be ignored.
KPSS$teststat
KPSS$cval
KPSS$lag

kpss(y,x=D,lags = c("short", "long", "nil")[2],use=15)

kpss(y,x=D,
    lags = c("short", "long", "nil")[2],
    use=NULL) #if "use=NULL", argument "lags"  will be chosen as input.




KPSS Unit Root Test with One Structural Break

Description

Implement the Kurozumi (2002) sequential kpss test with one structural break.

Usage

kpss_1br(y,
        lags = c("short", "long", "nil"),
        model=c("intercept","both"),
        use=c("nw","ba"),
        trim=0.1)

Arguments

y

Vector to be tested for a unit root.

lags

Lags used for correction of error term.

model

Modelling where the unknown structural change occurs.
intercept= structural change occurs at the intercept.
both= structural changes occur at both the intercept and the trend.

use

User specified lags for correction of error term. The default is the lag determined by Newey-West bandwidth "nw" with Bartlett "ba" kernel. Users can input your own number. This version suports two bandwidth functions: "nw" for Newey-West, "and" for Andrews. Three kernel functions are supported by both bandwidth functions: "ba"=Bartlett, "pa"=Parzen, "qs"=Qudratic Spectral

trim

The trimming percentage. Default is 10

Details

lags="short" sets the number of lags to \sqrt[4]{4 \times (n/100)}, whereas lags="long" sets the number of lags to \sqrt[4]{12 \times (n/100)}. If lags="nil" is choosen, then no error correction is made. Furthermore, lags and use are mutually exclusive. As long as use is not set to be NULL, its argumenta will be chosen fisrt. One can specify a different number of maximum lags by setting use accordingly.

Value

teststat

The kpss test statistic with one structural break.

cval

Critical values.

bpoint

The breaking point that corresponds to the teststat.

tstats

The sequential KPSS test statistic.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Kwiatkowski, D., Phillips, P.C.B., Schmidt, P. and Shin, Y. (1992) Testing the Null Hypothesis of Stationarity Against the Alternative of a Unit Root: How Sure Are We That Economic Time Series Have a Unit Root? Journal of Econometrics, 54, 159-178.
Kurozumi, E. (2002) Testing for stationarity with a break. Journal of Econometrics,108(1), 105-127.
Phillips, P.C.B. and Sainan Jin (2002) The KPSS test with seasonal dummies. Economics Letters, 77, 239-243.

Examples


data(macro)
y=macro[,"INF"]
KPSS1=kpss_1br(y,model=c("intercept","both")[2],use=c("nw","ba"))
KPSS1$teststat
KPSS1$cval
y[KPSS1$bpoint,]
#Plot
plot.ts(KPSS1$tstats,ylim=range(c(KPSS1$tstats,KPSS1$cval)));grid()
abline(h=KPSS1$cval[1],col="red")
abline(h=KPSS1$cval[2],col="blue")
abline(h=KPSS1$cval[3],col="green")
abline(v=KPSS1$bpoint,col="red",lty=2)


KPSS Unit Root Test with Two Structural Breaks

Description

Implement the kpss unit root test with two unknown structural breaks. Carrion-i-Silvestre and Sanso (2007) extends Kurozumi (2002) to two breaks, and create critical values.

Usage

kpss_2br(y, lags = c("short", "long", "nil"), model=1, use=c("nw","ba"),trace=TRUE)

Arguments

y

Vector to be tested for a unit root.

lags

Lags used for correction of error term.

model

Modelling where the unknown structural change occurs.
1 = AAn (Level shift without trend);
2 = AA (Level shift with trend);
3 = BB (Trend shift);
4 = CC (Level and trend shift)
Default is 1.

use

User specified lags for correction of error term. The default is the lag determined by Newey-West bandwidth "nw" with Bartlett "ba" kernel. Users can input your own number. This version suports two bandwidth functions: "nw" for Newey-West, "and" for Andrews. Three kernel functions are supported by both bandwidth functions: "ba"=Bartlett, "pa"=Parzen, "qs"=Qudratic Spectral

trace

Logical. If TURE (default), then screen displays the sequential progress.

Details

lags="short" sets the number of lags to \sqrt[4]{4 \times (n/100)}, whereas lags="long" sets the number of lags to \sqrt[4]{12 \times (n/100)}. If lags="nil" is choosen, then no error correction is made. Furthermore, lags and use are mutually exclusive. As long as use is not set to be NULL, its argumenta will be chosen fisrt. One can specify a different number of maximum lags by setting use accordingly.

Value

teststat

The test statistic.

cval

The critical values that are tabulated in Carrion-i-Silvestre and Sanso, A. (2007).

bpoint1

The first breaking point that corresponds to the teststat.

bpoint2

The second breaking point that corresponds to the teststat.

timeElapse

Time elapsed for sequential search.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Carrion-i-Silvestre, J. L. and Sanso, A. (2006) A guide to the computation of stationarity tests. Empirical Economics, 31(2), 433-448.
Carrion-i-Silvestre, J. L. and Sanso, A. (2007) The KPSS test with two structural breaks,Spanish Economic Review, 9(2), 105-127.
Kwiatkowski, D., Phillips, P.C.B., Schmidt, P. and Shin, Y. (1992) Testing the Null Hypothesis of Stationarity Against the Alternative of a Unit Root: How Sure Are We That Economic Time Series Have a Unit Root? Journal of Econometrics, 54, 159-178.
Kurozumi, E. (2002) Testing for stationarity with a break. Journal of Econometrics,108(1), 105-127.

Examples


data(macro)


y=macro[1:200,"INF"]

KPSS2=kpss_2br(y,model=1,use=c("nw","ba"))
KPSS2$teststat
KPSS2$cval
y[KPSS2$bpoint,]




Modified Dirichlet Kernel for Consistent Estimate of Long-run Variance

Description

Computes the modified Dirichlet window to obtain consistent estimate of long-run variance of multivariate time series.

Usage

mdchlet(data,v)

Arguments

data

Data matrix for computing consistent long-run variance, normally, multivariate regression residuals.

v

Number of autocovariance terms in the kernel.

Value

Return the consistent estimate of long-run variance. This procedure handles both multivariate and single time series, which is basically designed for "fmvar","fmgmm" and "fmols".

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Brillinger, David R. (1981) Time Series Data Analysis and Theory. San Francisco, CA: Holden-Day.

Examples

data(macro)
e=apply(macro, 2, function(x) x-mean(x))
mdchlet(e,v=15)

Parzen Kernel for Consistent Estimate of Long-run Variance

Description

Compute the Parzen window to obtain consistent estimate of long-run variance of multivariate time series.

Usage


parzen(data,v)

Arguments

data

Data matrix for computing consistent long-run variance, normally, multivariate regression residuals.

v

Number of autocovariance terms in the kernel.

Value

Return the consistent estimate of long-run variance. This procedure handles both multivariate and single time series, which is basically designed for "fmvar","fmgmm" and "fmols".

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Brillinger, David R. (1981) Time Series Data Analysis and Theory. San Francisco, CA: Holden-Day.

Examples

data(macro)
e=apply(macro, 2, function(x) x-mean(x))
parzen(e,v=15)

Phillips and Perron Unit Root Test

Description

Implement the Phillips-Perron (1988) PP unit root test, including both Za (Z-alpha) and Zt (Z-tau) statistics. This wrapper allows inputting additional deterministic part, for example season dummies, but the asymptotic critical values are not available.

Usage


pp(y,type=c("none","const","trend"),d=NULL,lags=c("short","long","nill"),use=c("nw","ba"))

Arguments

y

Vector to be tested for a unit root.

type

The deterministic parts in the test regression.

d

Additional deterministic parts in addition to "type"" in the test regression.

lags

Lags used for correction of error term. See section "details" below.

use

User specified lags for correction of error term. See section "details" below.The default is the lag determined by Newey-West bandwidth ("nw") with Bartlett kernel ("ba").

Details

lags="short" sets the number of lags to \sqrt[4]{4 \times (n/100)}, whereas lags="long" sets the number of lags to \sqrt[4]{12 \times (n/100)}. If lags="nil" is choosen, no error correction is made.

Furthermore, "lags" and "use" are mutually exclusive: As long as "use" is not set to be NULL, its argument will be chosen first. One can specify a different number of maximum lags by setting "use" accordingly. Users can input number of your souce. This version suports two bandwidth functions: "nw" for Newey-West and "and" for Andrews. The kernel functions are supported: "ba"=Bartlett, "pa"=Parzen, "qs"=Qudratic Spectral

Value

Zt

The Z-tau test statistic.

cvZt

Critical values of Zt.

Za

The Z-alpha test statistic.

cvZa

Critical values of Za.

lag

Number of lags used for kernel function.

resid

Regression residuals.

Note

This code modifies function ur.pp of package urca, which does not have relevant critical values for "Z-alpha" test statistic.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Phillips, P.C.B. and Perron, P. (1988) Testing for a unit root in time series regression. Biometrika, 75(2), 335-346.
MacKinnon, J.G. (1991) Critical Values for Cointegration Tests- Long-Run Economic Relationships, eds. R.F. Engle and C.W.J. Granger, London, Oxford, 267-276.

Examples

data(macro)
y=macro[,"INF"]
pp(y,
   type=c("none","const","trend")[3],
   lags = c("short", "long", "nil")[2],
   use=c("nw","ba")) # If argument "use" is NOT NULL, argument lags will be ignored.

pp(y,lags = c("short", "long", "nil")[2],
   type=c("none","const","trend")[3],
   use=NULL)

pp(y,lags = c("short", "long", "nil")[2],
   type=c("none","const","trend")[3],
   use=18)

Quadratic-Spectral Kernel for Consistent Estimate of Long-run Variance

Description

Computes the Andrews (1991) Quadratic-Spectral window to obtain consistent estimate of long-run variance of multivariate time series.

Usage

qs(data,v)

Arguments

data

Data matrix for computing consistent long-run variance, normally, multivariate regression residuals.

v

Number of autocovariance terms in the kernel.

Value

Return the consistent estimate of long-run variance. This procedure handles both multivariate and single time series, which is basically designed for "fmvar","fmgmm" and "fmols".

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Andrews, D. W. K. (1991) Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Estimation. Econometrica, 59, 817-858.

Brillinger, David R. (1981) Time Series Data Analysis and Theory. San Francisco, CA: Holden-Day.

Examples

data(macro)
e=apply(macro, 2, function(x) x-mean(x))

qs(e,v=15)


Reisz Kernel for Consistent Estimate of Long-run Variance

Description

Computes the Reisz Bochner window to obtain consistent estimate of long-run variance of multivariate time series.

Usage

reisz(data,v) 

Arguments

data

Data matrix for computing consistent long-run variance, normally, multivariate regression residuals.

v

Number of autocovariance terms in the kernel.

Value

Return the consistent estimate of long-run variance. This procedure handles both multivariate and single time series, which is basically designed for "fmvar","fmgmm" and "fmols".

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Brillinger, David R. (1981) Time Series Data Analysis and Theory. San Francisco, CA: Holden-Day.

Examples

data(macro)
e=apply(macro, 2, function(x) x-mean(x))
reisz(e,v=15)

Stock-Watson Common Trends Statistic

Description

Computes Stock and Watson (1988) common trends statistic for the null hypothesis that the data is a noncointegrated system (after allowing for a p-th order polynomial time trend).

Usage

sw(data,p,v=15,ker_fun="parzen",aband=0,filter=0)

Arguments

data

Matrix of k-time series variables.

p

Order of the time polynomial in the null hypothesis.

v

Number of autocovariance terms to compute the spectrum at frequency zero, default=15.

ker_fun

Set kernel function to one of the available kernels, default="parzen". See section details below.

aband

Whether to activate the automatic bandwidth selection.
aband=1. To activate.
aband=0. Do not activate. The default.

filter

Whether to use an AR(1) filter to compute the spectrum at frequency zero.
filter=1. To use.
filter=0. Do not use. The default.

Details

1. Available kernels. Technical details are referred to Brillinger (1981,P.55)
"parzen"=Parzen kernel
"fejer"=Bartlett kernel
"dchlet"= Dirichlet kernel
"mdchlet"= Modified Dirichlet kernel
"tukham"=Tukey-Hamming kernel
"tukhan"=Tukey-Hanning kernel
"cauchy"=Cauchy kernel
"bohman"=Bohman kernel
"reisz"=Riesz,Bochner kernel
"gw"= Gauss-Weierstrass kernel
"qs"= Andrews (1991) Quadratic-Spectral

These kernels are written for FM procedures, technically different from those used in pp and kpss tests.

2. Andrews (1991) has developed data based (or automatic) bandwidth procedures for computing the spectrum. COINT implements these procedures for the Parzen, Bartlette, Tukey-Hamming, and the Quadratic-Spectral kernels. When aband is active, COINT ignores the value you specify for the band-width parameter and automatically substitutes the data-based value.
3. The aim of the AR(1) filter is to flatten the spectrum of residual around the zero frequency, thereby making it easier to estimate the true spectrum by simple averaging of the periodogram.

Value

sw_stat

Test statistic. Reject the null of a unit root if the SW statistic < critical value

sw_cv

Critical values.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Stock, J. & M. K. Watson (1988) Testing for Common Trends. Journal of the American Statistical Association, 83, 1097-1107.

Examples


data(macro)
sw(macro,p=1,v=15)



Tukey-Hamming Kernel for Consistent Estimate of Long-run Variance

Description

Compute the Tukey-Hamming window to obtain consistent estimate of long-run variance of multivariate time series.

Usage

tukham(data,v)

Arguments

data

Data matrix for computing consistent long-run variance, normally, multivariate regression residuals.

v

Number of autocovariance terms in the kernel.

Value

Brillinger, David R. (1981) Time Series Data Analysis and Theory. San Francisco, CA: Holden-Day.

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Brillinger, David R. (1981) Time Series Data Analysis and Theory. San Francisco, CA: Holden-Day.

Examples

data(macro)
e=apply(macro, 2, function(x) x-mean(x))
tukham(e,v=15)

Tukey-Hanning Kernel for Consistent Estimate of Long-run Variance

Description

Compute the Tukey-Hanning window to obtain consistent estimate of long-run variance of multivariate time series.

Usage

tukhan(data,v)

Arguments

data

Data matrix for computing consistent long-run variance, normally, multivariate regression residuals.

v

Number of autocovariance terms in the kernel.

Value

Return the consistent estimate of long-run variance. This procedure handles both multivariate and single time series, which is basically designed for "fmvar","fmgmm" and "fmols".

Author(s)

Ho Tsung-wu <tsungwu@ntnu.edu.tw>, College of Management, National Taiwan Normal University.

References

Brillinger, David R. (1981) Time Series Data Analysis and Theory. San Francisco, CA: Holden-Day.

Examples

data(macro)
e=apply(macro, 2, function(x) x-mean(x))
tukhan(e,v=15)