Resources

A Consumer Demand Model

/*--------------------------------------------------------------

                    SAS Sample Library

        Name: modex02.sas
 Description: Example program from SAS/ETS User's Guide,
              The MODEL Procedure
       Title: A Consumer Demand Model
     Product: SAS/ETS Software
        Keys: nonlinear simultaneous equation models
        PROC: MODEL
       Notes:

--------------------------------------------------------------*/

data tlog1;
   input t share1 share2 share3 p1 p2 p3;
datalines;
  1    0.129      0.493     0.378    1.40406    1.49089    1.39449
  2    0.126      0.499     0.375    1.43488    1.52051    1.52407
  3    0.114      0.522     0.364    1.57969    1.46667    1.65631
  4    0.119      0.511     0.370    1.49961    1.55867    1.92536
  5    0.126      0.509     0.365    2.01051    1.61371    1.78626
  6    0.127      0.497     0.376    1.65436    1.69078    1.70540
  7    0.128      0.495     0.377    1.62652    1.66765    1.61266
  8    0.119      0.514     0.367    1.66980    1.50343    1.47088
  9    0.125      0.499     0.376    1.40209    1.48202    1.45782
 10    0.108      0.523     0.369    1.38906    1.42591    1.51648
 11    0.106      0.538     0.356    1.43997    1.34984    1.46885
 12    0.102      0.544     0.354    1.33201    1.31234    1.42404
 13    0.102      0.540     0.358    1.17398    1.27947    1.33307
 14    0.136      0.471     0.393    1.12215    1.29747    1.22201
 15    0.164      0.535     0.301    1.18175    1.27395    1.13321
 16    0.111      0.532     0.357    1.08195    1.24290    1.10386
 17    0.125      0.503     0.372    1.02606    1.17886    1.04558
 18    0.127      0.497     0.376    1.01399    1.12550    0.95515
 19    0.145      0.458     0.397    1.31784    1.11050    0.89666
 20    0.164      0.492     0.314    1.13912    1.10141    0.89219
 21    0.130      0.492     0.378    0.94897    1.06430    0.92483
 22    0.139      0.472     0.389    1.03611    0.99587    0.88390
 23    0.134      0.483     0.383    0.95167    0.97834    0.84329
 24    0.138      0.475     0.387    0.94553    0.91948    0.82540
 25    0.130      0.486     0.384    0.82124    0.88765    0.84305
 26    0.142      0.467     0.391    0.91700    0.83821    0.81825
 27    0.140      0.471     0.389    0.81815    0.80076    0.80307
 28    0.139      0.473     0.388    0.75771    0.76853    0.78136
 29    0.136      0.481     0.383    0.66028    0.76027    0.77448
 30    0.129      0.483     0.388    0.72626    0.72469    0.74480
 31    0.138      0.476     0.386    0.65864    0.69642    0.73169
 32    0.141      0.470     0.389    0.70983    0.66085    0.70354
 33    0.140      0.471     0.389    0.67501    0.64329    0.68928
 34    0.140      0.472     0.388    0.64815    0.62016    0.67150
 35    0.149      0.443     0.408    0.62117    0.60156    0.65453
 36    0.140      0.472     0.388    0.61053    0.56857    0.62066
 37    0.140      0.471     0.389    0.61021    0.53726    0.58696
 38    0.140      0.472     0.388    0.57732    0.51423    0.55821
 39    0.139      0.474     0.387    0.52595    0.49851    0.54516
 40    0.138      0.476     0.386    0.48673    0.48049    0.52500
 41    0.159      0.483     0.358    0.51146    0.45405    0.49703
 42    0.137      0.478     0.385    0.43755    0.45166    0.49636
 43    0.137      0.478     0.385    0.41167    0.43600    0.49146
 44    0.138      0.475     0.387    0.43348    0.40635    0.46186
 ;

title1 'Consumer Demand--Translog Functional Form';
title2 'Asymmetric Model';

proc model data=tlog1;
   endogenous share1 share2;
   parms a1 a2 b11 b12 b13 b21 b22 b23 b31 b32 b33;

   bm1 = b11 + b21 + b31;
   bm2 = b12 + b22 + b32;
   bm3 = b13 + b23 + b33;
   lp1 = log(p1);
   lp2 = log(p2);
   lp3 = log(p3);
   share1 = ( a1 + b11 * lp1 + b12 * lp2 + b13 * lp3 ) /
            ( -1 + bm1 * lp1 + bm2 * lp2 + bm3 * lp3 );
   share2 = ( a2 + b21 * lp1 + b22 * lp2 + b23 * lp3 ) /
            ( -1 + bm1 * lp1 + bm2 * lp2 + bm3 * lp3 );

   fit share1 share2
       start=( a1 -.14 a2 -.45 b11 .03 b12 .47 b22 .98 b31 .20
               b32 1.11 b33 .71 ) / outsused=smatrix sur;
run;

title2 'Symmetric Model';
proc model data=tlog1;
   var share1 share2 p1 p2 p3;
   parms a1 a2 b11 b12 b22 b31 b32 b33;
   bm1 = b11 + b12 + b31;
   bm2 = b12 + b22 + b32;
   bm3 = b31 + b32 + b33;
   lp1 = log(p1);
   lp2 = log(p2);
   lp3 = log(p3);
   share1 = ( a1 + b11 * lp1 + b12 * lp2 + b31 * lp3 ) /
            ( -1 + bm1 * lp1 + bm2 * lp2 + bm3 * lp3 );
   share2 = ( a2 + b12 * lp1 + b22 * lp2 + b32 * lp3 ) /
            ( -1 + bm1 * lp1 + bm2 * lp2 + bm3 * lp3 );
   fit share1 share2
       start=( a1 -.14 a2 -.45 b11 .03 b12 .47 b22 .98 b31 .20
               b32 1.11 b33 .71 ) / sdata=smatrix sur;
run;

data _null_;
   /* probchi( reduced-full, n-restrictions )*/
   p = 1-probchi( 1.44, 3 );
   put p=;
run;