[R] trend turning points

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Mon Apr 19 11:10:47 CEST 2004


On Mon, 19 Apr 2004 14:27:00 +0530 Ajay Shah wrote:

>   >> does anybody know of a nice test to detect trend turning points
>   >in> time series? Possibly with reference?
>   >
>   >You can look at the function breakpoints() in the package
>   >strucchange and the function segmented() in the package segmented
>   >which do segmentation of (generalized) linear regression models.
>   >The former tries to fit fully segmented regression models, the
>   >latter broken line trends.  References are given on the respective
>   >help pages.
>   >
>   >A suitable test for a change in trend in linear regression models
>   >is the OLS-based CUSUM test with a Cramer-von Mises functional of
>   >Kraemer& Ploberger (1996, JoE) which is available via efp() in
>   >strucchange and associated methods.
> 
> I have seen strucchange with great interest but somehow the
> combination of the R and the statistics knowledge that is required to
> access it feels like a bottleneck :-) Could someone perhaps write a
> simple R program which illustrates the facilities and usage?

The package has an accompanying vignette which explains the ideas behind
it and how to use its inference functions. The breakpoints() facilities
are also documented in a paper by Zeileis, Kleiber, Kraemer, Hornik
(2003, CSDA).

A mini-example would be:

## load package and data
R> data(Nile)
R> library(strucchange)

## fit, visualize and test OLS-based CUSUM test
## with a Cramer-von Mises functional
R> ocus <- efp(Nile ~ 1, type = "OLS-CUSUM")
R> plot(ocus, functional = "meanL2")
R> sctest(ocus, functional = "meanL2")

## estimate breakpoints
R> bp <- breakpoints(Nile ~ 1)
R> plot(bp)
R> summary(bp)

hth,
Z

> -- 
> Ajay Shah                                                   Consultant
> ajayshah at mayin.org                      Department of Economic Affairs
> http://www.mayin.org/ajayshah           Ministry of Finance, New Delhi
>




More information about the R-help mailing list