Solved
Contributor
Posts: 25

# Estimation of nonnegative parameters

Dear SAS experts,

I would like to estimate nonnegative parameters of a nonlinear function.

The original nonlinear function is:

Q = alpha*exp(rho*T)*(K^beta1)*(L^beta2)*(E^beta3)

alpha, rho, beta1, beta2, beta3 > 0

beta1+beta2+beta3 = 1

I attached a data file (ChinaQ). These data are log data.

I coded SAS, but it does not work. I would like to know how to estimate parameters for the nonlinear function with some restrictions of nonnegative parameters (i.e. beta1+beta2+beta3 = 1).

proc nlp data=chinaQ;

parms alpha rho beta1 beta2 beta3;

bounds alpha rho beta1 beta2 beta3 >= 0;

model Q = log (alpha) + rho*T + beta1*K + beta2*L + (1-beta1-beta2)*E;

run;

Sincerely yours,

J1

Accepted Solutions
Solution
‎08-30-2016 08:34 PM
Super User
Posts: 10,205

## Re: Estimation of nonnegative parameters

```As Rick pointed out, either your utility function is not right or your constraint condition
x1<1 is not right. when x1~0 your utility function can't get the max value.

"I would like to know if SAS can solve the optimal control problem such as a differential game or not."
I am not familiar with these concepts . But I am sure SAS can solve almost any optimal problem.
Especially for SAS/OR .

"I would like to know if standard errors are different from asymptotic standard errors or not."
I think both are the same thing. Asymptotic standard errors are based on big sample(e.g. n is big enough).
If you want exact std err you need to know exact distribution , but it is every hard sometime.

"To get asymptotic standard errors using SAS, do I need a specific coding?"
Most time, SAS can give you std err ,no need for coding. But for your this special case,I think you need to write some code.

"If I want to estimate different parameter values, then I would like to know which part I have to change in your coding."
For changing Object function, you need change:
start func();
....
return (obj);
finish;

For changing constrain condition , you need change another function,
Check IML documentation to know how to write these.

```

All Replies
SAS Super FREQ
Posts: 3,836

## Re: Estimation of nonnegative parameters

Your program statements are calling PROC NLP in SAS/OR software, which is for nonlinear optimization.  However, based on the syntax I think you meant to call PROC NLIN, which is for fitting nonlinear regression models.

Contributor
Posts: 25

## Re: Estimation of nonnegative parameters

Thank you very much for your commment.

I ran SAS based on your comment "NLIN". But I got this message below.

ERROR 22-322: Syntax error, expecting one of the following: a numeric constant,
a datetime constant, -, :, =.
ERROR 76-322: Syntax error, statement will be ignored.
84 bounds alpha rho beta1 beta2 beta3 >= 0;
85 model Q = log (alpha) + rho*T + beta1*K + beta2*L + (1-beta1-beta2)*E;
86 run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE NLIN used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

I think my coding is not correct.

SAS Super FREQ
Posts: 3,836

## Re: Estimation of nonnegative parameters

Yes. In my response there is a hyperlink to the documentation for PROC NLIN. Click on it and read about the syntax for the statements that you are trying to use.

For example, in the doc for the PARMS statement, the first sentence says

"A PARAMETERS (or PARMS) statement is required. The purpose of this statement is to provide starting values for the NLIN procedure. ...

All parameters must be assigned starting values through the PARAMETERS statement. The NLIN procedure does not assign default starting values to parameters in your model."

Another issue: beta3 is not a parameter in your model. Since you don't need to estimate it, remove it from all statements.

Contributor
Posts: 25

## Re: Estimation of nonnegative parameters

Dear Rick,

I have another model for a nonlinear function. But I have no data for an independent variable (i.e. Utility function). In this case, I would like to know how to estimate X1, X2, X3, X4 with standard errors. This model has many restrictions for parameters.

Sincerely yours,

J1

Parameters: X1, X2, X3, X4

Dependent variable: U

Independent variables: C, M, G, T

Model: U = (1/X1)*(C*M^X2*(380/G)^X3)^X1*exp(-X4*T)

Restriction for parameters:

X2, X3>0;

-infinity < X1 <1;

X1*(X2+X3) < 1;

X1*(1+X2+X3) < 1

SAS Super FREQ
Posts: 3,836

## Re: Estimation of nonnegative parameters

Your statement does not make sense. Without data all you have is a parametrized mathematical function for U as a function of X1,X2,X3,X4 on a constrained domain. What do you want to do with this function?

Contributor
Posts: 25

## Re: Estimation of nonnegative parameters

Dear Rick,

There is no data for utility function in Economics.

I know some scholars use the Quasi-FIML (quasi-full-information-maximum-likelihood) to estimate parameter values for the utility function, but they use very special program.

I guess that there are some ways to estimate parameter values for the utlity function using SAS.

If you have any idea to estimate parameter values for the utility function, then please let me know.

Sincerley yours,

J1

SAS Super FREQ
Posts: 3,836

## Re: Estimation of nonnegative parameters

I am not an econometrician, so please try to express your questions in terms of mathematical quantities.

From your conversation with KSharp, it sounds like you might want to find the optimum value of this function over the contrained domain.  You can do that if you have specific values of the parameters, but not if the parameters are unspecified.

If you want to discuss how to find optima of a constrained function of four variables, please post a new question.  Also tell us what SAS products you have licensed.  Usually people use SAS/OR or SAS/IML to perform nonlinear optimization.

Super User
Posts: 10,205

## Re: Estimation of nonnegative parameters

```You should post it at IML forum, since it is about nonlinear optimization problem.

proc iml;
start function(x) global(T,K,L,E,Q);
obj=abs( log(x[1]) + x[2]*T + x[3]*K + x[4]*L + x[5]*E - log(Q) );
return (obj);
finish;

con={0 0 0 0 0 . .,
. . . . . . .,
0 0 1 1 1 0 1 };
x=j(1,5,4);
optn={0 3};

T=1/2;
K=1/4;
L=2;
E=3;
Q=8;
call nlpcg(xres,rc,"function",x,optn,con);
quit;

OUTPUT:

Optimization Start
Parameter Estimates
Objective
Function	Lower
Bound
Constraint	Upper
Bound
Constraint
1	X1	4.000000	0.250000	0	.
2	X2	4.000000	0.500000	0	.
3	X3	0.333333	0.250000	0	.
4	X4	0.333333	2.000000	0	.
5	X5	0.333333	3.000000	0	.
Value of Objective Function = 3.0568528194

```
Super User
Posts: 10,205

## Re: Estimation of nonnegative parameters

```Once you got Object value ~ 0, you can say you got what you want.

OUTPUT:

Optimization Results
Parameter Estimates
Objective
Function
1	X1	3.535421	0.277617
2	X2	0.002152	0.476309
3	X3	0.794348	0.236768
4	X4	0.000008818	1.976258
5	X5	0.205643	2.980308
Value of Objective Function = 1.768923E-10

```
Contributor
Posts: 25

## Re: Estimation of nonnegative parameters

Dear Xia Keshan

Can you explain what this coding means?

con={0 0 0 0 0 . .,

. . . . . . .,

0 0 1 1 1 0 1 };

x=j(1,5,4);

optn={0 3};

I would like to know these values below. Are there average values of my data?

T=1/2;

K=1/4;

L=2;

E=2;

Q=6;

I would like to know how to estimate the parameters of a nonlinear function with STANDARD ERRORS. Do you have any idea to get standard error?

I have another model for a nonlinear function. But I have no data for an independent variable (i.e. U). In this case, I would like to know how to estimate X1, X2, X3, X4 with standard errors. This model has many restrictions for parameters. I also would like to know how to add these restrictions in the coding. I added my coding below. Please see this. Thank you very much in advance.

Sincerely yours,

J1

Parameters: X1, X2, X3, X4

Dependent variable: U

Independent variables: C, M, G, T

Model: U = (1/X1)*(C*M^X2*(380/G)^X3)^X1*exp(-X4*T)

Restriction for parameters:

X2, X3>0;

-infinity < X1 <1;

X1*(X2+X3) < 1;

X1*(1+X2+X3) < 1

Coding is:

proc iml;

start function(x) global(C,M,G,T,U);

obj=abs( log(1/x[1]) + x[1]*C + x[1]*x[2]*M + x[1]*x[3]*(log(380)-G) + x[4]*T - U);

return (obj);

finish;

con={0 0 0 0 0 . .,

. . . . . . .,

0 0 1 1 1 0 1 };

x=j(1,5,4);

optn={0 3};

C=1/2;

M=1/4;

G=2;

T=1/2;

U=8;

call nlpcg(xres,rc,"function",x,optn,con);

quit;

Super User
Posts: 10,205

## Re: Estimation of nonnegative parameters

I misunderstand your question. If you want estimate parameter like PROC REG+RESTRICT statement , then my code is not appropriated . @Rick point you right way .
Contributor
Posts: 25

## Re: Estimation of nonnegative parameters

Dear Xia Keshan,

Thank you very much for your comments. I would like to know how to estimate parameter values when there is no data about the value of a dependent variable (e.g. utility function). I guess that your coding is appropriate, but I would like to know your opinion. Also, I would like to know if your coding can get the standard error or not. If your coding is appropriate, then please see my second model in the previous response.

Sincerely yours,

J1

Super User
Posts: 10,205

## Re: Estimation of nonnegative parameters

```No. My code would get you standard error.
I don't think you can build a model without a dependent variable.
There is URL that you might be interested in .Especial for comment in it.

http://blogs.sas.com/content/iml/2015/06/08/fit-circle.html

```
Super User
Posts: 10,205

## Re: Estimation of nonnegative parameters

```Ha. I think the following code from the comment of URL could give you both parameter estimate and standard error.

*--- SAS/STAT ---;
proc nlin data=circle converge=1e-6;
parms x0 = 0, y0 = 0, R = 1;
bounds R >= 0;
delta = ( (x - x0)**2 + (y - y0)**2 - R**2 ) **2;
model zero = delta;
run;
zero is a column of 0's to satisfy nlin syntax. Cheers.

I could get it too by IML code, but that would lead to many code . Enjoy PROC NLIN .

```
☑ This topic is solved.