| Title: | Structural Breaks in Quantile Regression |
|---|---|
| Description: | Methods for detecting structural breaks, determining the number of breaks, and estimating break locations in linear quantile regression, using one or multiple quantiles, based on Qu (2008) and Oka and Qu (2011). Applicable to both time series and repeated cross-sectional data. The main function is rq.break(). References for detailed theoretical and empirical explanations: (1) Qu, Z. (2008). "Testing for Structural Change in Regression Quantiles." Journal of Econometrics, 146(1), 170-184 <doi:10.1016/j.jeconom.2008.08.006> (2) Oka, T., and Qu, Z. (2011). "Estimating Structural Changes in Regression Quantiles." Journal of Econometrics, 162(2), 248-267 <doi:10.1016/j.jeconom.2011.01.005>. |
| Authors: | Zhongjun Qu [aut, cre], Tatsushi Oka [aut], Samuel Messer [ctb] |
| Maintainer: | Zhongjun Qu <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.0.2 |
| Built: | 2026-05-20 06:05:38 UTC |
| Source: | https://github.com/cran/QR.break |
This function estimates break dates in a quantile regression model,
allowing for up to m breaks.
When m = 1, this function finds the optimal single-break partition within
a segment by evaluating the objective function at each possible break point
to determine the break date.
When m > 1, a dynamic programming algorithm is used to efficiently determine
the break dates.
brdate(y, x, n.size = 1, m, trim.size, vec.long)brdate(y, x, n.size = 1, m, trim.size, vec.long)
y |
A numeric vector of dependent variables ( |
x |
A numeric matrix of regressors ( |
n.size |
An integer specifying the number of cross-sectional units ( |
m |
An integer specifying the maximum number of breaks allowed. |
trim.size |
An integer representing the minimum length of a regime, which ensures break dates are not too short or too close to the sample's boundaries. |
vec.long |
A numeric vector/matrix used in dynamic programming, storing pre-computed objective function values for all possible segments of the sample for optimization.
Produced by the function |
The function first determines the optimal one-break partition.
If multiple breaks are allowed (m > 1), it applies a dynamic programming
algorithm as in Bai and Perron (2003) to minimize the objective function.
The algorithm finds break dates by iterating over all possible partitions,
returning optimal break locations and associated objective function values.
An upper triangular matrix (m × m) containing estimated break dates. The row index represents break dates, and the column index corresponds to the permitted number of breaks before the ending date.
Bai, J. and P. Perron (2003). Computation and analysis of multiple structural change models. Journal of Applied Econometrics, 18(1), 1-22.
Oka, T. and Z. Qu (2011). Estimating structural changes in regression quantiles, Journal of Econometrics, 162(2), 248-267.
# data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] n.size = 1 T.size = length(y) # number of time periods # setting vec.tau = seq(0.20, 0.80, by = 0.150) trim.e = 0.2 trim.size = round(T.size * trim.e) #minimum length of a regime m.max = 3 # compute the objective function under all possible partitions out.long = gen.long(y, x, vec.tau, n.size, trim.size) vec.long.m = out.long$vec.long ## for break estimation using multiple quantiles # break date mat.date = brdate(y, x, n.size, m.max, trim.size, vec.long.m) print(mat.date)# data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] n.size = 1 T.size = length(y) # number of time periods # setting vec.tau = seq(0.20, 0.80, by = 0.150) trim.e = 0.2 trim.size = round(T.size * trim.e) #minimum length of a regime m.max = 3 # compute the objective function under all possible partitions out.long = gen.long(y, x, vec.tau, n.size, trim.size) vec.long.m = out.long$vec.long ## for break estimation using multiple quantiles # break date mat.date = brdate(y, x, n.size, m.max, trim.size, vec.long.m) print(mat.date)
This function constructs confidence intervals for break dates based on a single quantile or multiple quantiles (specified by the user).
ci.date.m(y, x, vec.tau, vec.date, n.size = 1, v.b = 2)ci.date.m(y, x, vec.tau, vec.date, n.size = 1, v.b = 2)
y |
A numeric vector of dependent variables ( |
x |
A numeric matrix of regressors ( |
vec.tau |
A numeric vector of quantiles of interest. |
vec.date |
A numeric vector of estimated break dates. |
n.size |
An integer specifying the size of the cross section ( |
v.b |
A numeric value specifying the confidence level:
|
A numeric matrix where:
The 1st column contains the break dates.
The 2nd and 3rd columns contain the lower and upper bounds of the confidence intervals, respectively.
Oka, T. and Z. Qu (2011). Estimating Structural Changes in Regression Quantiles. Journal of Econometrics, 162(2), 248–267.
# data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] # quantiles vec.tau = 0.8 # break dates (point estimates) vec.date = c(146, 200) # Calculate confidence intervals for break dates res = ci.date.m(y, x, vec.tau, vec.date, n.size = 1, v.b = 2) print(res)# data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] # quantiles vec.tau = 0.8 # break dates (point estimates) vec.date = c(146, 200) # Calculate confidence intervals for break dates res = ci.date.m(y, x, vec.tau, vec.date, n.size = 1, v.b = 2) print(res)
This function determines the number of breaks in a model by
sequentially applying the DQ() test. It tests for additional breaks
by comparing the test statistic to critical values at various significance levels.
dq( y, x, vec.tau, q.L, q.R, n.size = 1, m.max, trim.size, mat.date, d.Sym, table.cv )dq( y, x, vec.tau, q.L, q.R, n.size = 1, m.max, trim.size, mat.date, d.Sym, table.cv )
y |
A numeric vector of dependent variables ( |
x |
A numeric matrix of regressors ( |
vec.tau |
A numeric vector of quantiles of interest. |
q.L |
A numeric value specifying the left-end quantile range for the DQ test. |
q.R |
A numeric value specifying the right-end quantile range for the DQ test. |
n.size |
An integer specifying the size of the cross-section ( |
m.max |
An integer indicating the maximum number of breaks allowed. |
trim.size |
A numeric trimming value (the minimum length of a regime). |
mat.date |
A numeric matrix of break dates. |
d.Sym |
A logical value indicating whether the quantile range is symmetric satisfying |
table.cv |
A matrix of simulated critical values for cases not covered by the response surface. |
A list containing:
testA numeric vector of DQ test statistics.
cvA numeric matrix of critical values for the DQ test at 10, 5, and 1 percent significance levels.
dateA numeric matrix of estimated break dates.
nbreakA numeric vector indicating the number of detected breaks at different significance levels.
# This example may take substantial time for automated package # checks since it involves dynamic programming data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] n.size = 1 T.size = length(y) # number of time periods # setting vec.tau = seq(0.20, 0.80, by = 0.150) trim.e = 0.2 trim.size = round(T.size * trim.e) #minimum length of a regime m.max = 3 # dynamic program algorithm to compute the objective function out.long = gen.long(y, x, vec.tau, n.size, trim.size) mat.long.s = out.long$mat.long ## for break estimation using individual quantile vec.long.m = out.long$vec.long ## for break estimation using multiple quantiles jointly # break date mat.date = brdate(y, x, n.size, m.max, trim.size, vec.long.m) ## qunatile ranges (left and right) q.L = 0.2 q.R = 0.8 d.Sym = TRUE ## symmetric trimming of quantiles table.cv = NULL ##covered by the response surface because d.Sym = TRUE # determine the number of breaks out.m = dq(y, x, vec.tau, q.L, q.R, n.size, m.max, trim.size, mat.date, d.Sym, table.cv) # result print(out.m)# This example may take substantial time for automated package # checks since it involves dynamic programming data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] n.size = 1 T.size = length(y) # number of time periods # setting vec.tau = seq(0.20, 0.80, by = 0.150) trim.e = 0.2 trim.size = round(T.size * trim.e) #minimum length of a regime m.max = 3 # dynamic program algorithm to compute the objective function out.long = gen.long(y, x, vec.tau, n.size, trim.size) mat.long.s = out.long$mat.long ## for break estimation using individual quantile vec.long.m = out.long$vec.long ## for break estimation using multiple quantiles jointly # break date mat.date = brdate(y, x, n.size, m.max, trim.size, vec.long.m) ## qunatile ranges (left and right) q.L = 0.2 q.R = 0.8 d.Sym = TRUE ## symmetric trimming of quantiles table.cv = NULL ##covered by the response surface because d.Sym = TRUE # determine the number of breaks out.m = dq(y, x, vec.tau, q.L, q.R, n.size, m.max, trim.size, mat.date, d.Sym, table.cv) # result print(out.m)
This procedure computes test statistics for detecting a single structural break within a range of quantiles. The null hypothesis is that there is no break in any quantile in the specified range; the alternative is that at least one quantile in the range is affected by a break.
dq.test.0vs1(y, x, q.L, q.R, n.size = 1)dq.test.0vs1(y, x, q.L, q.R, n.size = 1)
y |
A numeric vector of dependent variables ( |
x |
A numeric matrix of regressors ( |
q.L |
A numeric value specifying the lower bound of the quantile range. |
q.R |
A numeric value specifying the upper bound of the quantile range. |
n.size |
An integer specifying the size of the cross-section ( |
A numeric scalar representing the DQ test statistic.
Koenker, R. and Bassett Jr, G. (1978). Regression quantiles. Econometrica, 46(1), 33–50.
Qu, Z. (2008). Testing for structural change in regression quantiles. Journal of Econometrics, 146(1), 170–184.
## data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] ## qunatile range (left and right limits) q.L = 0.2 q.R = 0.8 ## N n.size = 1 # dq-test result = dq.test.0vs1(y, x, q.L, q.R, n.size) print(result)## data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] ## qunatile range (left and right limits) q.L = 0.2 q.R = 0.8 ## N n.size = 1 # dq-test result = dq.test.0vs1(y, x, q.L, q.R, n.size) print(result)
This function performs a sequential test to determine whether the number of
breaks in a quantile regression model should be increased from to using
multiple quantiles.
dq.test.lvsl_1(y, x, q.L, q.R, n.size = 1, vec.date)dq.test.lvsl_1(y, x, q.L, q.R, n.size = 1, vec.date)
y |
A numeric vector of dependent variables ( |
x |
A numeric matrix of regressors ( |
q.L |
A numeric value specifying the lower bound of the quantile range. |
q.R |
A numeric value specifying the upper bound of the quantile range. |
n.size |
An integer specifying the size of cross-sections ( |
vec.date |
A numeric vector ( |
This procedure tests for the existence of breaks against breaks
based on multiple quantiles:
breaks vs. breaks.
A numeric value representing the DQ test statistic.
Qu, Z. (2008). Testing for Structural Breaks in Regression Quantiles. Journal of Econometrics, 146(1), 170-184.
# Load data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] # Set quantile range (left and right limits) q.L = 0.2 q.R = 0.8 # Set N parameter n.size = 1 # Specify break date under H_0 vec.date = 146 # Run the test result = dq.test.lvsl_1(y, x, q.L, q.R, n.size, vec.date) print(result)# Load data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] # Set quantile range (left and right limits) q.L = 0.2 q.R = 0.8 # Set N parameter n.size = 1 # Specify break date under H_0 vec.date = 146 # Run the test result = dq.test.lvsl_1(y, x, q.L, q.R, n.size, vec.date) print(result)
This is a repeated cross-sectional data set on young drivers (under 21 years old) involved in motor vehicle accidents in the state of California from 1983 to 2007 (quarterly data). The data are obtained from the National Highway Traffic Safety Administration (NHTSA), which include the blood alcohol concentration (BAC) of the driver, their age, gender, and whether the crash was fatal.
data(driver)data(driver)
A data frame with five variables:
yq: Year and quarter ("Year Quarter" format, e.g., "1983 Q2").
bac: The blood alcohol concentration (BAC) level of the driver.
age: The driver's age.
gender: A gender dummy, with 1 for male and 0 for female.
winter: A dummy variable for the fourth quarter, with 1 for Q4 and 0 otherwise.
Motor vehicle crashes are the leading cause of death among youth aged 15–20, with a high proportion involving drunk driving. The BAC level is an important measure of alcohol impairment. Oka and Qu (2011) used this data to examine whether and how young drivers' drinking behaviors have changed over time.
Oka, T. and Z. Qu (2011). Estimating Structural Changes in Regression Quantiles. Journal of Econometrics, 162(2), 248–267.
data(driver) names(driver) summary(driver)data(driver) names(driver) summary(driver)
This dataset contains quarterly real GDP growth rates in the US from 1947 Q4 to 2009 Q2. It is used in Oka and Qu (2011) to examine whether and where distributional breaks occur in US GDP.
data(gdp)data(gdp)
A data frame with four variables:
yq A character vector representing the year and quarter (e.g., "1947 Q2").
gdp A numeric vector of real GDP growth rates (annualized by multiplying by 4).
lag1 A numeric vector representing the first-order lagged value of gdp.
lag2 A numeric vector representing the second-order lagged value of gdp.
Oka, T. and Z. Qu (2011). Estimating Structural Changes in Regression Quantiles. Journal of Econometrics, 162(2), 248–267.
data(gdp) names(gdp) summary(gdp)data(gdp) names(gdp) summary(gdp)
This function computes the objective function values for all possible segments of the sample.
gen.long(y, x, vec.tau, n.size = 1, trim.size)gen.long(y, x, vec.tau, n.size = 1, trim.size)
y |
A numeric vector of dependent variables ( |
x |
A numeric matrix of regressors ( |
vec.tau |
A vector of quantiles of interest. |
n.size |
The size of the cross-section; default is set to 1. |
trim.size |
The minimum length of a regime (integer). |
A list containing:
A matrix of objective function values for separate quantiles.
A matrix of objective function values for combined quantiles.
Bai, J and P. Perron (2003). Computation and Analysis of Multiple Structural Change Models. Journal of Applied Econometrics, 18(1), 1-22.
# This example may take substantial time for automated package checks data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] n.size = 1 T.size = length(y) # number of time periods # setting vec.tau = seq(0.20, 0.80, by = 0.150) trim.e = 0.2 trim.size = round(T.size * trim.e) #minimum length of a regime out.long = gen.long(y, x, vec.tau, n.size, trim.size)# This example may take substantial time for automated package checks data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] n.size = 1 T.size = length(y) # number of time periods # setting vec.tau = seq(0.20, 0.80, by = 0.150) trim.e = 0.2 trim.size = round(T.size * trim.e) #minimum length of a regime out.long = gen.long(y, x, vec.tau, n.size, trim.size)
This function returns critical values obtained from a response surface analysis.
Note that this procedure only applies when the trimming is symmetric, i.e., .
res.surface(p, l, q.L, q.R, d.Sym)res.surface(p, l, q.L, q.R, d.Sym)
p |
The number of parameters in the model. |
l |
The number of breaks under the null |
q.L |
The lower bound of the quantile range. |
q.R |
The upper bound of the quantile range (not used in the function because |
d.Sym |
A logical value. Must be TRUE, as this method applies only to symmetric trimming ( |
A numeric vector of length 3 containing critical values at the 10%, 5%, and 1% significance levels.
# The number of regerssors p = 5 ## The number of breaks under the null l = 2 # qunatile range (left and right limits) q.L = 0.2 q.R = 0.8 # symmetric quantile trimming is true d.Sym = TRUE ## critical values from response surface cvs = res.surface(p, l, q.L, q.R, d.Sym) print(cvs)# The number of regerssors p = 5 ## The number of breaks under the null l = 2 # qunatile range (left and right limits) q.L = 0.2 q.R = 0.8 # symmetric quantile trimming is true d.Sym = TRUE ## critical values from response surface cvs = res.surface(p, l, q.L, q.R, d.Sym) print(cvs)
This is the main function of this package for testing breaks in quantile regression models and estimating break dates and break sizes with corresponding confidence intervals.
rq.break(y, x, vec.tau, N, trim.e, vec.time, m.max, v.a, v.b, verbose)rq.break(y, x, vec.tau, N, trim.e, vec.time, m.max, v.a, v.b, verbose)
y |
a numeric vector, the outcome variable (NT x 1), the first N units are from the first period, the next N from the second period, and so forth. |
x |
A matrix of regressors (NT x p), structured in the same way as y, a column of ones will be automatically added to x. |
vec.tau |
a numeric vector, quantiles used for break estimation, for example |
N |
a numeric vector, the number of cross-sectional units. Set to 1 for a time series quantile regression. |
trim.e |
a scalar between 0 and 1, the trimming proportion.
For example, if |
vec.time |
a vector of dates, needed for reporting the estimated break dates, in the format of (starting date...ending date); If set to NULL, the break dates will be reported as indices (e.g., 55 for the 55th observation in the sample). |
m.max |
the maximum number of breaks allowed. |
v.a |
the significance level used for determining the number of breaks; 1, 2 or 3 for 10%, 5% or 1%, respectively |
v.b |
the coverage level for constructing the confidence intervals of break dates; 1 or 2 for 90% and 95%, respectively. |
verbose |
Logical; set to TRUE to print estimates to the console. Default is FALSE. |
A list containing:
$s.out: A list with break testing results, estimated break dates, confidence intervals, and coefficient estimates
based on individual quantiles.
$m.out: A list with break testing results, estimated break dates, confidence intervals, and coefficient estimates
obtained by testing and estimating breaks using multiple quantiles simultaneously.
Each list (s.out or m.out) contains:
test_tau: A matrix of test statistics and critical values for break detection at quantile tau.
nbreak_tau: The number of detected breaks at quantile tau.
br_est_tau: A matrix of estimated break dates and their confidence intervals at quantile tau.
br_est_time_tau: The same as br_est_tau, but with break dates reported in calendar format (if vec.time is provided and is not NULL).
coef_tau: Estimated regression coefficients for each regime at quantile tau.
bsize_tau: Break size estimates for each transition between regimes at quantile tau.
Koenker, R. and G. Bassett Jr. (1978). Regression quantiles. Econometrica, 46(1), 33-50.
Oka, T. and Z. Qu (2011). Estimating Structural Changes in Regression Quantiles. Journal of Econometrics, 162(2), 248-267.
Qu, Z. (2008). Testing for Structural Change in Regression Quantiles. Journal of Econometrics, 146(1), 170-184.
## Example 1 ## Time series example, using GDP data ## data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] vec.time = gdp$yq ## the maximum number of breaks allowed m.max = 3 ## the signifance level for sequenatial testing ## 1, 2 or 3 for 10%, 5% or 1%, respectively v.a = 2 ## the significance level for the confidence intervals of estimated break dates. ## 1 or 2 for 90% and 95%, respectively. v.b = 2 ## the size of the cross-section N = 1 ## the trimming proportion for estimating the break dates ## (represents the minimum length of a regime; used to exclude ## the boundaries of the sample) trim.e = 0.15 ## quantiles vec.tau = seq(0.20, 0.80, by = 0.150) verbose = FALSE #do not print ## main estimation res = rq.break(y, x, vec.tau, N, trim.e, vec.time, m.max, v.a, v.b, verbose)## Example 1 ## Time series example, using GDP data ## data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] vec.time = gdp$yq ## the maximum number of breaks allowed m.max = 3 ## the signifance level for sequenatial testing ## 1, 2 or 3 for 10%, 5% or 1%, respectively v.a = 2 ## the significance level for the confidence intervals of estimated break dates. ## 1 or 2 for 90% and 95%, respectively. v.b = 2 ## the size of the cross-section N = 1 ## the trimming proportion for estimating the break dates ## (represents the minimum length of a regime; used to exclude ## the boundaries of the sample) trim.e = 0.15 ## quantiles vec.tau = seq(0.20, 0.80, by = 0.150) verbose = FALSE #do not print ## main estimation res = rq.break(y, x, vec.tau, N, trim.e, vec.time, m.max, v.a, v.b, verbose)
This procedure estimates a linear quantile regression given a set of break dates. It is structured to compute break sizes between adjacent regimes and their confidence intervals.
rq.est.full(y, x, v.tau, vec.date, n.size = 1)rq.est.full(y, x, v.tau, vec.date, n.size = 1)
y |
A numeric vector of dependent variables ( |
x |
A numeric matrix of regressors ( |
v.tau |
A numeric value representing the quantile of interest. |
vec.date |
A numeric vector of break dates, specified by the user. |
n.size |
An integer specifying the size of the cross-section ( |
An object from the quantile regression estimates, rq(), with structural breaks.
Koenker, R. and G. Bassett Jr. (1978). Regression Quantiles. Econometrica, 46(1), 33–50.
Oka, T. and Z. Qu (2011). Estimating Structural Changes in Regression Quantiles. Journal of Econometrics, 162(2), 248–267.
## data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] ## quantile v.tau = 0.8 ## break date vec.date = 146 # cross-sectional size n.size = 1 ## estimation rq.est.full(y, x, v.tau, vec.date, n.size)## data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] ## quantile v.tau = 0.8 ## break date vec.date = 146 # cross-sectional size n.size = 1 ## estimation rq.est.full(y, x, v.tau, vec.date, n.size)
This function estimates the coefficients for each regime, given the break dates.
rq.est.regime(y, x, v.tau, vec.date, n.size = 1)rq.est.regime(y, x, v.tau, vec.date, n.size = 1)
y |
A vector of dependent variables ( |
x |
A matrix of regressors ( |
v.tau |
The quantile of interest. |
vec.date |
A vector of estimated break dates. |
n.size |
The cross-sectional sample size ( |
A list containing the estimated coefficients for each regime.
## data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] ## quantile v.tau = 0.8 ## break date vec.date = 146 # cross-sectional size n.size = 1 ## estimation result = rq.est.regime(y, x, v.tau, vec.date, n.size) print(result)## data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] ## quantile v.tau = 0.8 ## break date vec.date = 146 # cross-sectional size n.size = 1 ## estimation result = rq.est.regime(y, x, v.tau, vec.date, n.size) print(result)
This procedure sequentially applies the SQ test to determine the number of breaks, based on a single quantile.
sq(y, x, v.tau, n.size = 1, m.max, trim.size, mat.date)sq(y, x, v.tau, n.size = 1, m.max, trim.size, mat.date)
y |
A numeric vector of dependent variables ( |
x |
A numeric matrix of regressors ( |
v.tau |
A numeric value representing the quantile of interest. |
n.size |
An integer specifying the size of the cross-section ( |
m.max |
An integer specifying the maximum number of breaks allowed. |
trim.size |
A numeric value specifying the trimming size (the minimum length of a segment). |
mat.date |
A numeric matrix of break dates. |
A list with the following components:
testA numeric vector of SQ test statistics.
cvA numeric matrix of critical values for the SQ test, with the 1st, 2nd, and 3rd rows corresponding to the 10%, 5%, and 1% significance levels.
dateA numeric matrix of break dates, with the 1st, 2nd, and 3rd rows corresponding to the 10%, 5%, and 1% significance levels.
nbreakA numeric vector indicating the number of breaks at the 10%, 5%, and 1% significance levels.
## data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] ## quantile v.tau = 0.8 # cross-sectional size n.size = 1 # the maximum number of breaks m.max = 3 ## trim T.size = length(y) trim.e = 0.2 trim.size = round(T.size * trim.e) #minimum length of a regime # get.long out.long = gen.long(y, x, v.tau, n.size, trim.size) mat.long.s = out.long$mat.long ## for individual quantile # mat.date mat.date = brdate(y, x, n.size, m.max, trim.size, mat.long.s) # sq result = sq(y, x, v.tau, n.size, m.max, trim.size, mat.date) print(result)## data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] ## quantile v.tau = 0.8 # cross-sectional size n.size = 1 # the maximum number of breaks m.max = 3 ## trim T.size = length(y) trim.e = 0.2 trim.size = round(T.size * trim.e) #minimum length of a regime # get.long out.long = gen.long(y, x, v.tau, n.size, trim.size) mat.long.s = out.long$mat.long ## for individual quantile # mat.date mat.date = brdate(y, x, n.size, m.max, trim.size, mat.long.s) # sq result = sq(y, x, v.tau, n.size, m.max, trim.size, mat.date) print(result)
The function implements a break test to evaluate whether a single structural break exists at a given quantile.
sq.test.0vs1(y, x, v.tau, n.size = 1)sq.test.0vs1(y, x, v.tau, n.size = 1)
y |
A numeric vector of dependent variables ( |
x |
A numeric matrix of regressors ( |
v.tau |
A numeric value representing the quantile level. |
n.size |
An integer specifying the size of the cross-section ( |
A numeric value representing the test statistic for the presence of a structural break.
Koenker, R. and G. Bassett Jr, (1978). Regression Quantiles. Econometrica, 46(1), 33–50.
Qu, Z. (2008). Testing for Structural Change in Regression Quantiles. Journal of Econometrics, 146(1), 170–184.
## data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] ## quantile v.tau = 0.8 # cross-sectional size n.size = 1 # sq test: 0 vs 1 result = sq.test.0vs1(y, x, v.tau, n.size) print(result)## data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] ## quantile v.tau = 0.8 # cross-sectional size n.size = 1 # sq test: 0 vs 1 result = sq.test.0vs1(y, x, v.tau, n.size) print(result)
This function tests the null hypothesis of breaks against the alternative hypothesis of breaks
in a single conditional quantile.
sq.test.lvsl_1(y, x, v.tau, n.size = 1, vec.date)sq.test.lvsl_1(y, x, v.tau, n.size = 1, vec.date)
y |
A numeric vector of dependent variables ( |
x |
A numeric matrix of regressors ( |
v.tau |
A numeric value representing the quantile of interest. |
n.size |
An integer specifying the size of the cross-section ( |
vec.date |
A numeric vector of break dates estimated under the null hypothesis. |
The function sequentially tests for breaks by splitting the sample conditional on the
break dates under the null hypothesis. At each step, it applies sq.test.0vs1() to compare
the hypothesis of no additional break against one more break.
A numeric value representing the test statistic.
Qu, Z. (2008). Testing for Structural Change in Regression Quantiles. Journal of Econometrics, 146(1), 170-184.
Oka, T. and Z. Qu (2011). Estimating Structural Changes in Regression Quantiles. Journal of Econometrics, 162(2), 248-267.
## data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] ## quantile v.tau = 0.8 # cross-sectional size n.size = 1 ## break date vec.date = 146 ## sq-test: 1 vs 2 result = sq.test.lvsl_1(y, x, v.tau, n.size, vec.date) print(result)## data data(gdp) y = gdp$gdp x = gdp[,c("lag1", "lag2")] ## quantile v.tau = 0.8 # cross-sectional size n.size = 1 ## break date vec.date = 146 ## sq-test: 1 vs 2 result = sq.test.lvsl_1(y, x, v.tau, n.size, vec.date) print(result)