Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: SUREG for Almost Ideal Demand System

 From "Brian P. Poi" To statalist@hsphsun2.harvard.edu Subject Re: st: SUREG for Almost Ideal Demand System Date Sat, 02 Jul 2011 18:55:25 -0400

```
On 07/01/2011 08:37 PM, Michael Musyoka wrote:

```
```Thanks a lot Poi for the assistance. Indeed I have managed it directly with the
coefficients from Sureg. But once I extract the coefficients into a matrix, I am

not getting the se and variance covariance matrix. Is there a way to combine
nlcom with matrix of coefficients? this will make it possible to do the own and
cross elasticities by stating i=j or i>j and vice versa at once....
For example...say Matrix E...Expenditure coefficient in Sureg....then

matrix list E
matrix c=J(13,1,1)
matrix Expel=J(13,1,0)
matrix n=J(13,1,0)
forval i=1/13 {
forval j=1/1  {
mat Expel[`i',`j']=c[`i',`j']+(scd[`i',`j']*E[`i',`j'])/sw[`i',`j']
nlcom (shares:c[`i',`j']+(0.33450538*E[`i',`j'])/.14810108)
}
}
```
```
```
I may have been unclear when I stated that -nlcom- could estimate multiple functions at once. What I meant by that was that if you want to obtain the variance-covariance matrix of multiple estimates, you specify all of the functions in the same call to -nlcom-. No looping is required.
```
```
For example, say you've just replicated example 4 from the Reference manual entry for -nlsur-, so that the active estimation results in Stata contain a 4-equation demand system. Now, let's obtain the vector of income elasticities and the corresponding covariance matrix. For the basic AIDS model, the income elasticity for the i'th good is eta_i = 1 + beta_i / w_i. To implement this formula, we need to pick the set of expenditure shares at which we want the elasticities. For simplicity, we will use the means. In Stata,
```

// Get the means of the	w's
summ w1, meanonly
scalar w1_mean = r(mean)
summ w2, meanonly
scalar w2_mean = r(mean)
summ w3, meanonly
scalar w3_mean = r(mean)
summ w4, meanonly
scalar w4_mean = r(mean)

nlcom   (1 + _b[/b1]/w1_mean)                           ///
(1 + _b[/b2]/w2_mean)                           ///
(1 + _b[/b3]/w3_mean)                           ///
(1 + (-_b[/b1] - _b[/b2] - _b[/b3])/w4_mean)

mat eta = r(b)
mat etaV = r(V)

// Let's verify Engel aggregation to check our results
mat ws = (w1_mean, w2_mean, w3_mean, w4_mean)
mat result = eta*ws'
mat list result

// Here	is the complete	covariance matrix:
mat list etaV

```
Instead of thinking in terms of a matrix of price elasticities, think in terms of a vector where we stack the columns one on top of another. If the price elasticity matrix is 4x4, then think in terms of a 16x1 vector of functions; otherwise, conceptualizing what the covariance matrix of what is already a matrix gets tricky. In this case your call to -nlcom- would include a total of 16 functions, one for each elasticity of good i with respect to price j.
```
I hope this helps.

-- Brian Poi
-- brian@poiholdings.com
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```