options crt limwarn=0 ; name yeardum 'Estimating the Average of a Set of Dummies' ; supres smpl ; ? ? This run shows the trick for estimating the average of a set ? of year effects when there are a complete set of year dummies ? in the model. The model estimated is a simple linear ? transformation of the original model. The trick works for ? unbalanced as well as balanced panels; this is the main novelty. ? ? TSP 4.2B (March 1994) ? Author: Bronwyn Hall ? ? t is the number of years (the maximum number for each firm). ? set nt = 1200 ; set t = 3 ; ? nt is the total number of obs list yrdum year1-year3 ; ? Original year dummies. list dums dum1-dum3 ; ? Transformed dummies. list alist a1-a3 ; ? Dummy coefficients. smpl 1 nt ; ? Generate some test data. random u ; random x ; trend (period=t) time ; dummy time yrdum ; const b 1 ; y = x*b+u ; ? Model without year dummies. set i = 0 ; dot 1 2 3 ; ? Add year dummy terms. set i = i+1 ; set a. = -.8+.5*i ; y = y + a.*year. ; enddot ; ? ? Balanced Panel of 3 Years. ? olsq y x yrdum ; frml avgeq abar = (year1+year2+year3)/t ; analyz avgeq ; ? Printout estimate of the average year effect as a check. ? ? The next 7 lines of code set up the array of dummies that will be ? used to estimate the mean of the year dummies. The first dummy will ? give the mean - it consists of the number of years for each individual ? in the panel. The others are simply -1's (to guarantee a rank T-1 ? matrix that is a linear transform of the original dummy matrix). The ? coefficients estimated for the 2,..,T dummies will be the same as in ? the original (ordinary) time dummy regression. ? dot 1 2 3 ; dum. = year. ; enddot ; smplif year1 ; dum1 = t ; dot 2 3 ; dum. = -1 ; enddot ; smpl 1 nt ; olsq y x dums ; ? ? Randomly sample the simulated data so we get an unbalanced panel. ? random(uniform) choose ; select choose>.3 ; msd yrdum ; olsq y x yrdum ; analyz avgeq ; ? Printout estimate of the average year effect as a check. olsq y x dums ; stop ; end ;