Three-Stage Least-squares Regression
[results]=threesls(arg1,...,argn)
* argi= arguments which can be:
- an equation of the following form:
'vary = coef1*varx1+...+coefi*varxi' where:
. coefi = the name of a coefficient
. varxi = the name of a variable
- 'coef=coef1;coef2;...coefn' where coef1,...,coefn are the names of the coefficients in the system (optional; default: 'coef=a1;...,an')
- 'endo =[endo1;...;endon]' where endo1,...,endon are the names of the endogenous variables (optional; necessary if the names of the endogenous variables in the rhs of the equations are not the same as those of the lhs; default: the names of all the lhs sides of the equations)
- the string 'noprint' if you do not want to print the results
- the string 'dropna' if the user wants to remove the NA values from the data
* results = a results tlist with:
- results('meth') = 'threesls'
- results('namecoef') = the matrix of the names of the coefficients
- results('riv1'),...,results('rivn) = the results of the iv estimation for each equation (see iv for more details).
x1 = rand(100,1,'n') x2 = rand(100,1,'n') x3 = rand(100,1,'n') evec = rand(100 ,3,'n') evec(:,2) = evec(:,3) + evec(:,2) // create cross-eqs corr // create simultaneously determined variables y1,y2 y1=10+x1+evec(:,1) y2=10+y1*0.5+x2*2+evec(:,2) y3=10+y2*1.5+x2*3+x3*4+evec(:,3) r=threesls('y1=a1+b1*x1','y2=a2+b2*x2+c2*y1','y3=a3+b3*x3+c3*y2+d3*x2',... 'coef=a1;a2;a3;b1;b2;b3;c1;c2;c3;d3') // Example taken from function threesls_d. The equations are 'y1=a1+b1*x1','y2=a2+b2*x2+c2*y1' and 'y3=a3+b3*x3+c3*y2+d3*x2'. // Coefficients are a1, a2, a3, b1, b2, b3, c1, c2, c3, d3. Their name is given to the function through the input 'coef=a1;a2;a3;b1;b2;b3;c1;c2;c3;d3'. | ![]() | ![]() |