Question: Are there any packages to do piecewise linear regression, which can detect the multiple knots automatically? Thanks.
When I use the strucchange package. I could not detect the change points. I have no idea how it detects the change points. From the plots, I could see there are several points I want it could help me to pick them out. Could anyone give an example here?

Answer: 
There is a pretty nice algorithm described in [Tomé and Miranda (1984)](http://idl.ul.pt/sites/idl.ul.pt/files/docs/Tome%26Miranda2004GRL.pdf). 

> 
> The proposed methodology uses a least-squares approach to compute the best continuous set of straight lines that fit a given time series, subject to a number of constraints on the minimum distance between breakpoints and on the minimum trend change at each breakpoint.
> 
> 
> 

The code and a GUI are available in both Fortran and IDL from their website: 
<http://www.dfisica.ubi.pt/~artome/linearstep.html>
I once came across a program called [Joinpoint](http://surveillance.cancer.gov/joinpoint/). On their website they say it fits a joinpoint model where "several different lines are connected together at the 'joinpoints'". And further: "The user supplies the minimum and maximum number of joinpoints. The program starts with the minimum number of joinpoint (e.g. 0 joinpoints, which is a straight line) and tests whether more joinpoints are statistically significant and must be added to the model (up to that maximum number)."

The NCI uses it for trend modelling of cancer rates, maybe it fits your needs as well.