Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: metrics
See also: gls

Quantlet: seq
Description: Estimates a simultaneous equations model by 3-stage least squares

Usage: {d3sls,cov3,d2sls} = seq(seqlist1,seqlist2)
Input:
seqlist1 list of matrices. If there are M equations then seqlist1 will be a list of M+2 matrices. The first matrix is comprised of the vectors of observations of the left-hand side variables. The next M matrices consist of the observations of the right-hand-side variables of the M equations. The last matrix contains the observations of the exogenous variables of the system.
seqlist2 list of string vectors. If there are M equations then seqlist2 will be a list of M+2 string (column) vectors. Each vector contains the names of the variables of the corresponding matrix from seqlist1.
Output:
d3sls 3-stage lest squares coefficient estimates
cov3 vector
d2sls estimated covariance matrix of the 3sls-estimator
n/a matrix
n/a 2-stage lest squares coefficient estimates
n/a vector

Note:

Example:
; simulated data for a supply-and-demand model
n=50
randomize(101)
sp      = #(1,-0.7)~#(-0.7,1)             	; covariance matrix
mp      = #(4,4)                          	; mean vector
pcompete = qfc(2*matrix(n,1),uniform(n))  	; price of competitor
income  = qfc(3*matrix(n,1),uniform(n))
praw    = qfc(matrix(n,1),uniform(n))    	; price of inputs
one     = matrix(n,1)
randomize(102)
u2=uniform(n)				; uniform random numbers used for error term
n2=1.2*qfn(u2)
randomize(103)
u3=uniform(n)
n3=1.2*qfn(u3)
; price and quantity computed as solutions of 2-equation system
price=1/1.5*(34+.25*pcompete+0.5*income+0.75*praw+-0.8*qfn(u3))
q=40-price+.25*pcompete[,2]+0.5*income+n2
/* structural equations */
;qd=40-price+.25*pcompete+0.5*income+n2
;qs=6+0.5*price-.75*praw+n3
; setting up the matrices for seqlist1
lhs=q~q
z1=one~price~pcompete~income
z2=one~price~praw
x=one~pcompete~income~praw
seqlist1=list(lhs,z1,z2,x)
; setting up the string vectors for seqlist2
yl="quantity demanded"|"quantity supplied"
zl1="one"|"price"|"pcompete"|"income"
zl2="one"|"price"|"praw"
xl="one"|"pcompete"|"income"|"praw"
seqlist2=list(yl,zl1,zl2,xl)
{d3,s,d2}=seq(seqlist1,seqlist2)
d3~d2

Result:
You will find the following output in the output window

Contents of output2sls

[ 1,] "====================================================="
[ 2,] "2stage Least-squares estimates"
[ 3,] "====================================================="
[ 4,] " EQ	dep. var.		R2	"
[ 5,] "====================================================="
[ 6,] " 1	quantity               0.244     "
[ 7,] " 2	quantity               -0.068     "
[ 8,] "====================================================="
[ 9,] "VARIABLE    Coef.Est.        Std.Err.          t"
[10,] "--------------------------------------------------"
[11,] "one           28.296          6.727         28.296"
[12,] "price         -0.495          0.291         -0.495"
[13,] "pcomp          0.113          0.112          0.113"
[14,] "incom          0.345          0.139          0.345"
[15,] "--------------------------------------------------------
[16,] "one            7.513          6.412          7.513"
[17,] "price          0.421          0.267          0.421"
[18,] "praw          -0.364          0.172         -0.364"
[19,] "====================================================="

Contents of output3sls

[ 1,] "====================================================="
[ 2,] "   3stage Least-squares estimates"
[ 3,] "====================================================="
[ 4,] " EQ	dep. var.		R2	"
[ 5,] "====================================================="
[ 6,] " 1	quantity               0.244     "
[ 7,] " 2	quantity               -0.068     "
[ 8,] "====================================================="
[ 9,] "VARIABLE    Coef.Est.        Std.Err.          t"
[10,] "--------------------------------------------------"
[11,] "one           28.365          6.439          4.405"
[12,] "price         -0.498          0.278         -1.791"
[13,] "pcomp          0.128          0.059          2.175"
[14,] "incom          0.341          0.132          2.589"
[15,] "-------------------------------------------------------
[16,] "one            7.513          6.217          1.209"
[17,] "price          0.421          0.258          1.630"
[18,] "praw          -0.364          0.167         -2.176"
[19,] "====================================================="

Contents of _tmp

[1,]   28.365   28.296
[2,] -0.49837 -0.49493
[3,]  0.12777  0.11271
[4,]  0.34135   0.3446
[5,]   7.5132   7.5132
[6,]  0.42127  0.42127
[7,] -0.36355 -0.36355



Author: A. Werwartz, 20000217
(C) MD*TECH Method and Data Technologies, 05.02.2006