## Force proc nlin fit through (0,0)

Hi SAS communit

I have a code like this but I try to force the function to go through 0,0, how do I do this?

Help would be brilliant for me thank you so much!

``````proc nlin data=data plots=fit outest=par_outest;
ods output parameterestimates=par_est;
parameters a=1 b=2 c=0.5 d=1;
model y = b+(a-b)/(1+exp((x-c)/d));
run;``````
2 REPLIES 2

## Re: Force proc nlin fit through (0,0)

Hi @linlin87,

If you set x=y=0 in your model equation, you obtain a relationship between the parameters: a=-b*exp(-c/d), so you can eliminate parameter a (or one of the other parameters if you prefer), use

``````parameters b=2 c=0.5 d=1;
model y = b*(1-(1+exp(-c/d))/(1+exp((x-c)/d)));``````

and finally compute a point estimate of a from the estimates of b, c and d using the above relationship (and, with some more work, an approximate standard error and approximate confidence limits for a from the approximate standard errors of b, c and d, if needed).

## Re: Force proc nlin fit through (0,0)

See the article, "Regression with inequality constraints on parameters."

It shows several examples, starting with simple restrictions and ending with the section "More general linear constraints," which applies to your problem.

First, set x=0 and y=0 in your model and solve for a as a function of the other parameters. I obtain

a = b*(1-t), where t = 1 + exp(-c/d), which simplifies to
a = -b*exp(-c/d).

You then use that expression in your PROC NLIN code:

``````proc nlin data=data plots=fit outest=par_outest;
ods output parameterestimates=par_est;
parameters b=2 c=0.5 d=1;
/* constrain the problem to pass through the origin (x,y)=(0,0) */
a = -b*exp(-c/d);
model y = b+(a-b)/(1+exp((x-c)/d));
estimate 'a' -b*exp(-c/d);              /* estimate original parameter */
run;``````

From SAS Users blog