[R] Fitting multiple horizontal lines to data

2013-11-06 Thread Sashikanth Chandrasekaran
I am not trying to fit a horizontal line at every unique value of y. I am trying fit the y values with as few horizontal lines by trading off the number of horizontal lines with the error. The actual problem I am trying to solve is to smooth data in a time series. Here is a realistic example of y

[R] Fitting multiple horizontal lines to data

2013-10-29 Thread Sashikanth Chandrasekaran
Dear R-users, I am trying to fit my data using one or more horizontal lines. If my data is in "y", I understand that "lm(y~1)" will fit a single horizontal line at mean(y). However, I want to try and fit the data with multiple horizontal lines if that reduces the error while still keeping the numbe