- Is there a modelling technique like LOESS that allows for zero, one, or more discontinuities, where the timing of the discontinuities are not known apriori?
- If a technique exists, is there an existing implementation in R?

**Answer**

It sounds like you want to perform multiple changepoint detection followed by independent smoothing within each segment. (Detection can be online or not, but your application is not likely to be online.) There’s a lot of literature on this; Internet searches are fruitful.

- DA Stephens wrote a useful introduction to Bayesian changepoint detection in 1994 (App. Stat. 43 #1 pp 159-178: JSTOR).
- More recently Paul Fearnhead has been doing nice work (e.g.,
*Exact and efficient Bayesian inference for multiple changepoint problems*, Stat Comput (2006) 16: 203-213: Free PDF). - A recursive algorithm exists, based on a beautiful analysis by D Barry & JA Hartigan
- One implementation of the Barry & Hartigan algorithm is documented in O. Seidou & TBMJ Ourda,
*Recursion-based Multiple Changepoint Detection in Multivariate Linear Regression and Application to River Streamflows,*Water Res. Res., 2006: Free PDF.

I haven’t looked hard for any R implementations (I had coded one in Mathematica a while ago) but would appreciate a reference if you do find one.

**Attribution***Source : Link , Question Author : Jeromy Anglim , Answer Author : whuber*