http://pages.stern.nyu.edu/~wgreene/Econometrics/RestrictedLeastSquares.lim http://pages.stern.nyu.edu/~wgreene/Econometrics/farms.lpj Restricted Least Squares Using Matrix Algebra ? Make the four input coefficients sum to 1.0 Namelist ; X = one,x1,x2,x3,x4 $ Create ; y = yit $ Regress ; Lhs = y ; Rhs = X ; Res = e $ ? (Regress ; Lhs = y ; Rhs = X ; CLS:b(2)+b(3)+b(4)+b(5)=1$ Matrix ; R = [0,1,1,1,1] $ Matrix ; q = [1] $ Matrix ; list ; m = R*b - q $ Matrix ; A = R**R' ; C = *R' * $ Matrix ; list ; bstar = b - C*m $ Create ; estar = y - X'bstar $ Calc ; list ; e'e ; estar'estar $ Matrix ; list ; mstar = R*bstar - q $ ? Make the four input coefficients sum to 1.0 ? and zero out the 5 year dummy variables Create ; y = yit $ Namelist ; X = one,x1,x2,x3,x4, year93,year94,year95,year96,year97 $ Matrix ; R = [ 0,1,1,1,1,0,0,0,0,0 / 0,0,0,0,0,1,0,0,0,0 / 0,0,0,0,0,0,1,0,0,0 / 0,0,0,0,0,0,0,1,0,0 / 0,0,0,0,0,0,0,0,1,0 / 0,0,0,0,0,0,0,0,0,1 ] $ Matrix ; q = [1/0/0/0/0/0] $ Regress ; Lhs = y ; Rhs = X ; Res = e $ ? ; cls:b(2)+b(3)+b(4)+b(5)=1, ? b(6)=0,b(7)=0,b(8)=0,b(9)=0,b(10)=0$ Matrix ; list ; m = R*b - q $ Matrix ; A = R**R' ; C = *R' * $ Matrix ; list ; bstar = b - C*m $ Create ; estar = y - X'bstar $ Calc ; list ; e'e ; estar'estar $ Matrix ; list ; mstar = R*bstar - q $ ? Lagrange Multipliers Matrix ; list ; Lambda = *m $