# Tag Info

## Hot answers tagged change-point

11

It appears you are looking for spikes within intervals of relative quiet. "Relative" means compared to typical nearby values, which suggests smoothing the series. A robust smooth is desirable precisely because it should not be influenced by a few local spikes. "Quiet" means variation around that smooth is small. Again, a robust estimate of local ...

10

Another approach would be to wrap the call to lmer in a function that is passed the breakpoint as a parameter, then minimize the deviance of the fitted model conditional upon the breakpoint using optimize. This maximizes the profile log likelihood for the breakpoint, and, in general (i.e., not just for this problem) if the function interior to the wrapper ...

10

A very similar example is used in the tutorial of PyMC. If you assume that the daily amount of requests was constant until some point in time (maybe exactly Christmas) and after that it was constant again, all you need to do is substitute the numbers in the example: http://pymc.googlecode.com/svn/doc/tutorial.html As this is the Bayesian approach you won't ...

7

(At first I thought it could be a problem resulting from the fact that max is not vectorized, but that's not true. It does make it a pain to work with changePoint, wherefore the following modification: changePoint <- function(x, b0, slope1, slope2, delta){ fit <- b0 + (x*slope1) + (sapply(x-delta, function (t) max(0, t)) * slope2) } ) This ...

6

Given your data: cp <- c(5, 2, 4, 1, 9, 2, 9, 2, 10, 1) then the ranks, with ties being given average of the ranks, are: > rank(cp) [1] 7.0 4.0 6.0 1.5 8.5 4.0 8.5 4.0 10.0 1.5 What is being done here? If you sort the data in increasing order, then we have a 1 in both rank order positions 1 and 2. We could assign rank 1 to both 1s, or ...

5

This sounds like a job for the Mahalanobis Distance. You would apply this by estimating the population covariance and mean vector using the previous $(k-1)$ samples (assuming $k > N$, where $N$ is the dimension of your observed vectors), and then computing the Mahalanobis Distance. A google search reveals a lot of hits on this topic, Bartkowiak seems like ...

5

Change Points can arise from a number of possible causes. Each of the possible causes can be evaluated. In terms of increasing complexity : 1. detecting a change in the expected value is essentially Intervention Detection. Pursue the work of Ruey Tsay to understand what you need to do. His work does not cover detecting the onset of a new time trend, The ...

5

You need to make days_ind a time-dependent variable. The way you have it coded right now, everybody whose observation (whether event or censoring time) was after 110 days will have experienced a different hazard throughout their entire followup then those whose observation is before 110 days. What you want to have is for the hazard to "jump" at 110 days. It ...

5

This is an (offline) changepoint detection problem. Our previous discussion provides references to journal articles and R code. Look first at the Barry and Hartigan "product partition model," because it handles changes in slope and has efficient implementations.

5

The 12-month rolling aggregation will remove seasonality which makes the task easier. For non-seasonal time series, the methods in the strucchange package for R are excellent. For seasonal time series, you might look at the BFAST (Breaks For Additive Seasonal and Trend) method which is implemented in the bfast package for R. This method involves applying ...

4

Your question is most interesting to me and it's solution has been my primary research for a number of years. There are a number of ways that "a structural break" may occur. If there is a change in the Intercept or a change in Trend in "the latter portion of the time series" then one would be better suited to perform Intervention Detection (N.B. this is ...

4

If the number of points is not too big, you may try all possibilities. Let's assume that the points are $X_i=(x_i,y_i)$ where $i=1,..,N$. Than, you may loop with $j$ from $2$ to $N-2$ and fit two lines to both $\{X_1,...,X_j\}$ and $\{X_{(j+1)},...,X_N\}$. Finally, you pick $j$ for which the sum of sum of squared residuals for both lines is minimal.

4

This sounds to me more like a change point problem. You should investigate the bcp package, http://cran.r-project.org/web/packages/bcp/index.html, as well as strucchange, http://cran.r-project.org/web/packages/strucchange/index.html John Emerson maintains the bcp package, and when I met him, he seemed very willing to engage the community and potential ...

4

A "Jump" in a time series is a permanent change in the equation's implied intercept. Consider a series 1,1,1,1,4,4,4,4,4 where the basic model is y(t)=1 + 3*x(t) and x is the level shift/step shift series 0,0,0,0,1,1,1,1,1 . Thus suggests an intercept change at period 5 from a "1" to a "4" . If a second series is 1,2,3,4,8,9,10,11,12 then the model is ...

3

Here is a two cents suggestion. Denote $X_t$ the differenced series. Given $\Delta > 0$ and a point $t$, define $$a(\Delta,t) = {1\over 2\Delta + 1} |X_t|.$$ For let’s says $\Delta = 50$, the value of $a(\Delta,t)$ characterizes the off/on zones by low/high values. An anomalous step is a point $t$ where $|X_t| > \alpha a(\Delta,t)$ – you’ll need to ...

3

There are a number of ways that "a structural break" may occur. If there is a change in the Intercept or a change in Trend in "the latter portion of the time series" then one would be better suited to perform Intervention Detection (N.B. this is the empirical identification of the significant impact of an unspecified Deterministic Variable such as a Level ...

3

EDIT: As requested by OP, here a minimal example of how to include breakpoints in a nls. Actually, after reviewing the question and answers that is considered a duplicate, I believe they go way around to come at a solution. It can be as simple as : Data <- data.frame( A = rnorm(100), S = sample(0:9,100,TRUE) ) X <- nls(S~ B0 + B1*as.numeric(A ...

3

If you are using the changepoint package (which from the output I presume you are) then the changepoint locations always end with n. Thus the length of your data is 118 and there is a single change in mean at 15. For info AMOC means At Most One Change and thus the maximum number of changepoints the method will identify is 1. As 1 has been identified then ...

3

If you are wanting to test "significance" then I suggest you use the Asymptotic penalty option, i.e. penalty='Asymptotic' and pen.value=0.05 for 95% confidence. This automatically sets the penalty based on the cost function you are using. I find that this works well for smaller data sets <1000 but not too small <100. If you want to use the manual ...

2

In general, it's a bit odd to want to fit something as piece-wise linear. However, if you really wish to do so, then the MARS algorithm is the most direct. It will build up a function one knot at a time; and then usually prunes back the number of knots to combat over-fitting ala decision trees. You can access the MARS algotithm in R via earth or mda. In ...

2

To quote from the intro in the Efron/Tibshirani text on the subject: The message of this book can therefore be summarized by paraphrasing Tukey: "The bootstrap, like a shotgun, can blow the head off any problem if the statistician can stand the resulting mess''. It sounds like you're trying to make inference based on the assumption that the ...

2

There is a lot of literature for testing the change in mean. If it is known that mean does not change, and you need to test the variance, you can convert the problem of testing for change in variance to the one of testing for change in mean with simple transformation. Suppose your initial data is $X_i$, then define $Y_i=(X_i-\mu)^2$, where $\mu$ is the ...

2

I'm not aware of any multiple changepoint algorithms for circular data available within R. PELT can be applied to any test statistic which satisfies the assumptions in the paper. The PELT code is the same regardless of the cost function. The existing changepoint package implementation is in C. It is simply a case of coding up a new cost function that can ...

1

Detecting a drift in a random walk is a lot harder than you make it out to be. Random walks are nonstationary sequences that can have long excursions in one direction or another. So they appear to drift even without any change in the process. Since the random walk fits an ARIMA first difference model, you could apply the model to the data and look to see ...

1

Changes in variance occur quite often in time series.We employ a search process based upon R. Tsay's innovative work to find the point in time that the variance of the errors has changed. This leads directly to Generalized Least Squares or otherwise known as Weighted Least Squares. His work appeared in the Journal of Forecasting Vol 7 1-20 1988 and has been ...

1

To answer one of your questions: Yes you can do changepoint analysis on a vector. I think that the only package that can currently do this in R is the ecp package: http://cran.r-project.org/web/packages/ecp/

1

@Dail -- You don't need to know the date in advance. There are many options beyond the Chow Test. In practice, the Chow test can be undesirable because it assumes homoskedasticity, which is very often violated in real time series data. There is a famous paper on testing for structural breaks when the break dates are unknown and methods are now quite well ...

1

This may not be state of the art, but an intuitive method would be smoothing the data by placing weights on the observations close to each point in time. So if you want to know whether sample R has a zero mean at time T: mu(R,T)=w1*Sample(R,T)+w2*Sample(R,T-1)+w3*Sample(R,T+1).... Perhaps exponential weights can be a good choice, depending on the ...

1

It seems that the main issue here is efficient change-point detection, as after that the mean of the segment can be found trivially with increasing accuracy in the number of samples. Once recent approach that might be interesting is Z. Harchaoui, F. Bach, and E. Moulines. Kernel change-point analysis, Advances in Neural Information Processing Systems (NIPS), ...

1

I have programmed this from scratch once a few years ago, and I have a Matlab file for doing piece-wise linear regression on my computer. About 1 to 4 breakpoints is computationally possible for about 20 measurements points or so. 5 or 7 break points starts to be really too much. The pure mathematical approach as I see it is to try all possible combinations ...

Only top voted, non community-wiki answers of a minimum length are eligible