• No results found

strucchange: An R Package for Testing for Structural Change in Linear Regression Models

N/A
N/A
Protected

Academic year: 2021

Share "strucchange: An R Package for Testing for Structural Change in Linear Regression Models"

Copied!
38
0
0

Loading.... (view fulltext now)

Full text

(1)

strucchange

: An

R

Package for Testing for Structural

Change in Linear Regression Models

Achim Zeileis

1

Friedrich Leisch

1

Kurt Hornik

1

Christian Kleiber

2 1 Institut f¨ur Statistik & Wahrscheinlichkeitstheorie, Technische Universit¨at Wien,

e-mail:[email protected]

2 Institut f¨ur Wirtschafts- und Sozialstatistik, Universit¨at Dortmund, e-mail:[email protected]

Abstract

This paper reviews tests for structural change in linear regression models from the generalized fluctuation test framework as well as from theF test (Chow test) framework. It introduces a unified approach for implementing these tests and presents how these ideas have been realized in anRpackage calledstrucchange. Enhancing the standard significance test approach the package contains methods to fit, plot and test empirical fluctuation processes (like CUSUM, MOSUM and estimates-based processes) and to compute, plot and test sequences ofF statistics with the supF, aveF and expFtest. Thus, it makes powerful tools available to display information about structural changes in regression relationships and to assess their significance. Furthermore, it is described how incoming data can be monitored.

Keywords: structural change, CUSUM, MOSUM, recursive estimates, moving estimates,

mon-itoring,R, S.

1

Introduction

The problem of detecting structural changes in linear regression relationships has been an im-portant topic in statistical and econometric research. The most imim-portant classes of tests on structural change are the tests from the generalized fluctuation test framework (Kuan and Hornik,1995) on the one hand and tests based onF statistics (Hansen,1992b;Andrews,1993;

Andrews and Ploberger,1994) on the other. The first class includes in particular the CUSUM and MOSUM tests and the fluctuation test, while the Chow and the supF test belong to the latter. A topic that gained more interest rather recently is to monitor structural change, i.e., to start after a history phase (without structural changes) to analyze new observations and to be able to detect a structural change as soon after its occurrence as possible.

This paper concerns ideas and methods for implementing generalized fluctuation tests as well asF tests in a comprehensive and flexible way, that reflects the common features of the testing procedures. It also offers facilities to display the results in various ways. These ideas have been realized in a package calledstrucchange in theRsystem1 for statistical computing, the GNU implementation of theSlanguage. The package can be downloaded from the ComprehensiveR

Archive Network (CRAN)http://cran.R-project.org/, where updated or extended future

(2)

versions of the package will also be available.

This paper is organized as follows: In Section 2 the standard linear regression model upon which all tests are based will be described and the testing problem will be specified. Section3

introduces a data set which is also available in the package and which is used for the examples in this paper. The following sections 4, 5 and 6 will then explain the tests, how they are implemented instrucchangeand give examples for each. Section4is concerned with computing empirical fluctuation processes, with plotting them and the corresponding boundaries and finally with testing for structural change based on these processes. Analogously, Section5 introduces theF statistics and their plotting and testing methods before Section6extends the tools from Section4for the monitoring case.

2

The model

Consider the standard linear regression model

yi=x>i βi+ui (i= 1, . . . , n), (1)

where at timei,yiis the observation of the dependent variable,xi= (1, xi2, . . . , xik)> is ak×1

vector of observations of the independent variables, with the first component equal to unity,ui

are iid(0, σ2), and βi is the k×1 vector of regression coefficients. Tests on structural change

are concerned with testing the null hypothesis of “no structural change”

H0: βi=β0 (i= 1, . . . , n) (2)

against the alternative that the coefficient vector varies over time, with certain tests being more or less suitable (i.e., having good or poor power) for certain patterns of deviation from the null hypothesis.

It is assumed that the regressors are nonstochastic with||xi||=O(1) and that

1 n n X i=1 xix>i −→ Q (3)

for some finite regular matrixQ. These are strict regularity conditions excluding trends in the data which are assumed for simplicity. For some tests these assumptions can be extended to dynamic models without changing the main properties of the tests; but as these details are not part of the focus of this work they are omitted here.

In what follows ˆβ(i,j) is the ordinary least squares (OLS) estimate of the regression coefficients

based on the observationsi+ 1, . . . , i+j, and ˆβ(i) = ˆβ(0,i) is the OLS estimate based on all observations up toi. Hence ˆβ(n) is the common OLS estimate in the linear regression model.

SimilarlyX(i) is the regressor matrix based on all observations up toi. The OLS residuals are

denoted as ˆui =yi−x>i βˆ(n) with the variance estimate ˆσ2 = n−1k

Pn

i=1uˆ 2

i. Another type of

residuals that are often used in tests on structural change are the recursive residuals

˜ ui = yi−x>i βˆ(i−1) q 1 +x> i X(i−1) > X(i−1)−1 xi (i=k+ 1, . . . , n), (4)

which have zero mean and varianceσ2 under the null hypothesis. The corresponding variance

estimate is ˜σ2= 1

n−k

Pn

(3)

3

The data

The data used for examples throughout this paper are macroeconomic time series from the USA. The data set contains the aggregated monthly personal income and personal consumption ex-penditures (in billion US dollars) between January 1959 and February 2001, which are seasonally adjusted at annual rates. It was originally taken from http://www.economagic.com/, a web site for economic times series. Both time series are depicted in Figure1.

Time billion US$ 1960 1970 1980 1990 2000 0 2000 4000 6000 8000 incomeexpenditures

Figure 1: Personal income and personal consumption expenditures in the US

The data is available in thestrucchangepackage: it can be loaded and a suitable subset chosen by

R> library(strucchange) R> data(USIncExp) R> library(ts)

R> USIncExp2 <- window(USIncExp, start = c(1985,12))

We use a simple error correction model (ECM) for the consumption function similar toHansen

(1992a):

∆ct = β1+β2et−1+β3∆it+ut, (5)

et = ct−α1−α2it, (6)

where ct is the consumption expenditure and it the income. We estimate the cointegration

equation (6) by OLS and use the residuals ˆet as regressors in equation (5), in which we will

test for structural change. Thus, the dependent variable is the increase in expenditure and the regressors are the cointegration residuals and the increments of income (and a constant). To compute the cointegration residuals and set up the model equation we need the following steps inR:

R> coint.res <- residuals(lm(expenditure ~ income, data = USIncExp2)) R> coint.res <- lag(ts(coint.res, start = c(1985,12), freq = 12), k = -1) R> USIncExp2 <- cbind(USIncExp2, diff(USIncExp2), coint.res)

(4)

R> colnames(USIncExp2) <- c("income", "expenditure", "diff.income", "diff.expenditure", "coint.res") R> ecm.model <- diff.expenditure ~ coint.res + diff.income

Figure2shows the transformed time series necessary for estimation of equation (5).

−200 −100 0 100 200 diff.income −40 0 20 40 60 80 diff.expenditure −150 −50 0 50 100 coint.res 1990 1995 2000 Time

Figure 2: Time series used – first differences and cointegration residuals

In the following sections we will apply the methods introduced to test for structural change in this model.

4

Generalized fluctuation tests

The generalized fluctuation tests fit a model to the given data and derive an empirical process, that captures the fluctuation either in residuals or in estimates. For these empirical processes the limiting processes are known, so that boundaries can be computed, whose crossing probability under the null hypothesis is α. If the empirical process path crosses these boundaries, the fluctuation is improbably large and hence the null hypothesis should be rejected (at significance levelα).

4.1

Empirical fluctuation processes: function

efp

Given a formula that describes a linear regression model to be tested the functionefpcreates an object of class"efp"which contains a fitted empirical fluctuation process of a specified type.

(5)

The types available will be described in detail in this section.

CUSUM processes: The first type of processes that can be computed are CUSUM processes,

which contain cumulative sums of standardized residuals. Brown et al. (1975) suggested to consider cumulative sums of recursive residuals:

Wn(t) = 1 ˜ σ√η k+btηc X i=k+1 ˜ ui (0≤t≤1), (7)

whereη=n−kis the number of recursive residuals andbtηcis the integer part oftη.

Under the null hypothesis the limiting process for the empirical fluctuation processWn(t) is the

Standard Brownian Motion (or Wiener Process)W(t). More precisely the following functional central limit theorem (FCLT) holds:

Wn=⇒W, (8)

asn→ ∞, where⇒denotes weak convergence of the associated probability measures.

Under the alternative, if there is just a single structural change pointt0, the recursive residuals

will only have zero mean up tot0. Hence the path of the process should be close to 0 up to

t0 and leave its mean afterwards. Kr¨amer et al. (1988) show that the main properties of the

CUSUM quantity remain the same even under weaker assumptions, in particular in dynamic models. Thereforeefphas the logical argumentdynamic; if set toTRUEthe lagged observations xt−1 will be included as regressors.

Ploberger and Kr¨amer (1992) suggested to base a structural change test on cumulative sums of the common OLS residuals. Thus, the OLS-CUSUM type empirical fluctuation process is defined by: Wn0(t) = 1 ˆ σ√n bntc X i=1 ˆ ui (0≤t≤1). (9)

The limiting process for W0

n(t) is the standard Brownian bridge W0(t) = W(t)−tW(1). It

starts in 0 att= 0 and it also returns to 0 fort= 1. Under a single structural shift alternative the path should have a peak aroundt0.

These processes are available in the functionefpby specifying the argumenttypeto be either "Rec-CUSUM"or"OLS-CUSUM", respectively.

MOSUM processes: Another possibility to detect a structural change is to analyze moving

sums of residuals (instead of using cumulative sums of the same residuals). The resulting empirical fluctuation process does then not contain the sum of all residuals up to a certain timetbut the sum of a fixed number of residuals in a data window whose size is determined by the bandwidth parameterh∈(0,1) and which is moved over the whole sample period. Hence the Recursive MOSUM process is defined by

Mn(t|h) = 1 ˜ σ√η k+bNηtc+bηhc X i=k+bNηtc+1 ˜ ui (0≤t≤1−h) (10) = Wn bN ηtc+bηhc η −Wn bN ηtc η , (11)

(6)

whereNη= (η− bηhc)/(1−h). Similarly the OLS-based MOSUM process is defined by Mn0(t|h) = 1 ˆ σ√n   bNntc+bnhc X i=bNntc+1 ˆ ui   (0≤t≤1−h) (12) = Wn0 bN ntc+bnhc n −Wn0 bN ntc n , (13)

where Nn = (n− bnhc)/(1−h). As the representations (11) and (13) suggest, the limiting

process for the empirical MOSUM processes are the increments of a Brownian motion or a Brownian bridge respectively. This is shown in detail inChu et al.(1995a).

If again a single structural shift is assumed att0, then both MOSUM paths should also have a

strong shift aroundt0.

The MOSUM processes will be computed if type is set to "Rec-MOSUM" or "OLS-MOSUM", re-spectively.

Estimates-based processes: Instead of defining fluctuation processes on the basis of residuals

they can be equally well based on estimates of the unknown regression coefficients. With the same ideas as for the residual-based CUSUM- and MOSUM-type processes thek×1-vector β is either estimated recursively with a growing number of observations or with a moving data window of constant bandwidthhand then compared to the estimates based on the whole sample. The former idea leads to the fluctuation process in the spirit ofPloberger et al.(1989) which is defined by Yn(t) = √ i ˆ σ√n X(i)>X(i) 1 2 ˆ β(i)−βˆ(n), (14) wherei=bk+t(n−k)cwitht∈[0,1]. And the latter gives the moving estimates (ME) process introduced byChu et al.(1995b):

Zn(t|h) = p bnhc ˆ σ√n X(bntc,bnhc)>X(bntc,bnhc) 1 2 ˆ β(bntc,bnhc)−βˆ(n), (15) where 0 ≤ t ≤ 1−h. Both are k-dimensional empirical processes. Thus, the limiting pro-cesses are ak-dimensional Brownian Bridge or the increments thereof respectively. Instead of rescaling the processes for eachi they can also be standardized by X(n)>X(n)

1 2

. This has the advantage that it has to be calculated only once, butKuan and Chen (1994) showed that if there are dependencies between the regressors the rescaling improves the empirical size of the resulting test. Heuristically the rescaled empirical fluctuation process “looks” more like its theoretic counterpart.

Under a single shift alternative the recursive estimates processes should have a peak and the moving estimates process should again have a shift close to the shift pointt0.

Fortype="fluctuation"the functionefpreturns the recursive estimates process, whereas for "ME"the moving estimates process is returned.

All six processes may be fitted using the function efp. For our example we want to fit an OLS-based CUSUM process, and a moving estimates (ME) process with bandwidthh = 0.2. The commands are simply

(7)

R> ocus <- efp(ecm.model, type="OLS-CUSUM", data=USIncExp2) R> me <- efp(ecm.model, type="ME", data=USIncExp2, h=0.2)

These return objects of class"efp" which contain mainly the empirical fluctuation processes and a few further attributes like the process type. The process itself is of class"ts"(the basic time series class inR), which either preserves the time properties of the dependent variable if this is a time series (like in our example), or which is standardized to the interval [0,1] (or a subinterval). For the MOSUM and ME processes the centered interval [h/2,1−h/2] is chosen rather than [0,1−h] as in (10) and (12).

Any other process type introduced in this section can be fitted by setting thetypeargument. The fitted process can then be printed, plotted or tested with the corresponding test on struc-tural change. For the latter appropriate boundaries are needed; the concept of boundaries for fluctuation processes is explained in the next section.

4.2

Boundaries and plotting

The idea that is common to all generalized fluctuation tests is that the null hypothesis of “no structural change” should be rejected when the fluctuation of the empirical processefp(t) gets improbably large compared to the fluctuation of the limiting process. For the one-dimensional residual-based processes this comparison is performed by some appropriate boundaryb(t), that the limiting process just crosses with a given probabilityα. Thus, ifefp(t) crosses either b(t) or −b(t) for any t then it has to be concluded that the fluctuation is improbably large and the null hypothesis can be rejected at confidence levelα. The procedure for thek-dimensional estimates-based processes is similar, but instead of a boundary for the process itself a boundary for ||efpi(t)|| is used, where || · || is an appropriate functional which is applied component-wise. We have implemented the functionals ‘max’ and ‘range’. The null hypothesis is rejected if ||efpi(t)|| gets larger than a constant λ, which depends on the confidence level α, for any i= 1, . . . , k.

The boundaries for the MOSUM processes are also constants, i.e., of form b(t) = λ, which seems natural as the limiting processes are stationary. The situation for the CUSUM processes is different though. Both limiting processes, the Brownian motion and the Brownian bridge, respectively, are not stationary. It would seem natural to use boundaries that are proportional to the standard deviation function of the corresponding theoretic process, i.e.,

b(t) = λ·√t (16)

b(t) = λ·p

t(1−t) (17)

for the Recursive CUSUM and the OLS-based CUSUM path respectively, whereλ determines the confidence level. But the boundaries that are commonly used are linear, because a closed form solution for the crossing probability is known. So the standard boundaries for the two proccess are of type

b(t) = λ·(1 + 2t) (18)

b(t) = λ. (19)

They were chosen because they are tangential to the boundaries (16) and (17) respectively in t = 0.5. However,Zeileis (2000a) examined the properties of the alternative boundaries (16) and (17) and showed that the resulting OLS-based CUSUM test has better power for structural changes early and late in the sample period.

(8)

Given a fitted empirical fluctuation process the boundaries can be computed very easily using the functionboundary, which returns a time series object with the same time properties as the given fluctuation process:

R> bound.ocus <- boundary(ocus, alpha=0.05)

It is also rather convenient to plot the process with its boundaries for some confidence levelα (by default 0.05) to see whether the path exceeds the boundaries or not: The result of

R> plot(ocus)

is shown in Figure3.

OLS−based CUSUM test

Time

empirical fluctuation process

1990 1995 2000

−1.5

−0.5

0.5

1.0

Figure 3: OLS-based CUSUM process

It can be seen that the OLS-based CUSUM process exceeds its boundary; hence there is evi-dence for a structural change. Furthermore the process seems to indicate two changes: one in the first half of the 1990s and another one at the end of 1998.

It is also possible to suppress the boundaries and add them afterwards, e.g. in another color

R> plot(ocus, boundary = FALSE) R> lines(bound.ocus, col = 4) R> lines(-bound.ocus, col = 4)

For estimates-based processes it is only sensible to use time series plots if the functional ‘max’ is used because it is equivalent to rejecting the null hypothesis when maxi=1,...,k||efp(t)||gets

large or when maxtmaxi=1,...,kefpi(t) gets large. This again is equivalent to any one of the

(one-dimensinal) processesefpi(t) fori= 1, . . . , k exceeding the boundary. The k-dimensional process can also be plotted by specifying the parameterfunctional(which defaults to"max") asNULL:

R> plot(me, functional = NULL)

The output fromRcan be seen in Figure4, where the three parts of the plot show the processes that correspond to the estimate of the regression coefficients of the intercept, the cointegration

(9)

−1.5 −0.5 0.0 0.5 1.0 (Intercept) −1.5 −1.0 −0.5 0.0 0.5 coint.res −0.5 0.0 0.5 1.0 diff.income 1988 1990 1992 1994 1996 1998 2000 Time

ME test (moving estimates test)

Figure 4: 3-dimensional moving estimates process

residuals and the increments of income, respectively. All three paths show two shifts: the first shift starts at the beginning of the sample period and ends in about 1991 and the second shift occurs at the very end of the sample period. The shift that causes the significance seems to be the strong first shift in the process for the intercept and the cointegration residuals, because these cross their boundaries. Thus, the ME test leads to similar results as the OLS-based CUSUM test, but provides a little more information about the nature of the structural change.

4.3

Significance testing with empirical fluctuation processes

Although calculating and plotting the empiricial fluctuation process with its boundaries provides and visualizes most of the information, it might still be necessary or desirable to carry out a traditional significance test. This can be done easily with the functionsctest(structural change test) which returns an object of class "htest" (R’s standard class for statistical test results) containing in particular the test statistic and the corresponding p value. The test statistics reflect what was described by the crossing of boundaries in the previous section. Hence the test statistic isSrfrom (20) for the residual-based processes andSefrom (21) for the estimates-based

processes: Sr = max t efp(t) f(t) , (20) Se = max||efp(t)||, (21)

(10)

where f(t) depends on the shape of the boundary, i.e., b(t) = λ·f(t). For most boundaries is f(t) ≡ 1, but the linear boundary for the Recursive CUSUM test for example has shape f(t) = 1 + 2t.

It is either possible to supply sctest with a fitted empirical fluctuation process or with a formula describing the model that should be tested. Thus, the commands

R> sctest(ocus)

R> sctest(ecm.model, type="OLS-CUSUM", data=USIncExp2)

lead to equivalent results:

OLS-based CUSUM test data: ecm.model

S0 = 1.5511, p-value = 0.01626

sctestis a generic function which has methods not only for fluctuation tests, but all structural change tests (on historic data) introduced in this paper including theF tests described in the next section.

5

F

tests

A rather different approach to investigate whether the null hypothesis of “no structural change” holds, is to useF test statistics. An important difference is that the alternative is specified: whereas the generalized fluctuation tests are suitable for various patterns of structural changes, theF tests are designed to test against a single shift alternative. Thus, the alternative can be formulated on the basis of the model (1)

βi=

βA (1≤i≤i0)

βB (i0< i≤n)

, (22)

wherei0 is some change point in the interval (k, n−k). Chow (1960) was the first to suggest

such a test on structural change for the case where the (potential) change pointi0 is known.

He proposed to fit two separate regressions for the two subsamples defined byi0 and to reject

whenever Fi0 = ˆ u>uˆ−eˆ>eˆ ˆ e>ˆe/(n2k). (23)

is too large, where ˆe= (ˆuA,ˆuB)> are the residuals from the full model, where the coefficients

in the subsamples are estimated separately, and ˆuare the residuals from the restricted model, where the parameters are just fitted once for all observations. The test statisticFi0 has an

asymptoticχ2 distribution withkdegrees of freedom and (under the assumption of normality) Fi0/k has an exactF distribution withkandn−2kdegrees of freedom. The major drawback

of this “Chow test” is that the change point has to be known in advance, but there are tests based uponF statistics (Chow statistics), that do not require a specification of a particular change point and which will be introduced in the following sections.

5.1

F

statistics: function

Fstats

A natural idea to extend the ideas from the Chow test is to calculate the F statistics for all potential change points or for all potential change points in an interval [i, ı] and to reject if any

(11)

of those statistics get too large. Therefore the first step is to compute theF statistics Fi for

k < i≤i≤ı < n−k, which can be easily done using the functionFstats. Again the model to be tested is specified by a formula interface and the parametersiand ıare respresented by from and to, respectively. Alternatively to indices of observations these two parameters can also be specified by fractions of the sample; the default is to takefrom = 0.15and implicitly to = 0.85. To compute the F test statistics for all potential change points between January 1990 and June 1999 the appropriate command would be:

R> fs <- Fstats(ecm.model, from = c(1990, 1), to = c(1999,6), data = USIncExp2)

This returns an object of class "Fstats"which mainly contains a time series of F statistics. Analogously to the empiricial fluctuation processes these objects can be printed, plotted and tested.

5.2

Boundaries and plotting

The computation of boundaries and plotting ofF statistics is rather similar to that of empir-ical fluctuation processes introduced in the previous section. Under the null hypthesis of no structural change boundaries can be computed such that the asymptotic probability that the supremum (or the mean) of the statisticsFi (fori≤i≤ı) exceeds this boundary is α. So the

command

R> plot(fs)

plots the process ofF statistics with its boundary; the output can be seen in Figure5. As theF

Time F statistics 1990 1992 1994 1996 1998 0 5 10 15 20 Figure 5: F statistics

statistics cross their boundary, there is evidence for a structural change (at the levelα= 0.05). The process has a clear peak in 1998, which mirrors the results from the analysis by empirical fluctuation processes and tests, respectively, that also indicated a break in the late 1990s. It is also possible to plot thepvalues instead of theF statistics themselves by

(12)

which leads to equivalent results. Furthermore it is also possible to set up the boundaries for the average instead of the supremum by:

R> plot(fs, aveF=TRUE)

In this case another dashed line for the observed mean of theF statistics will be drawn.

5.3

Significance testing with

F

statistics

As already indicated in the previous section, there is more than one possibility to aggregate the series ofF statistics into a test statistic. Andrews(1993) and Andrews and Ploberger (1994) respectively suggested three different test statistics and examined their asymptotic distribution:

supF = sup i≤i≤ı Fi, (24) aveF = 1 ı−i+ 1 ı X i=i Fi, (25) expF = log   1 ı−i+ 1 ı X i=i exp(0.5·Fi)  . (26)

The supF statistic in (24) and the aveF statistic from (25) respectively reflect the testing procedures that have been described above. Either the null hypothesis is rejected when the maximal or the meanF statistic gets too large. A third possibility is to reject when the expF statistic from (26) gets too large. The aveF and expF test have certain optimality properties (Andrews and Ploberger,1994). The tests can be carried out in the same way as the fluctuation tests: either by supplying the fittedFstatsobject or by a formula that describes the model to be tested. Hence both commands

R> sctest(fs, type="expF")

R> sctest(ecm.model, type = "expF", from = 49, to = 162, data = USIncExp2)

lead to equivalent output:

expF test data: ecm.model

exp.F = 8.9955, p-value = 0.001311

Thepvalues are computed based onHansen(1997).2

6

Monitoring with the generalized fluctuation test

In the previous sections we were concerned with the retrospective detection of structural changes in given data sets. Over the last years several structural change tests have been extended to monitoring of linear regression models where new data arrive over time (Chu et al., 1996;

Leisch et al., 2000). Such forward looking tests are closely related to sequential tests. When new observations arrive, estimates are computed sequentially from all available data (historical

2The authors thank Bruce Hansen, who wrote the original code for computingp values forF statistics in

(13)

sample plus newly arrived data) and compared to the estimate based only on the historical sample. As in the retrospective case, the hypothesis of no structural change is rejected if the difference between these two estimates gets too large.

The standard linear regression model (1) is generalized to

yi =x>i βi+ui (i= 1, . . . , n, n+ 1, . . .), (27)

i.e., we expect new observations to arrive after time n (when the monitoring begins). The sample{(x1, y1), . . . ,(xn, yn)}will be called thehistoric sample, the corresponding time period

1, . . . , nthehistory period.

Currently monitoring has only been developed for recursive (Chu et al., 1996) and moving (Leisch et al., 2000) estimates tests. The respective limiting processes are—as in the retro-spective case—the Brownian Bridge and increments of the Brownian Bridge. The empirical processes are rescaled to map the history period to the interval [0,1] of the Brownian Bridge. For recursive estimates there exists a closed form solution for boundary functions, such that the limiting Brownian Bridge stays within the boundaries on the interval (1,∞) with probability 1−α. Note that the monitoring period consisting of all data arriving after the history period corresponds to the Brownian Bridge after time 1. For moving estimates, only the growth rate of the boundaries can be derived analytically and critical values have to be simulated.

Consider that we want to monitor our ECM during the 1990s for structural change, using years 1986–1989 as the history period. First we cut the historic sample from the complete data set and create an object of class"mefp":

R> USIncExp3 <- window(USIncExp2, start = c(1986, 1), end = c(1989,12)) R> me.mefp <- mefp(ecm.model, type = "ME", data = USIncExp3, alpha = 0.05)

Because monitoring is a sequential test procedure, the significance level has to be specified in advance, i.e., when the object of class "mefp" is created. The "mefp" object can now be monitored repeatedly for structural changes.

Let us assume we get new observations for the year 1990. Calling functionmonitoronme.mefp automatically updates our monitoring object for the new observations and runs a sequential test for structural change on each new observation (no structural break is detected in 1990):

R> USIncExp3 <- window(USIncExp2, start = c(1986, 1), end = c(1990,12)) R> me.mefp <- monitor(me.mefp)

Then new data for the years 1991–2001 arrive and we repeat the monitoring:

R> USIncExp3 <- window(USIncExp2, start = c(1986, 1)) R> me.mefp <- monitor(me.mefp)

Break detected at observation # 72 R> me.mefp

Monitoring with ME test (moving estimates test) Initial call:

mefp.formula(formula = ecm.model, type = "ME", data = USIncExp3, alpha = 0.05) Last call:

monitor(obj = me.mefp) Significance level : 0.05 Critical value : 3.109524 History size : 48 Last point evaluated : 182 Structural break at : 72

(14)

Parameter estimate on history : (Intercept) coint.res diff.income

18.9299679 -0.3893141 0.3156597 Last parameter estimate :

(Intercept) coint.res diff.income 27.94869106 0.00983451 0.13314662

The software informs us that a structural break has been detected at observation #72, which corresponds to December 1991. Boundary and plotting methods for "mefp"objects work (al-most) exactly as their"efp"counterparts, only the significance levelalphacannot be specified, because it is specified when the"mefp" object is created. The output of plot(me.mefp) can be seen in Figure6.

Monitoring with ME test (moving estimates test)

Time

empirical fluctuation process

1990 1992 1994 1996 1998 2000 0 2 4 6 8

Figure 6: Monitoring structural change with bandwidthh= 1

Instead of creating an "mefp" object using the formula interface like above, it could also be done re-using an existing"efp"object, e.g.:

R> USIncExp3 <- window(USIncExp2, start = c(1986, 1), end = c(1989,12)) R> me.efp <- efp(ecm.model, type = "ME", data = USIncExp3, h = 0.5) R> me.mefp <- mefp(me.efp, alpha=0.05)

If now again the new observations up to February 2001 arrive, we can monitor the data

R> USIncExp3 <- window(USIncExp2, start = c(1986, 1)) R> me.mefp <- monitor(me.mefp)

Break detected at observation # 70

and discover the structural change even two observations earlier as we used the bandwidth h=0.5 instead of h=1. Due to this we have not one history estimate that is being compared with the new moving estimates, but we have a history process, which can be seen on the left in Figure7. This plot can simply be generated by

R> plot(me.mefp)

The results of the monitoring emphasize the results of the historic tests: the moving estimates process has two strong shifts, the first around 1992 and the second around 1998.

(15)

Monitoring with ME test (moving estimates test)

Time

empirical fluctuation process

1988 1990 1992 1994 1996 1998 2000 0 1 2 3 4

Figure 7: Monitoring structural change with bandwidthh= 0.5

7

Conclusions

In this paper, we have described thestrucchange package that implements methods for test-ing for structural change in linear regression relationships. It provides a unified framework for displaying information about structural changes flexibly and for assessing their significance according to various tests.

Containing tests from the generalized fluctuation test framework as well as tests based onF statistics (Chow test ststistics) the package extends standard significance testing procedures: There are methods for fitting empirical fluctuation processes (CUSUM, MOSUM and estimates-based processes), computing an appropriate boundary, plotting these results and finally carrying out a formal significance test. Analogously a sequence ofF statistics with the corresponding boundary can be computed, plotted and tested. Finally the methods for estimates-based fluc-tuation processes have extensions to monitor incoming data.

Acknowledgements

This research of Achim Zeileis, Friedrich Leisch and Kurt Hornik was supported by the Aus-trian Science Foundation (FWF) under grant SFB#010 (‘Adaptive Information Systems and Modeling in Economics and Management Science’).

The work of Christian Kleiber was supported by the Deutsche Forschungsgemeinschaft, Son-derforschungsbereich 475.

(16)

References

D. W. K. Andrews. Tests for parameter instability and structural change with unknown change point. Econometrica, 61:821–856, 1993.

D. W. K. Andrews and W. Ploberger. Optimal tests when a nuisance parameter is present only under the alternative. Econometrica, 62:1383–1414, 1994.

R. L. Brown, J. Durbin, and J. M. Evans. Techniques for testing the constancy of regression relationships over time. Journal of the Royal Statistical Society, B 37:149–163, 1975.

G. C. Chow. Tests of equality between sets of coefficients in two linear regressions.Econometrica, 28:591–605, 1960.

C.-S. J. Chu, K. Hornik, and C.-M. Kuan. MOSUM tests for parameter constancy.Biometrika, 82:603–617, 1995a.

C.-S. J. Chu, K. Hornik, and C.-M. Kuan. The moving-estimates test for parameter stability. Econometric Theory, 11:669–720, 1995b.

C.-S. J. Chu, M. Stinchcombe, and H. White. Monitoring structural change. Econometrica, 64 (5):1045–1065, 1996.

B. E. Hansen. Testing for parameter instability in linear models. Journal of Policy Modeling, 14:517–533, 1992a.

B. E. Hansen. Tests for parameter instability in regressions with I(1) processes. Journal of Business & Economic Statistics, 10:321–335, 1992b.

B. E. Hansen. Approximate asymptoticpvalues for structural-change tests.Journal of Business & Economic Statistics, 15:60–67, 1997.

W. Kr¨amer, W. Ploberger, and R. Alt. Testing for structural change in dynamic models. Econometrica, 56(6):1355–1369, 1988.

C.-M. Kuan and M.-Y. Chen. Implementing the fluctuation and moving-estimates tests in dynamic econometric models. Economics Letters, 44:235–239, 1994.

C.-M. Kuan and K. Hornik. The generalized fluctuation test: A unifying view. Econometric Reviews, 14:135–161, 1995.

F. Leisch, K. Hornik, and C.-M. Kuan. Monitoring structural changes with the generalized fluctuation test. Econometric Theory, 16:835–854, 2000.

W. Ploberger and W. Kr¨amer. The CUSUM test with OLS residuals. Econometrica, 60(2): 271–285, 1992.

W. Ploberger, W. Kr¨amer, and K. Kontrus. A new test for structural stability in the linear regression model. Journal of Econometrics, 40:307–318, 1989.

A. Zeileis.pvalues and alternative boundaries for CUSUM tests. Working Paper 78, SFB “Adap-tive Information Systems and Modelling in Economics and Management Science”, December 2000a. URLhttp://www.wu-wien.ac.at/am/wp00.htm#78.

A. Zeileis.p-Werte und alternative Schranken von CUSUM-Tests. Master’s thesis, Fachbereich Statistik, Universit¨at Dortmund, 2000b. URL http://www.ci.tuwien.ac.at/~zeileis/

(17)

A

Implementation details for

p

values

An important and useful tool concerning significance tests arepvalues, especially for applica-tion in a software package. Their implementaapplica-tion is therefore crucial and in this secapplica-tion we will give more detail about the implementation in thestrucchangepackage.

For the CUSUM tests with linear boundaries there are rather good approximations to the asymptoticp value functions given in Zeileis(2000a). For the recursive estimates fluctuation test there is a series expansion, which is evaluated for the first hundred terms. For all other tests from the generalized fluctuation test framework thepvalues are computed by linear interpola-tion from tabulated critical values. For the Recursive CUSUM test with alternative boundaries pvalues from the interval [0.001,1] and [0.001,0.999] for the OLS-based version respectively are approximated from tables given in Zeileis (2000b). The critical values for the Recursive MOSUM test for levels in [0.01,0.2] are taken fromChu et al.(1995a), while the critical values for the levels in [0.01,0.1] for the OLS-based MOSUM and the ME test are given inChu et al.

(1995b); the parameter his in both cases interpolated for values in [0.05,0.5].

Thepvalues for the supF, aveF and expF test are approximated based onHansen(1997), who also wrote the original code inGAUSS, which we merely ported to R. The computation uses tabulated simulated regression coefficients.

B

strucchange

reference manual

This section contains the help pages from thestrucchangepackage.

boundary.efp Boundary for Empirical Fluctuation Processes

Description

Computes boundary for an object of class"efp" Usage

boundary(x, alpha = 0.05, alt.boundary = FALSE, ...)

Arguments

x an object of class"efp".

alpha numeric from interval (0,1) indicating the confidence level for which the boundary of the corresponding test will be computed.

alt.boundary logical. If set to TRUE alternative boundaries (instead of the standard linear boundaries) will be computed (for CUSUM processes only).

... currently not used.

Value

(18)

Author(s)

Achim [email protected] See Also

efp,plot.efp Examples

## Load dataset "nhtemp" with average yearly temperatures in New Haven data(nhtemp)

## plot the data plot(nhtemp)

## test the model null hypothesis that the average temperature remains constant ## over the years

## compute OLS-CUSUM fluctuation process temp.cus <- efp(nhtemp ~ 1, type = "OLS-CUSUM") ## plot the process without boundaries

plot(temp.cus, alpha = 0.01, boundary = FALSE) ## add the boundaries in another colour bound <- boundary(temp.cus, alpha = 0.01) lines(bound, col=4)

lines(-bound, col=4)

boundary.Fstats Boundary for F Statistics

Description

Computes boundary for an object of class"Fstats" Usage

boundary(x, alpha = 0.05, pval = FALSE, aveF = FALSE, asymptotic = FALSE, ...)

Arguments

x an object of class"Fstats".

alpha numeric from interval (0,1) indicating the confidence level for which the boundary of the supF test will be computed.

pval logical. If set to TRUEa boundary for the corresponding p values will be computed.

aveF logical. If set to TRUE the boundary of the aveF (instead of the supF) test will be computed. The resulting boundary then is a boundary for the mean of the F statistics rather than for the F statistics themselves. asymptotic logical. If set toTRUEthe asymptotic (chi-square) distribution instead of

the exact (F) distribution will be used to compute the p values (only if pvalisTRUE).

(19)

Value

an object of class"ts" with the same time properties as the time series inx Author(s)

Achim [email protected] See Also

Fstats,plot.Fstats Examples

## Load dataset "nhtemp" with average yearly temperatures in New Haven data(nhtemp)

## plot the data plot(nhtemp)

## test the model null hypothesis that the average temperature remains constant ## over the years for potential break points between 1941 (corresponds to ## from = 0.5) and 1962 (corresponds to to = 0.85)

## compute F statistics

fs <- Fstats(nhtemp ~ 1, from = 0.5, to = 0.85) ## plot the p values without boundary

plot(fs, pval = TRUE, alpha = 0.01) ## add the boundary in another colour

lines(boundary(fs, pval = TRUE, alpha = 0.01), col = 2)

boundary.mefp Boundary Function for Monitoring of Structural Changes

Description

Computes boundary for an object of class"mefp" Usage

boundary(x, ...) Arguments

x an object of class"mefp".

... currently not used.

Value

an object of class"ts" with the same time properties as the monitored process Author(s)

(20)

See Also

mefp,plot.mefp

Examples

df1 <- data.frame(y=rnorm(300)) df1[150:300,"y"] <- df1[150:300,"y"]+1

me1 <- mefp(y~1, data=df1[1:50,,drop=FALSE], type="ME", h=1, alpha=0.05)

me2 <- monitor(me1, data=df1) plot(me2, boundary=FALSE)

lines(boundary(me2), col="green", lty="44")

boundary Boundary Function for Structural Change Tests

Description

A generic function computing boundaries for structural change tests Usage

boundary(x, ...)

Arguments

x an object. Usemethodsto see whichclasshas a method for boundary.

... additional arguments affecting the boundary.

Value

an object of class"ts" with the same time properties as the time series inx Author(s)

Achim [email protected] See Also

(21)

covHC Heteroskedasticity-Consistent Covariance Matrix Estimation

Description

Heteroskedasticity-consistent estimation of the covariance matrix of the coefficient estimates in a linear regression model.

Usage

covHC(formula, type = c("HC2", "const", "HC", "HC1", "HC3"), tol = 1e-10, data=list())

Arguments

formula a symbolic description for the model to be tested.

type a character string specifying the estimation type. For details see below.

tol tolerance whensolveis used

data an optional data frame containing the variables in the model. By default the variables are taken from the environment whichcovHCis called from. Details

When type = "const" constant variances are assumed and and covHC gives the usual estimate of the covariance matrix of the coefficient estimates:

ˆ

σ2(X>X)−1

All other methods do not assume constant variances and are suitable in case of heteroskedas-ticity. "HC"gives White’s estimator; for details see the references.

Value

A matrix containing the covariance matrix estimate. References

MacKinnon J.G., White H. (1985), Some heteroskedasticity-consistent covariance matrix estimators with improved finite sample properties. Journal of Econometrics 29, 305-325 See Also

(22)

Examples

## generate linear regression relationship ## with homoskedastic variances

x <- sin(1:100)

y <- 1 + x + rnorm(100)

## compute usual covariance matrix of coefficient estimates covHC(y~x, type="const")

sigma2 <- sum(residuals(lm(y~x))^2)/98 sigma2 * solve(crossprod(cbind(1,x)))

efp Empirical Fluctuation Process

Description

Computes an empirical fluctuation process according to a specified method from the gen-eralized fluctuation test framework

Usage

efp(formula, data, type = <<see below>>, h = 0.15, dynamic = FALSE, rescale = TRUE, tol = 1e-7)

Arguments

formula a symbolic description for the model to be tested.

data an optional data frame containing the variables in the model. By default the variables are taken from the environment whichefpis called from. type specifies which type of fluctuation process will be computed. For details

see below.

h a numeric from interval (0,1) sepcifying the bandwidth. determins the

size of the data window relative to sample size (for MOSUM and ME processes only).

dynamic logical. If TRUE the lagged observations are included as a regressor. rescale logical. IfTRUEthe estimates will be standardized by the regressor matrix

of the corresponding subsample according to Kuan & Chen (1994); if FALSE the whole regressor matrix will be used. (only if type is either "fluctuation"or"ME")

tol tolerance whensolveis used

Details

If type is one of "Rec-CUSUM", "OLS-CUSUM", "Rec-MOSUM" or "OLS-MOSUM"the function efpwill return a one-dimensional empiricial process of sums of residuals. Either it will be based on recursive residuals or on OLS residuals and the process will contain CUmulative SUMs or MOving SUMs of residuals in a certain data window. For the MOSUM and ME

(23)

processes all estimations are done for the observations in a moving data window, whose size is determined byhand which is shifted over the whole sample.

If there is a single structural change pointt∗, the standard CUSUM path starts to depart from its mean 0 att∗. The OLS-based CUSUM path will have its peak aroundt∗. The MOSUM path should have a strong change att∗.

If type is either "fluctuation"or "ME" a k-dimensional process will be returned, if k is the number of regressors in the model, as it is based on recursive OLS estimates of the regression coefficients or moving OLS estimates respectively.

Both paths should have a peak aroundt∗ if there is a single structural shift. Value

efpreturns an object of class"efp" which inherits from the class "ts" or "mts" respec-tively, to which a string with thetypeof the process, the number of regressors (nreg), the bandwidth (h) and the function call (call) are added as attributes. The functionplothas a method to plot the empirical fluctuation process; withsctestthe corresponding test on structural change can be performed.

Author(s)

Achim [email protected] References

Brown R.L., Durbin J., Evans J.M. (1975), Techniques for testing constancy of regression relationships over time,Journal of the Royal Statistal Society, B,37, 149-163.

Chu C.-S., Hornik K., Kuan C.-M. (1995), MOSUM tests for parameter constancy,Biometrika, 82, 603-617.

Chu C.-S., Hornik K., Kuan C.-M. (1995), The moving-estimates test for parameter stabil-ity,Econometric Theory, 11, 669-720.

Kr¨amer W., Ploberger W., Alt R. (1988), Testing for structural change in dynamic models, Econometrica,56, 1355-1369.

Kuan C.-M., Hornik K. (1995), The generalized fluctuation test: A unifying view, Econo-metric Reviews,14, 135 - 161.

Kuan C.-M., Chen (1994), Implementing the fluctuation and moving estimates tests in dynamic econometric models,Economics Letters,44, 235-239.

Ploberger W., Kr¨amer W. (1992), The CUSUM test with OLS residuals,Econometrica,60, 271-285.

See Also

plot.efp,print.efp,sctest.efp,boundary.efp

Examples

## Load dataset "nhtemp" with average yearly temperatures in New Haven data(nhtemp)

## plot the data plot(nhtemp)

(24)

## test the model null hypothesis that the average temperature remains constant ## over the years

## compute OLS-CUSUM fluctuation process temp.cus <- efp(nhtemp ~ 1, type = "OLS-CUSUM") ## plot the process with alternative boundaries plot(temp.cus, alpha = 0.01, alt.boundary = TRUE) ## and calculate the test statistic

sctest(temp.cus)

## Load dataset "USIncExp" with income and expenditure in the US ## and choose a suitable subset

data(USIncExp)

USIncExp2 <- window(USIncExp, start=c(1970,1), end=c(1989,12))

## test the null hypothesis that the way the income is spent in expenditure ## does not change over time

## compute moving estimates fluctuation process

me <- efp(expenditure~income, type="ME", data=USIncExp2, h=0.2) ## plot the two dimensional fluctuation process with boundaries plot(me, functional=NULL)

## and perform the corresponding test sctest(me)

Fstats F Statistics

Description

Computes a series of F statistics for a specified data window. Usage

Fstats(formula, from = 0.15, to = NULL, data,

cov.type = c("const", "HC", "HC1"), tol=1e-7) Arguments

formula a symbolic description for the model to be tested

from, to numeric. If from is smaller than 1 they are interpreted as percentages of data and by default to is taken to be 1 - from. F statistics will be calculated for the observations(n*from):(n*to), whenn is the number of observations in the model. Iffromis greater than 1 it is interpreted to be the index and todefaults ton - from. If from is a vector with two elements, thenfrom andto are interpreted as time specifications like in

ts, see also the examples.

data an optional data frame containing the variables in the model. By default the variables are taken from the environment whichFstatsis called from. cov.type a string indicating which type of covariance matrix estimator should be used. Constant homoskedastic variances are assumed if set to "const" and White’s heteroskedasticity consistent estimator is used if set to"HC". And"HC1"stands for a standardized estimator of "HC", see alsocovHC.

(25)

Details

For every potential change point infrom:toa F statistic (Chow test statistic) is computed. For this an OLS model is fitted for the observations before and after the potential change point, i.e. 2kparameters have to be estimated, and the error sum of squares is computed (ESS). Another OLS model for all obervations with a restricted sum of squares (RSS) is computed, hencekparameters have to be estimated here. Ifnis the number of observations andkthe number of regressors in the model, the formula is:

F= (RSS−ESS) ESS/(n−2k) Value

Fstats returns an object of class "Fstats", which contains mainly a time series of F statistics. The functionplothas a method to plot the F statistics or the corresponding p values; withsctesta supF-, aveF- or expF-test on structural change can be performed. Author(s)

Achim [email protected] References

Andrews D.W.K. (1993), Tests for parameter instability and structural change with un-known change point,Econometrica,61, 821-856.

Hansen B. (1992), Tests for parameter instability in regressions with I(1) processes,Journal of Business & Economic Statistics,10, 321-335.

Hansen B. (1997), Approximate asymptotic p values for structural-change tests,Journal of Business & Economic Statistics,15, 60-67.

See Also

plot.Fstats,sctest.Fstats,boundary.Fstats

Examples

## Load dataset "nhtemp" with average yearly temperatures in New Haven data(nhtemp)

## plot the data plot(nhtemp)

## test the model null hypothesis that the average temperature remains constant ## over the years for potential break points between 1941 (corresponds to from = ## 0.5) and 1962 (corresponds to to = 0.85)

## compute F statistics

fs <- Fstats(nhtemp ~ 1, from = 0.5, to = 0.85) ## this gives the same result

fs <- Fstats(nhtemp ~ 1, from = c(1941,1), to = c(1962,1)) ## plot the F statistics

plot(fs, alpha = 0.01)

## and the corresponding p values plot(fs, pval = TRUE, alpha = 0.01)

(26)

## perform the aveF test sctest(fs, type = "aveF")

mefp Monitoring of Empirical Fluctuation Processes

Description

Online monitoring of structural breaks in a linear regression model. A parameter estimate based on a historical sample is compared with estimates based on newly arriving data; a sequential test on the difference between the two parameter estimates signals structural breaks.

Usage

mefp(obj, ...)

mefp(formula, type = c("OLS-CUSUM", "OLS-MOSUM", "ME",

"fluctuation"), data, h=1, alpha=0.05, functional = c("max", "range"), period=10, tolerance=.Machine$double.eps^0.5,

CritvalTable=NULL, rescale=NULL, border=NULL, ...) mefp(obj, alpha=0.05, functional = c("max", "range"),

period=10, tolerance=.Machine$double.eps^0.5, CritvalTable=NULL, rescale=NULL, border=NULL, ...) monitor(obj, data=NULL, verbose=TRUE)

Arguments

formula a symbolic description for the model to be tested.

data an optional data frame containing the variables in the model. By default the variables are taken from the environment whichefpis called from. type specifies which type of fluctuation process will be computed.

h (only used for ME processes). A numeric scalar from interval (0,1) speci-fying the size of the data window relative to the sample size.

obj Object of class"efp"(formefp) or"mefp"(formonitor). alpha Significance level of the test, i.e., probability of type I error.

functional Determines if maximum or range of parameter differences is used as statis-tic.

period (only used for ME processes). Maximum time (relative to the history period) that will be monitored. Default is 10 times the history period. tolerance Tolerance for numeric==comparisons.

CritvalTable Table of critical values, this table is interpolated to get critical values for arbitraryalphas. The default depends on thetypeof fluctuation process (pre-computed tables are available for all types). This argument is under development.

(27)

rescale If TRUE the estimates will be standardized by the regressor matrix of the corresponding subsample similar to Kuan & Chen (1994); if FALSE the historic regressor matrix will be used. The default is to rescale the monitoring processes of type"ME" but not of "fluctuation".

border An optional user-specified border function for the empirical process. This argument is under development.

verbose If TRUE, signal breaks by text output.

... Currently not used.

Details

mefp creates an object of class "mefp" either from a model formula or from an object of class"efp". In addition to the arguments of efp, the type of statistic and a significance level for the monitoring must be specified. The monitoring itself is performed bymonitor, which can be called arbitrarily often on objects of class"mefp". If new data have arrived, then the empirical fluctuation process is computed for the new data. If the process crosses the boundaries corresponding to the significance levelalpha, a structural break is detected (and signaled).

The typical usage is to initialize the monitoring by creation of an object of class"mefp" either using a formula or an"efp"object. Data available at this stage are considered the history sample, which is kept fixed during the complete monitoring process, and may not contain any structural changes.

Subsequent calls tomonitor perform a sequential test of the null hypothesis of no struc-tural change in new data against the general alternative of changes in one or more of the coefficients of the regression model.

Author(s)

Friedrich Leisch References

Friedrich Leisch, Kurt Hornik, and Chung-Ming Kuan. Monitoring structural changes with the generalized fluctuation test. Econometric Theory, 16:835-854, 2000.

See Also

plot.mefp,boundary.mefp Examples

df1 <- data.frame(y=rnorm(300)) df1[150:300,"y"] <- df1[150:300,"y"]+1

## use the first 50 observations as history period

e1 <- efp(y~1, data=df1[1:50,,drop=FALSE], type="ME", h=1) me1 <- mefp(e1, alpha=0.05)

## the same in one function call

me1 <- mefp(y~1, data=df1[1:50,,drop=FALSE], type="ME", h=1, alpha=0.05)

(28)

## monitor the 50 next observations

me2 <- monitor(me1, data=df1[1:100,,drop=FALSE]) plot(me2)

# and now monitor on all data me3 <- monitor(me2, data=df1) plot(me3)

## Load dataset "USIncExp" with income and expenditure in the US ## and choose a suitable subset for the history period

data(USIncExp)

USIncExp3 <- window(USIncExp, start=c(1969,1), end=c(1971,12)) ## initialize the monitoring with the formula interface me.mefp <- mefp(expenditure~income, type="ME", rescale=TRUE,

data=USIncExp3, alpha=0.05) ## monitor the new observations for the year 1972

USIncExp3 <- window(USIncExp, start=c(1969,1), end=c(1972,12)) me.mefp <- monitor(me.mefp)

## monitor the new data for the years 1973-1976

USIncExp3 <- window(USIncExp, start=c(1969,1), end=c(1976,12)) me.mefp <- monitor(me.mefp)

plot(me.mefp, functional = NULL)

plot.efp Plot Empirical Fluctuation Process

Description

Plotting method for objects of class"efp" Usage

plot(x, alpha = 0.05, alt.boundary = FALSE, boundary = TRUE, functional = "max", main = NULL, ylim = NULL,

ylab = "empirical fluctuation process", ...) Arguments

x an object of class"efp".

alpha numeric from interval (0,1) indicating the confidence level for which the boundary of the corresponding test will be computed.

alt.boundary logical. If set to TRUE alternative boundaries (instead of the standard linear boundaries) will be plotted (for CUSUM processes only).

boundary logical. If set toFALSEthe boundary will be computed but not plotted. functional indicates which functional should be applied to the estimates based

pro-cesses ("fluctuation" and "ME"). If set to NULL a multiple process is plotted.

main, ylim, ylab, ...

(29)

Details

Alternative boundaries that are proportional to the standard deviation of the corresponding limiting process are available for the CUSUM-type processes.

Value

efpreturns an object of class"efp"which inherits from the class"ts"or"mts"respectively. The functionplothas a method to plot the empirical fluctuation process; withsctestthe corresponding test on structural change can be performed.

Author(s)

Achim [email protected] References

Brown R.L., Durbin J., Evans J.M. (1975), Techniques for testing constancy of regression relationships over time,Journal of the Royal Statistal Society, B,37, 149-163.

Chu C.-S., Hornik K., Kuan C.-M. (1995), MOSUM tests for parameter constancy,Biometrika, 82, 603-617.

Chu C.-S., Hornik K., Kuan C.-M. (1995), The moving-estimates test for parameter stabil-ity,Econometric Theory, 11, 669-720.

Kr¨amer W., Ploberger W., Alt R. (1988), Testing for structural change in dynamic models, Econometrica,56, 1355-1369.

Kuan C.-M., Hornik K. (1995), The generalized fluctuation test: A unifying view, Econo-metric Reviews,14, 135 - 161.

Kuan C.-M., Chen (1994), Implementing the fluctuation and moving estimates tests in dynamic econometric models,Economics Letters,44, 235-239.

Ploberger W., Kr¨amer W. (1992), The CUSUM test with OLS residuals,Econometrica,60, 271-285.

Zeileis A. (2000), p Values and Alternative Boundaries for CUSUM Tests, Working Paper 78, SFB ”Adaptive Information Systems and Modelling in Economics and Management Science”, Vienna University of Economics,http://www.wu-wien.ac.at/am/wp00.htm#78. See Also

efp,boundary.efp,sctest.efp

Examples

## Load dataset "nhtemp" with average yearly temperatures in New Haven data(nhtemp)

## plot the data plot(nhtemp)

## test the model null hypothesis that the average temperature remains constant ## over the years

## compute Rec-CUSUM fluctuation process temp.cus <- efp(nhtemp ~ 1)

(30)

plot(temp.cus, alpha = 0.01) ## and calculate the test statistic sctest(temp.cus)

## compute (recursive estimates) fluctuation process ## with an additional linear trend regressor

lin.trend <- 1:60

temp.me <- efp(nhtemp ~ lin.trend, type = "fluctuation") ## plot the bivariate process

plot(temp.me, functional = NULL) ## and perform the corresponding test sctest(temp.me)

plot.Fstats Plot F Statistics

Description

Plotting method for objects of class"Fstats" Usage

plot(x, pval = FALSE, asymptotic = FALSE, alpha = 0.05, boundary = TRUE, aveF = FALSE, xlab = "Time", ylab = NULL, ylim = NULL, ...)

Arguments

x an object of class"Fstats".

pval logical. If set to TRUE the corresponding p values instead of the original F statistics will be plotted.

asymptotic logical. If set toTRUEthe asymptotic (chi-square) distribution instead of the exact (F) distribution will be used to compute the p values (only if pvalisTRUE).

alpha numeric from interval (0,1) indicating the confidence level for which the boundary of the supF test will be computed.

boundary logical. If set toFALSEthe boundary will be computed but not plotted. aveF logical. If set toTRUE the boundary of the aveF test will be plotted. As

this is a boundary for the mean of the F statistics rather than for the F statistics themselves a dashed line for the mean of the F statistics will also be plotted.

xlab, ylab, ylim, ...

high-levelplotfunction parameters. Author(s)

(31)

References

Andrews D.W.K. (1993), Tests for parameter instability and structural change with un-known change point,Econometrica,61, 821-856.

Hansen B. (1992), Tests for parameter instability in regressions with I(1) processes,Journal of Business & Economic Statistics,10, 321-335.

Hansen B. (1997), Approximate asymptotic p values for structural-change tests,Journal of Business & Economic Statistics,15, 60-67.

See Also

Fstats,boundary.Fstats,sctest.Fstats

Examples

## Load dataset "nhtemp" with average yearly temperatures in New Haven data(nhtemp)

## plot the data plot(nhtemp)

## test the model null hypothesis that the average temperature remains constant ## over the years for potential break points between 1941 (corresponds to ## from = 0.5) and 1962 (corresponds to to = 0.85)

## compute F statistics

fs <- Fstats(nhtemp ~ 1, from = 0.5, to = 0.85) ## plot the F statistics

plot(fs, alpha = 0.01)

## and the corresponding p values plot(fs, pval = TRUE, alpha = 0.01) ## perform the aveF test

sctest(fs, type = "aveF")

plot.mefp Plot Methods for mefp Objects

Description

This is a method of the genericplotfunction for for"mefp"objects as returned bymefpor

monitor. It plots the emprical fluctuation process (or a functional therof) as a time series plot, and includes boundaries corresponding to the significance level of the monitoring procedure.

Usage

plot(x, boundary=TRUE, functional="max", main=NULL, ylab="empirical fluctuation process", ylim=NULL, ...)

(32)

Arguments

x an object of class"mefp".

boundary if FALSE, plotting of boundaries is suppressed.

functional indicates which functional should be applied to a multivariate empirical process. If set to NULL all dimensions of the process (one process per coefficient in the linear model) are plotted.

main, ylab, ylim, ...

high-levelplotfunction parameters. Author(s) Friedrich Leisch See Also mefp Examples df1 <- data.frame(y=rnorm(300)) df1[150:300,"y"] <- df1[150:300,"y"]+1

me1 <- mefp(y~1, data=df1[1:50,,drop=FALSE], type="ME", h=1, alpha=0.05)

me2 <- monitor(me1, data=df1) plot(me2)

root.matrix Root of a Matrix

Description

Computes the root of a symmetric and positive semidefinite matrix. Usage

root.matrix(X) Arguments

X a symmetric and positive semidefinite matrix

Value

a symmetric matrix of same dimensions asX Author(s)

(33)

Examples X <- matrix(c(1,2,2,8), ncol=2) test <- root.matrix(X) ## control results X test %*% test

sctest.efp Generalized Fluctuation Tests

Description

Performs a generalized fluctuation test. Usage

sctest(x, alt.boundary = FALSE, functional = c("max", "range"), ...)

Arguments

x an object of class"efp".

alt.boundary logical. If set to TRUE alternative boundaries (instead of the standard linear boundaries) will be used (for CUSUM processes only).

functional indicates which functional should be applied to the estimates based pro-cesses ("fluctuation"and"ME").

... currently not used.

Details

The critical values for the MOSUM tests and the ME test are just tabulated for confidence levels between 0.1 and 0.01, thus the p value approximations will be poor for other p values. Value

an object of class"htest"containing: statistic the test statistic

p.value the corresponding p value

method a character string with the method used data.name a character string with the data name

Author(s)

(34)

References

Brown R.L., Durbin J., Evans J.M. (1975), Techniques for testing constancy of regression relationships over time,Journal of the Royal Statistal Society, B,37, 149-163.

Chu C.-S., Hornik K., Kuan C.-M. (1995), MOSUM tests for parameter constancy,Biometrika, 82, 603-617.

Chu C.-S., Hornik K., Kuan C.-M. (1995), The moving-estimates test for parameter stabil-ity,Econometric Theory, 11, 669-720.

Kr¨amer W., Ploberger W., Alt R. (1988), Testing for structural change in dynamic models, Econometrica,56, 1355-1369.

Kuan C.-M., Hornik K. (1995), The generalized fluctuation test: A unifying view, Econo-metric Reviews,14, 135 - 161.

Kuan C.-M., Chen (1994), Implementing the fluctuation and moving estimates tests in dynamic econometric models,Economics Letters,44, 235-239.

Ploberger W., Kr¨amer W. (1992), The CUSUM Test with OLS Residuals, Econometrica, 60, 271-285.

Zeileis A. (2000), p Values and Alternative Boundaries for CUSUM Tests, Working Paper 78, SFB ”Adaptive Information Systems and Modelling in Economics and Management Science”, Vienna University of Economics,http://www.wu-wien.ac.at/am/wp00.htm#78. See Also

efp,plot.efp Examples

## Load dataset "nhtemp" with average yearly temperatures in New Haven data(nhtemp)

## plot the data plot(nhtemp)

## test the model null hypothesis that the average temperature remains constant ## over the years compute OLS-CUSUM fluctuation process

temp.cus <- efp(nhtemp ~ 1, type = "OLS-CUSUM") ## plot the process with alternative boundaries plot(temp.cus, alpha = 0.01, alt.boundary = TRUE) ## and calculate the test statistic

sctest(temp.cus)

## compute moving estimates fluctuation process temp.me <- efp(nhtemp ~ 1, type = "ME", h = 0.2) ## plot the process with functional = "max" plot(temp.me)

## and perform the corresponding test sctest(temp.me)

(35)

sctest.Fstats supF-, aveF- and expF-Test

Description

Performs the supF-, aveF- or expF-test Usage

sctest(x, type = c("supF", "aveF", "expF"), asymptotic = FALSE, ...)

Arguments

x an object of class"Fstats".

type a character string specifying which test will be performed.

asymptotic logical. Only necessary if x contains just a single F statistic and type is "supF" or "aveF". If then set to TRUE the asymptotic (chi-square) distribution instead of the exact (F) distribution will be used to compute the p value.

... currently not used.

Details

If xcontains just a single F statistic and type is"supF" or "aveF"the Chow test will be performed.

The original GAUSS code for computing the p values of the supF-, aveF- and expF-test was written by Bruce Hansen and is available fromhttp://www.ssc.wisc.edu/~bhansen/. R port by Achim Zeileis.

Value

an object of class"htest"containing: statistic the test statistic

p.value the corresponding p value

method a character string with the method used data.name a character string with the data name

References

Andrews D.W.K. (1993), Tests for parameter instability and structural change with un-known change point,Econometrica,61, 821-856.

Hansen B. (1992), Tests for parameter instability in regressions with I(1) processes,Journal of Business & Economic Statistics,10, 321-335.

Hansen B. (1997), Approximate asymptotic p values for structural-change tests,Journal of Business & Economic Statistics,15, 60-67.

(36)

See Also

Fstats,plot.Fstats

Examples

## Load dataset "nhtemp" with average yearly temperatures in New Haven data(nhtemp)

## plot the data plot(nhtemp)

## test the model null hypothesis that the average temperature remains constant ## over the years for potential break points between 1941 (corresponds to ## from = 0.5) and 1962 (corresponds to to = 0.85)

## compute F statistics

fs <- Fstats(nhtemp ~ 1, from = 0.5, to = 0.85) ## plot the F statistics

plot(fs, alpha = 0.01)

## and the corresponding p values plot(fs, pval = TRUE, alpha = 0.01) ## perform the aveF test

sctest(fs, type = "aveF")

sctest.formula Structural Change Tests

Description

Performs tests for structural change. Usage

sctest(formula, type = <<see below>>, h = 0.15,

alt.boundary = FALSE, functional = c("max", "range"),

from = 0.15, to = NULL, point = 0.5, asymptotic = FALSE, data, ...)

Arguments

formula a formula describing the model to be tested.

type a character string specifying the structural change test that ist to be performed. Besides the tests types described inefpandsctest.Fstats

the Chow test is can be performed by setting type to"Chow".

h numeric from interval (0,1) specifying the bandwidth. Determins the size of the data window relative to sample size (for MOSUM and ME tests only).

dynamic logical. If TRUE the lagged observations are included as a regressor (for generalized fluctuation tests only).

tol tolerance whensolveis used

alt.boundary logical. If set to TRUE alternative boundaries (instead of the standard linear boundaries) will be used (for CUSUM processes only).

References

Related documents

Notices currently serve many purposes, including to provide a basis for individual choice; serve as the basis for regulation, promote public awareness of data practices, and

People responding to social media on behalf of the agency need to rely on a set of general behavioural guidelines and judgements made at the time.. The diagram also

Destructive and non-destructive testing methods, Tensile test, Compression test, shear test, bend test, Different types of Hardness tests, Impact tests, Fatigue tests,

Previous studies of soils from the White Bluffs Slough detected elevated europium-152 (Sula 1980; Cooper and Woodruff 1993), which was associated with single-pass reactor

class Platform(location: PhysicsVector, dimensions: PhysicsVector) extends JumperObject(location, dimensions) { override def collideWithDynamicObject(otherObject:

Update Notes – This button updates all changes on the Early Alert form, and saves them into a row in the Current Student History Table.. Email &amp; Print Letter – prints/emails

In the cartographic approach, neurolinguistic and psycholinguistic experiments showing dissociations between grammatical features, such as Tense and Agreement, in aphasia

Yet team training is charged with improving trainee competencies (e.g., knowledge, skills, attitudes) and achieving desirable performance outcomes (e.g., timely and accurate response,