Examples / CONSUMER.RPF |
CONSUMER.RPF is an example of estimation of a system of equations by multivariate least squares. It uses the NLSYSTEM instruction to estimate equations from an expenditure system given in Theil (1971), Section 7.6. It works with four groups of commodities: Food, Vice, Durable Goods and Remainder. Data for each consists of its value share \(\times\) (percent) change in quantity (WQ...) and the (percent) change in price (DP...). For commodity group \(i\), we have the equation
\begin{equation} WQ_{it} = u_i DQ_t + \sum\limits_j {\pi _{ij} DP_{jt} + \varepsilon _{it} } \end{equation}
This system of equations is redundant, as the sum of the \(\varepsilon\) over i must be zero. We thus estimate only three of the four equations. We are interested in two constraints:
\begin{equation} \sum\limits_j {\pi _{ij} } = 0 \text{(homogeneity)} \label{eq:consumer_homogeneity} \end{equation}
\begin{equation} \pi _{ij} = \pi _{ji} \text{(symmetry)} \end{equation}
To simplify the former, we parameterize the equations using an “excess” parameter (called EP...) for \(\pi_{i4}\). This parameter has a value of 0 if constraint \eqref{eq:consumer_homogeneity} holds.
We use different PARMSETs to handle the different problems. For instance, the PARMSET RELAX, when added in with the base parameter set, relaxes the homogeneity assumptions by allowing the \(\pi_{i4}\) to be estimated. The PARMSET SYMMETRY, when added to the others, imposes the symmetry constraints:
nonlin(parms=base) mu1 mu2 mu3 p11 p12 p13 p21 p22 p23 p31 p32 p33
nonlin(parms=relax) ep14 ep24 ep34
nonlin(parms=symmetry) p12=p21 p13=p31 p23=p32
The three FRML’s for the three equations we will estimate are:
frml ffood wqfood = mu1*dq+p11*(dpfood-dprem)+$
p12*(dpvice-dprem)+p13*(dpdura-dprem)+ep14*dprem
frml fvice wqvice = mu2*dq+p21*(dpfood-dprem)+$
p22*(dpvice-dprem)+p23*(dpdura-dprem)+ep24*dprem
frml fdura wqdura = mu3*dq+p31*(dpfood-dprem)+$
p32*(dpvice-dprem)+p33*(dpdura-dprem)+ep34*dprem
Because the equations are linear, the guess values aren’t particularly important, and we start everything at 0. The ones that are really important to be zero are the EP14, EP24 and EP34 since zeroing those imposes homogeneity. That’s why those get reset before the third NLSYSTEM:
compute mu1=mu2=mu3=0.0
compute p11=p12=p13=p21=p22=p23=p31=p32=p33=0.0
compute ep14=ep24=ep34=0.0
nlsystem(parmset=base) / ffood fvice fdura
nlsystem(parmset=base+relax) / ffood fvice fdura
compute ep14=ep24=ep34=0.0
nlsystem(parmset=base+symmetry) / ffood fvice fdura
Full Program
cal(a) 1922
all 1962:1
open data consumer.wks
data(format=wks,org=cols) / wqfood wqvice wqdura wqrem dpfood dpvice dpdura dprem
set dq = wqfood + wqvice + wqdura + wqrem
nonlin(parmset=base) mu1 mu2 mu3 $
p11 p12 p13 p21 p22 p23 p31 p32 p33
nonlin(parmset=relax) ep14 ep24 ep34
nonlin(parmset=symmetry) p12=p21 p13=p31 p23=p32
*
frml ffood wqfood = mu1*dq+p11*(dpfood-dprem)+$
p12*(dpvice-dprem)+p13*(dpdura-dprem)+ep14*dprem
frml fvice wqvice = mu2*dq+p21*(dpfood-dprem)+$
p22*(dpvice-dprem)+p23*(dpdura-dprem)+ep24*dprem
frml fdura wqdura = mu3*dq+p31*(dpfood-dprem)+$
p32*(dpvice-dprem)+p33*(dpdura-dprem)+ep34*dprem
*
compute mu1=mu2=mu3=0.0
compute p11=p12=p13=p21=p22=p23=p31=p32=p33=0.0
compute ep14=ep24=ep34=0.0
*
nlsystem(parmset=base,sigma) / ffood fvice fdura
nlsystem(parmset=base+relax) / ffood fvice fdura
compute ep14=ep24=ep34=0.0
nlsystem(parmset=base+symmetry,iters=500) / ffood fvice fdura
*
* Additional code for non-linear maximum likelihood from section 4.11.
*
dec frml[vect] ufrml
frml ufrml = ||wqfood-ffood,wqvice-fvice,wqdura-fdura||
dec symm sigma(3,3)
nonlin(parmset=sigmaparms) sigma
frml mvlikely = %logdensity(sigma,ufrml)
compute sigma=%identity(3)
maximize(parmset=base+sigmaparms) mvlikely
Output
Non-Linear System Estimation
Convergence in 5 Iterations. Final criterion was 0.0000000 <= 0.0000100
Annual Data From 1922:01 To 1952:01
Usable Observations 31
Log Likelihood -24.6331
Dependent Variable WQFOOD
Mean of Dependent Variable 0.3564516129
Std Error of Dependent Variable 0.7798570313
Standard Error of Estimate 0.4708680856
Sum of Squared Residuals 6.8732193747
Durbin-Watson Statistic 1.6916
Dependent Variable WQVICE
Mean of Dependent Variable 0.1632258065
Std Error of Dependent Variable 0.3317568095
Standard Error of Estimate 0.1829687560
Sum of Squared Residuals 1.0378045355
Durbin-Watson Statistic 2.1291
Dependent Variable WQDURA
Mean of Dependent Variable 0.6574193548
Std Error of Dependent Variable 1.5693097585
Standard Error of Estimate 0.4976413368
Sum of Squared Residuals 7.6770539027
Durbin-Watson Statistic 1.7114
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. MU1 0.153224487 0.032500016 4.71460 0.00000242
2. MU2 0.086039027 0.012628776 6.81293 0.00000000
3. MU3 0.489684409 0.034347946 14.25659 0.00000000
4. P11 -0.104267263 0.024568831 -4.24388 0.00002197
5. P12 -0.039179986 0.049319948 -0.79440 0.42696001
6. P13 0.043645731 0.022959760 1.90097 0.05730642
7. P21 0.022834432 0.009546896 2.39182 0.01676518
8. P22 -0.030968853 0.019164623 -1.61594 0.10610761
9. P23 0.002120576 0.008921647 0.23769 0.81212247
10. P31 0.052775172 0.025965799 2.03249 0.04210429
11. P32 0.015375630 0.052124248 0.29498 0.76800888
12. P33 -0.046514680 0.024265237 -1.91693 0.05524725
Covariance\Correlation Matrix of Residuals
WQFOOD WQVICE WQDURA
WQFOOD 0.470868086 0.19671098 -0.66920363
WQVICE 0.056319556 0.174085247 -0.55618678
WQDURA -0.284033825 -0.143536976 0.382581786
Non-Linear System Estimation
Convergence in 2 Iterations. Final criterion was 0.0000000 <= 0.0000100
Annual Data From 1922:01 To 1952:01
Usable Observations 31
Log Likelihood -22.8544
Dependent Variable WQFOOD
Mean of Dependent Variable 0.3564516129
Std Error of Dependent Variable 0.7798570313
Standard Error of Estimate 0.4517981656
Sum of Squared Residuals 6.3277690566
Durbin-Watson Statistic 1.9743
Dependent Variable WQVICE
Mean of Dependent Variable 0.1632258065
Std Error of Dependent Variable 0.3317568095
Standard Error of Estimate 0.1792821023
Sum of Squared Residuals 0.9964042383
Durbin-Watson Statistic 2.2702
Dependent Variable WQDURA
Mean of Dependent Variable 0.6574193548
Std Error of Dependent Variable 1.5693097585
Standard Error of Estimate 0.4764026232
Sum of Squared Residuals 7.0357432418
Durbin-Watson Statistic 1.9323
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. MU1 0.147835996 0.031357522 4.71453 0.00000242
2. MU2 0.084554489 0.012443261 6.79520 0.00000000
3. MU3 0.495527247 0.033065220 14.98636 0.00000000
4. P11 -0.106171762 0.023602578 -4.49831 0.00000685
5. P12 -0.012806948 0.049997083 -0.25615 0.79783200
6. P13 0.039531361 0.022173215 1.78284 0.07461186
7. P21 0.022309739 0.009365952 2.38200 0.01721869
8. P22 -0.023703039 0.019839793 -1.19472 0.23219564
9. P23 0.000987060 0.008798753 0.11218 0.91067925
10. P31 0.054840255 0.024887950 2.20349 0.02756050
11. P32 -0.013221128 0.052719872 -0.25078 0.80198365
12. P33 -0.042053396 0.023380745 -1.79863 0.07207665
13. EP14 0.042114704 0.025763248 1.63468 0.10211584
14. EP24 0.011602668 0.010223347 1.13492 0.25640934
15. EP34 -0.045665727 0.027166288 -1.68097 0.09276865
Non-Linear System Estimation
Convergence in 4 Iterations. Final criterion was 0.0000023 <= 0.0000100
Annual Data From 1922:01 To 1952:01
Usable Observations 31
Log Likelihood -25.7915
Dependent Variable WQFOOD
Mean of Dependent Variable 0.3564516129
Std Error of Dependent Variable 0.7798570313
Standard Error of Estimate 0.4841485646
Sum of Squared Residuals 7.2663948093
Durbin-Watson Statistic 1.7725
Dependent Variable WQVICE
Mean of Dependent Variable 0.1632258065
Std Error of Dependent Variable 0.3317568095
Standard Error of Estimate 0.1831803921
Sum of Squared Residuals 1.0402067375
Durbin-Watson Statistic 2.1368
Dependent Variable WQDURA
Mean of Dependent Variable 0.6574193548
Std Error of Dependent Variable 1.5693097585
Standard Error of Estimate 0.4998142698
Sum of Squared Residuals 7.7442434345
Durbin-Watson Statistic 1.6721
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. MU1 0.179071334 0.027533501 6.50376 0.00000000
2. MU2 0.087927604 0.012223275 7.19346 0.00000000
3. MU3 0.482091683 0.028434138 16.95468 0.00000000
4. P11 -0.107306957 0.024968933 -4.29762 0.00001726
5. P12 0.021986050 0.000000000 0.00000 0.00000000
6. P13 0.043381733 0.000000000 0.00000 0.00000000
7. P21 0.021986050 0.009121665 2.41031 0.01593892
8. P22 -0.026206200 0.017468176 -1.50023 0.13355605
9. P23 0.002226149 0.000000000 0.00000 0.00000000
10. P31 0.043381733 0.019552510 2.21873 0.02650513
11. P32 0.002226149 0.008913365 0.24975 0.80277754
12. P33 -0.044386294 0.023563419 -1.88370 0.05960624
MAXIMIZE - Estimation by BFGS
Convergence in 43 Iterations. Final criterion was 0.0000055 <= 0.0000100
Annual Data From 1922:01 To 1962:01
Usable Observations 31
Skipped/Missing (from 41) 10
Function Value -24.6331
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. MU1 0.153224533 0.032435002 4.72405 0.00000231
2. MU2 0.086039029 0.013164255 6.53581 0.00000000
3. MU3 0.489684251 0.035342158 13.85553 0.00000000
4. P11 -0.104267487 0.026956216 -3.86803 0.00010972
5. P12 -0.039179519 0.051896479 -0.75496 0.45027584
6. P13 0.043645811 0.025627600 1.70308 0.08855341
7. P21 0.022834437 0.009649813 2.36631 0.01796645
8. P22 -0.030968525 0.021129682 -1.46564 0.14274615
9. P23 0.002120522 0.008807082 0.24077 0.80972982
10. P31 0.052775153 0.027347386 1.92981 0.05363086
11. P32 0.015374354 0.058659560 0.26209 0.79324851
12. P33 -0.046514296 0.025907692 -1.79539 0.07259229
13. SIGMA(1,1) 0.221716843 0.056878825 3.89806 0.00009697
14. SIGMA(2,1) 0.026518937 0.016725003 1.58559 0.11283316
15. SIGMA(2,2) 0.033477335 0.008881499 3.76933 0.00016368
16. SIGMA(3,1) -0.133742641 0.050021016 -2.67373 0.00750130
17. SIGMA(3,2) -0.040984184 0.019469504 -2.10505 0.03528738
18. SIGMA(3,3) 0.247647120 0.065670535 3.77105 0.00016256
Copyright © 2025 Thomas A. Doan