## Bent-stick model with proc nlin

Occasional Contributor
Posts: 8

# Bent-stick model with proc nlin

Hi Everyone,

I've red an article on the response of pigs to increasing concentrations of isoleucine in their diet. The response was analysed with proc nlin. It is said in the article that they modified the classical broken-stick (or linear-plateau) model into a bentstick model.

I know how to program a broken-stick model but I really don't know how to do with a bent-stick model. In the article the bent-stick model is based on two line segments that are connected by a quadratic function, resulting in a smooth transition between both line segments. So it seems to be a modification of a broken stick model.ent_stick

Does any one can help me please ?

Thanks

Friedrich

Posts: 2,655

## Re: Bent-stick model with proc nlin

Example 63.1 Segmented Model in the NLIN Procedure documentation will get you started.  This is a linear plateau following a quadratic.  What you want is linear-quadratic-linear.  Start by writing the expectation across all X, then apply the continuity and smoothness conditions.

It might be better to fit a spline to the data, with four knots, corresponding to the two ends and the two join points, or a thin-plate spline that accommodates the design.

Steve Denham

Contributor
Posts: 62

## Re: Bent-stick model with proc nlin

Hello.

A very good proc nlin example is in the following link

Regression - hockey sticks, broken sticks, piecewise, change points

Occasional Contributor
Posts: 8

## Re: Bent-stick model with proc nlin

Thanks a lot for you answers.

I've used the piecewise regression and applied Steve's advice (expectation across all X + continuity and smoothness).

So I've 3 equations :

1. when X<X1 Y=a1+b1X
2. when X1<X<X2 Y=a2+b2X+c2X²
3. when X>X2 Y= a3+b3X

which gives :

ods graphics on;

Proc nlin data=Essai_segmentedLQL noitprint plots=(diagnostics fitplot);

parms a1=1 b1=1 b2=1 b3=1 c2=1 X1=10 X2=20;

if (X<=X1) then mean = a1+b1*X;

else

if (X>X1 AND X<=X2) then mean = a1+X1*(b1-b2)+b2*X+c2*(X*X-X1*X1);

else mean = a1+X1*(b1-b2)+X2*(b2-b3)+c2*(X2*X2-X1*X1)+b3*X;

model Y = mean;

run;

ods graphics off;

It seems to work quite well. There's just an issue with the start parameters. I have to estimate graphically the breakpoints. It is not a problem with one set of data, but it is if I want to run several regression with quite different parameters values. But I think I can handle this.

Thank again for you help.

Friedrich

Contributor
Posts: 62