## Question on Seemingly Unrelated Regression

Econometrics questions and discussions

### Question on Seemingly Unrelated Regression

Dear tom,

I want to estimate a Linear Expenditure System based on the Stone-Geary utility function:

where: demand for commodity i; marginal expenditure share with ; and minimum quantity demanded from commodity i.

Maximizing this function subject to the expenditure restriction where is price of commodity i and m is total expenditure, leads to the linear expenditure system:
.

Time series form of the above equation is:
.

At first, I estimate by using the Engel function as: .
And after estimation of , I plug it into the above equation and finally I estimate the above equation by SUR.

But I don’t know how to estimate it in RATS by SUR. I don't know how to write a program for it in RATS.
I would be grateful if you could possibly guide me through it.
jack

Posts: 158
Joined: Tue Sep 27, 2016 11:44 am

### Re: Question on Seemingly Unrelated Regression

Sorry. If you have the alpha's, what are the parameters to be estimated?
TomDoan

Posts: 7457
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Question on Seemingly Unrelated Regression

I want to derive demand functions and therefore cost functions for n commodities. The utility function is the Stone-Geary utility function. Maximizing utility function with respect to budget constrain leads to the linear expenditure system:

As you see, each equation has two parameters: and . In the first step, I use an Engel function (a panel model) for estimating : .

Then I use obtained from the first step in the linear expenditure system and obtain parameter via SUR method.

But I don’t know how to write a SUR program in RATS.
jack

Posts: 158
Joined: Tue Sep 27, 2016 11:44 am

### Re: Question on Seemingly Unrelated Regression

Use NLSYSTEM, not SUR.
TomDoan

Posts: 7457
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Question on Seemingly Unrelated Regression

Dear Tom,

As you know, it is really beyond my ability to write a program for it. I used to sue a kind of prototype one and adjust it according to my problem as I did with respect to MVGARCH and VAR models in the past.

It would be really kind of you to guide and help me in writing a model for it.
jack

Posts: 158
Joined: Tue Sep 27, 2016 11:44 am

### Re: Question on Seemingly Unrelated Regression

consumer.rpf is the closest thing we have to that. It doesn't look like it's all that difficult---you almost literally just write down the FRML's that match your equations. You just need to add a mu>=0 to your PARMSET to force the mu's to be non-negative.
TomDoan

Posts: 7457
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Question on Seemingly Unrelated Regression

I installed winRATS standard 9.2. But I can't find consumer.wks. How I can find it?
jack

Posts: 158
Joined: Tue Sep 27, 2016 11:44 am

### Re: Question on Seemingly Unrelated Regression

With the program files (including consumer.rpf) in your Examples and Procedures folder.
TomDoan

Posts: 7457
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Question on Seemingly Unrelated Regression

Dear Tom,

with two commodities, the linear expenditure system will be as follow:

I have data on p*x, p and m.

Is it possible to estimate alpha and mu with a program like consumer.rft? Because the first term in right hand sides of each equation is multiplication of alpha with mu.
jack

Posts: 158
Joined: Tue Sep 27, 2016 11:44 am

### Re: Question on Seemingly Unrelated Regression

Sure. That's the whole point of doing it with NLSYSTEM rather than SUR. Your model is linear in the observables, but not linear in the parameters. Also, it's not "seemingly unrelated" anyway---the mu's show up in both equations so they're very much related.
TomDoan

Posts: 7457
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Question on Seemingly Unrelated Regression

I wrote a code (based on consumer.rpf) and run it but I received this error from RATS:

## REG12. SIGMA Is Singular/Not PSD At Row 8. Too Many Equations for Data Set Size?

This is the code:
Code: Select all
`open data C:\les1.xlsxdata(format=xlsx,org=cols) / c1   c2   c3   c4   c5   c6   c7   c8   p1   p2   p3   p4   p5   p6   p7   p8   mnonlin(parmset=base) mu1 mu2 mu3 mu4 mu5 mu6 mu7 mu8 \$   a1 a2 a3 a4 a5 a6 a7 a8nonlin(parmset=nonnegative) mu1>=0.0 mu2>=0.0 mu3>=0.0 mu4>=0.0 \$    mu5>=0.0 mu6>=0.0 mu7>=0.0 mu8>=0.0nonlin(parmset=summation) a1+a2+a3+a4+a5+a6+a7+a8==1*frml fx1 c1 = (1-a1)*mu1*p1+a1*m-a1*mu2*p2+\$   -a1*mu3*p3-a1*mu4*p4-a1*mu5*p5-a1*mu6*p6-a1*mu7*p7-a1*mu8*p8frml fx2 c2 = (1-a2)*mu2*p2+a2*m-a2*mu1*p1+\$   -a2*mu3*p3-a2*mu4*p4-a2*mu5*p5-a2*mu6*p6-a2*mu7*p7-a2*mu8*p8frml fx3 c3 = (1-a3)*mu3*p3+a3*m-a3*mu1*p1+\$   -a3*mu2*p2-a3*mu4*p4-a3*mu5*p5-a3*mu6*p6-a3*mu7*p7-a3*mu8*p8frml fx4 c4 = (1-a4)*mu4*p4+a4*m-a4*mu1*p1+\$   -a4*mu2*p2-a4*mu3*p3-a4*mu5*p5-a4*mu6*p6-a4*mu7*p7-a4*mu8*p8frml fx5 c5 = (1-a5)*mu5*p5+a5*m-a5*mu1*p1+\$   -a5*mu2*p2-a5*mu3*p3-a5*mu4*p4-a5*mu6*p6-a5*mu7*p7-a5*mu8*p8frml fx6 c6 = (1-a6)*mu6*p6+a6*m-a6*mu1*p1+\$   -a6*mu2*p2-a6*mu3*p3-a6*mu4*p4-a6*mu5*p5-a6*mu7*p7-a6*mu8*p8frml fx7 c7 = (1-a7)*mu7*p7+a7*m-a7*mu1*p1+\$   -a7*mu2*p2-a7*mu3*p3-a7*mu4*p4-a7*mu5*p5-a7*mu6*p6-a7*mu8*p8frml fx8 c8 = (1-a8)*mu8*p8+a8*m-a8*mu1*p1+\$   -a8*mu2*p2-a8*mu3*p3-a8*mu4*p4-a8*mu5*p5-a8*mu6*p6-a8*mu7*p7*compute mu1=mu2=mu3=mu4=mu5=mu6=mu7=mu8=0.0compute a1=a2=a3=a4=a5=a6=a7=a8=0.0*nlsystem(parmset=base+nonnegative+summation,iters=500) / fx1 fx2 fx3 fx4 fx5 fx6 fx7 fx8*`
jack

Posts: 158
Joined: Tue Sep 27, 2016 11:44 am

### Re: Question on Seemingly Unrelated Regression

Can you estimate all 8? Most demands systems have an adding up constraint so you can also estimate N-1.
TomDoan

Posts: 7457
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Question on Seemingly Unrelated Regression

I deleted equation 8 but I again got the error:
## REG12. SIGMA Is Singular/Not PSD At Row 7. Too Many Equations for Data Set Size?

Code: Select all
`open data C:\Users\LapTop118\Desktop\les1.xlsxdata(format=xlsx,org=cols) / c1   c2   c3   c4   c5   c6   c7   c8   p1   p2   p3   p4   p5   p6   p7   p8   mnonlin(parmset=base) mu1 mu2 mu3 mu4 mu5 mu6 mu7 mu8 \$   a1 a2 a3 a4 a5 a6 a7 a8nonlin(parmset=nonnegative) mu1>=0.0 mu2>=0.0 mu3>=0.0 mu4>=0.0 \$    mu5>=0.0 mu6>=0.0 mu7>=0.0 mu8>=0.0nonlin(parmset=summation) a1+a2+a3+a4+a5+a6+a7+a8==1*frml fx1 c1 = (1-a1)*mu1*p1+a1*m-a1*mu2*p2+\$   -a1*mu3*p3-a1*mu4*p4-a1*mu5*p5-a1*mu6*p6-a1*mu7*p7-a1*mu8*p8frml fx2 c2 = (1-a2)*mu2*p2+a2*m-a2*mu1*p1+\$   -a2*mu3*p3-a2*mu4*p4-a2*mu5*p5-a2*mu6*p6-a2*mu7*p7-a2*mu8*p8frml fx3 c3 = (1-a3)*mu3*p3+a3*m-a3*mu1*p1+\$   -a3*mu2*p2-a3*mu4*p4-a3*mu5*p5-a3*mu6*p6-a3*mu7*p7-a3*mu8*p8frml fx4 c4 = (1-a4)*mu4*p4+a4*m-a4*mu1*p1+\$   -a4*mu2*p2-a4*mu3*p3-a4*mu5*p5-a4*mu6*p6-a4*mu7*p7-a4*mu8*p8frml fx5 c5 = (1-a5)*mu5*p5+a5*m-a5*mu1*p1+\$   -a5*mu2*p2-a5*mu3*p3-a5*mu4*p4-a5*mu6*p6-a5*mu7*p7-a5*mu8*p8frml fx6 c6 = (1-a6)*mu6*p6+a6*m-a6*mu1*p1+\$   -a6*mu2*p2-a6*mu3*p3-a6*mu4*p4-a6*mu5*p5-a6*mu7*p7-a6*mu8*p8frml fx7 c7 = (1-a7)*mu7*p7+a7*m-a7*mu1*p1+\$   -a7*mu2*p2-a7*mu3*p3-a7*mu4*p4-a7*mu5*p5-a7*mu6*p6-a7*mu8*p8*compute mu1=mu2=mu3=mu4=mu5=mu6=mu7=mu8=0.0compute a1=a2=a3=a4=a5=a6=a7=a8=0.0*nlsystem(parmset=base+nonnegative+summation,iters=10000) / fx1 fx2 fx3 fx4 fx5 fx6 fx7*`
jack

Posts: 158
Joined: Tue Sep 27, 2016 11:44 am

### Re: Question on Seemingly Unrelated Regression

There's nothing fundamentally wrong with the model---if I put in random data, it works. So there must be something wrong with your data set. How much data do you have?
TomDoan

Posts: 7457
Joined: Wed Nov 01, 2006 5:36 pm

### Re: Question on Seemingly Unrelated Regression

10 years for each variables (17 variables).
jack

Posts: 158
Joined: Tue Sep 27, 2016 11:44 am

Next