twosls — Two-Stage Least-squares Regression
[results]=twosls(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)
- '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') = 'tsls'
- 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(200,1,'n'); x2 = rand(200,1,'n'); evec = rand(200,2,'n'); // // create simultaneously determined variables y1,y2 y1 =1+x1+evec(:,1); y2 = 1+y1+x2+evec(:,2); rt=twosls('y1=a+b*x1','y2=d+e*(y1-x2)+f*x2','coef=a;b;d;e;f') // Example taken from function twosls_d. The equations are 'y1=a+b*x1' and 'y2=d+e*(y1-x2)+f*x2'. // Coefficients are a, b, d, e and f. Their name is given to the function through the input 'coef=a;b;d;e;f'.