Non-linear least-square estimation and imposing constraints

When a linear regression is not possible, we can fit a non-linear equation


nl (y={b0}+{b1}*x1+{b2}*x2)

but since nl doesn't handle missing data, we need to make sure that we drop all missing values first. 

drop if y==. | x1==. |x2==.

In many occasions the results from nl match those of the regress. However the point from the nl command is its ability to impose non-linear constraints. To demonstrate, we can impose nonsensical constraints here: 

nl (y={b0}+{b1}*x1+{b1}*x2)
*note here that we have constrained the coefficients of x1 and x2 to be the same (b1)

We can also impose constraints (more complex ones using the constraint command)
constraint define 1 x1=x2
constraint list

No comments:

Post a Comment