Library: | metrics |
See also: | seq |
Quantlet: | sur | |
Description: | Estimates a seemingly unrelated regression system by feasible generalized least squares |
Usage: | {b,s}=sur(surlist1,surlist2) | |
Input: | ||
surlist1 | list of matrices. If there are M equations then surlist1 will be a list of M+1 matrices. The first matrix is comprised of the vectors of observations of the left-hand side variables. Each of the next M matrices consists of the observations of the right-hand-side variables of one of the M equations of the system. | |
surlist2 | list of string vectors. If there are M equations then surlist2 will be a list of M+1 string (column) vectors. Each vector contains the names of the variables of the corresponding matrix from surlist1. | |
Output: | ||
b | vector, containing the generalized least squares coefficient estimates | |
s | vector, containing the estimated standard errors of the components of b |
library("metrics") z=read("carc.dat") price=z[,2] weight=z[,9] foreign=(z[,14].<>1) mpg=z[,3] displ=z[,12] length=z[,10] n=rows(z) one = matrix(n,1) lhs=price~mpg~displ x1=one~foreign~weight~length x2=one~foreign~weight x3=one~foreign~weight surlist1=list(lhs,x1,x2,x3) ; setting up the string vectors for surlist2 yl="price"|"mpg"|"displ" zl1="one"|"foreign"|"weight"|"length" zl2="one"|"foreign"|"weight" zl3="one"|"foreign"|"weight" surlist2=list(yl,zl1,zl2,zl3) {b,s}=sur(surlist1,surlist2)
You will find the following output in the output window Contents of outputgls [ 1,] "=====================================================" [ 2,] " Generalized Least-squares estimates" [ 3,] "=====================================================" [ 4,] " EQ dep. var. R2 " [ 5,] "=====================================================" [ 6,] " 1 price 0.586 " [ 7,] " 2 mpg 0.686 " [ 8,] " 3 displ 0.822 " [ 9,] "=====================================================" [10,] "VARIABLE Coef.Est. Std.Err. t" [11,] "--------------------------------------------------" [12,] "one 7635.062 3698.595 2.064" [13,] "forei 3486.077 587.354 5.935" [14,] "weigh 6.426 0.956 6.724" [15,] "lengt -116.055 32.896 -3.528" [16,] "--------------------------------------------------------- [17,] "one 41.471 2.005 20.683" [18,] "forei -1.425 1.007 -1.414" [19,] "weigh -0.007 0.001 -11.093" [20,] "--------------------------------------------------------- [21,] "one -86.899 23.972 -3.625" [22,] "forei -25.257 12.043 -2.097" [23,] "weigh 0.097 0.007 13.704" [24,] "====================================================="