title: How to create function that uses iteratively reweighted least squares (IRLS) with piecwise regression?
body: <p>I've developed a successful function that outputs piecewise regression results into a dataframe using <code>breakpoints()</code> in the <code>strucchange</code> package. I then use this function with ddply across a large dataset to get piecewise regression data for each linear model (lm) in my dataset.</p>
  
  <p>After doing this, I went back to my data to see how the piecewise regression results looked. It worked pretty well, but many times the piecewise regression results were "incorrect" because of the influence of outliers. So, I'd like to be able to do the piecewise regression WITH an IRLS method (instead of ordinary least squares) to reduce the influence of outliers. This maybe isn't so hard with a few lm's, but I'd like to do it hundreds-to-thousands of times. </p>
  
  <p>Do any of you have any ideas about how to approach this problem? I've looked through the <code>strucchange</code> package file and I don't see any options for embedding IRLS into the <code>breakpoints()</code> function.</p>
  
  <p>Any help is greatly appreciated!</p>