nls segmented model with unknown joint points
Hello, I am interested in fitting a segmented model with unknown joint points in nls and perhaps eventually in nlme. I can fit this model in sas (see below, joint points to be estimated are a41 and a41), but am unsure how to specify this in the nlm function. I would really appreciate any suggestions or example code. Thanks a lot. -andy proc nlin data=Stems.Trees; params b41=-3 b42=1.5 b43=-1.5 b44=50 a41=0.75 a42=0.1; term1 = (b41*(x - 1) + b42*(x**2 -1)); if (a41 - x) >= 0 then term2 = (b43*(a41 - x)**2); else term2 = 0; if (a42 - x) >=0 then term3 = (b44*(a42 - x)**2); else term3 = 0; model y = term1+term2+term3; run;