Assume your estimated model is

y_i = B^T x_i1 + e_i,

where e_i ~ i.i.d. N(0; sigma^2); i = 1, ..., n.
However, the regression coeffcient B might be different for different subsamples. For instance, denote B_i the true regression coeffcient at the ith case, and assume that there are m unknown break points J_1, ..., J_m, such that

B_1 = ... = B_{J_1} =/ B_{J_1 + 1} = ... = B_{J_2} =/ B_{J_2 + 1} = ... = B_{J_m} =/ B{J_m + 1} = ... = B_n:

(=/ means "not equal")

Propose a procedure to estimate J_1, ..., J_m and e_i's for the case (1) m is given; (2) m is not given.

Please tell me how to solve this problem or give links that may help.