options crt limwarn=0 ; name usbalfe "Simple Panel Example - Hausman Test for FE" ; ? ? This run illustrates how to read in a balanced panel, ? where each observations is a firm-year, and the obs. are ? sorted by firm and then year within firm. ? The variables of interest, sl and cl, are centered within ? years by removing the overall year means. The run also shows ? how to create variables which are the same for all years of ? a single unit in a panel (variables constant over time), and ? how to test for equality of the coefficients across units, ? and for random versus correlated effects. ? ? U.S. Manufacturing Production Function. ? Balanced Panel. ? Data from Table 3 (US) of Mairesse and Hall (Jan. 1993) ? Sales not adjusted for Materials. ? ? If USBAL.DAT is not found, it needs to be uncompressed from ? USBAL.EXE, by giving the command USBAL at the DOS prompt. ? ? If you plan extensive use of this file, it will be more ? efficient to create a databank, and reference it here with ? an IN command. ? ? supres @smpl ; read(setsmpl,file="usbal.dat", format="(f10.0,6f11.0/f9.0,5f11.0)") @id year sic2d logs logs2d logy logl logc logn logk logm shmat logi ; set nt = @nob ; ? Save the total number of observations. ? ? The following code finds the first and last year of data for ? each firm and puts the values in every observation for the firm. ? This illustrates how to produce time-constant variables for a ? panel. The same trick will work for any other variables. ? smpl 1 nt ; ? Define the sales-labor and sl = logs-logl ; ? capital-labor ratio for the cl = logc-logl ; ? sample estimation. list yrdum year79-year88 ; dummy year yrdum ; ? Year dummies. dot 79-88 ; select year. ; ? Choose one year at a time. msd (noprint) sl cl ; ? Means of variables. unmake @mean sl. cl. ; ? Store the means for each year. sl = sl-sl. ; ? Center the variables within cl = cl-cl. ; ? year ; enddot ; smpl 1 nt ; msd sl cl ; ? Check the result. dfirst = @id~=@id(-1) ; ? Define a dummy for the first smpl 1 1 ; dfirst = 1 ; ? observation per firm. smpl 1 nt ; dlast = @id~=@id(+1) ; ? Define a dummy for the last smpl nt nt ; dlast = 1 ; ? observation per firm. smpl 1 nt ; select dlast ; lastyr = year ; ? lastyr is the last year mmake lastyr lastyr ; ? of data for each firm. select dfirst ; firstyr = year ; ? firstyr is the first year ? of data for each firm. unmake lastyr lastyr ; ? put lastyr in the first ? year of data for each firm. nyear = lastyr-firstyr+1 ; ? # of years for each firm. select ~dfirst ; ? Propagate firstyr and lastyr firstyr = firstyr(-1) ; ? from the first year of data lastyr = lastyr(-1) ; ? through all the years of data. select year>85 ; ? Use only 86-88 for the simple panel (byid,noprint) sl cl ; ? example. panel sl cl cl(-1) cl(-2) ; select year>82 ; ? Try 83-88 to see if Hausman panel sl cl ; ? test changes. stop ; end ;