$TITLE: M5-2.GMS, example of non-linear, constrainted least squares $ONTEXT there are I observations on two variables (set J), a dependent variables Y and an independent variable J. the objective is to estimate a log linear relationship vias OLS minimizing the sum of squared deviations imagine that this is production data (two inputs), added constraint equation imposes constant returns to scale: sum of slope coeff = 1 Y = output, X1 = capital, X2 = labor $OFFTEXT SETS I observations /I1*I6/ J dep and ind var /J1*J3/ K(J) set of independent variables /J2*J3/; PARAMETERS Y0(I) X0(I,K); TABLE BENCH(I,J) J1 J2 J3 I1 4 2 2 I2 3 4 1 I3 10 6 5 I4 14 11 3 I5 18 13 4 I6 22 14 6; DISPLAY BENCH; Y0(I) = BENCH(I, "J1"); X0(I,K) = BENCH(I, K); DISPLAY Y0, X0; VARIABLES ALPHA intercept BETA(K) slope coefficients (elasticities since estimated in logs) DEV sum of squared deviations YHAT(I) fitted values of the dependent variable; EQUATIONS OBJECTIVE objective function = sum of squared residuals EYHAT(I) equation for the fitted values of Y (log linear) CRS constraint constant returns: sum of slope coefficients = 1; OBJECTIVE.. DEV =E= SUM(I, (YHAT(I) - Y0(I))*(YHAT(I) - Y0(I))); EYHAT(I).. LOG(YHAT(I)) =E= ALPHA + SUM(K, BETA(K)*LOG(X0(I,K))); CRS.. SUM(K, BETA(K)) =E= 1; * model OLS: unconstrainted OLS MODEL OLS /OBJECTIVE, EYHAT/; ALPHA.L = 1; BETA.L(K) = 1; YHAT.L(I) = 2; SOLVE OLS USING NLP MINIMIZING DEV; * model OLSC: constrainted least squares, imposes CRS MODEL OLSC /ALL/; SOLVE OLSC USING NLP MINIMIZING DEV; * process output to get observed and fitted values of Y PARAMETER RESULTS(I,*); RESULTS(I, "YHAT") = YHAT.L(I); RESULTS(I, "Y0") = Y0(I); DISPLAY RESULTS; $LIBINCLUDE XLDUMP RESULTS M5.XLS SHEET1!B12