/* ** PROGRAM FOR TIME HET-AUTO ADJUSTED GLS ** ESTIMATION OF PANEL DATA ** ** WRITTEN BY ** SEUNG CHAN AHN ** DEPARTMENT OF ECONOMICS ** W.P. CAREY SCHOOL OF BUSINESS ** TEMPE, AZ 85287 ** */ /* ** COMPUTING RE-GLS AND KIEFER GLS ** */ new ; @ Locate MGIV.COL in the directory you execute this program @ #include mgiv.col ; @ Open output file @ output file = pan_gls2.out reset ; @ Format output file @ format /rd 12,4 ; @ Provide # of observations and # of variables @ nobs = 336 ; nvar = 13 ; @ Read Data @ load dat[nobs,nvar] = auto_1.txt ; @ 48 states (N = 48), 1982 - 1988 (T = 7)@ @ Define Variables @ id = dat[.,1] ; @ ID for States @ year = dat[.,2] ; @ year @ spircons = dat[.,3] ; @ Spirits consumption @ unrate = dat[.,4] ; @ Unemployment rate @ perinc = dat[.,5] ; @ Personal Income @ emppop = dat[.,6] ; @ Employment/Population Ration @ beertax = dat[.,7] ; @ Tax on Case of Beer @ mlda = dat[.,8] ; @ Minimum Legal Drinking Age @ vmiles = dat[.,9] ; @ Ave. mile per driver @ jaild = dat[.,10] ; @ Mandatory Jail Sentense = 1 @ comserd = dat[.,11] ; @ Mandotory Jail Sentence @ allmort = dat[.,12] ; @ # of Vehicle Fatalities @ mrall = dat[.,13] ; @ Vehicle Fatality Rate (VFR) @ @ Creating Time dummy variables @ v = {1982.5, 1983.5, 1984.5, 1985.5, 1986.5, 1987.5 }; dyr = dummy(year,v); @ Define N and T @ t = 7 ; n = rows(dat)/t ; @ Define Dep. Var., Time-varying Reg. and Time-invariant Reg. @ yy = mrall*10000 ; @ dependent var. @ xx = beertax~mlda~jaild~comserd~unrate~ln(perinc)~dyr[.,2:7]; @ time-varying indep. @ zz = ones(rows(yy),1); @ time-invariant indep. @ vny = {"VFR"}; vnx = {"beertax","mlda","jailed","comserd","unrate","lpinc", "yr83", "yr84", "yr85", "yr86", "yr87", "yr88"}; vnz = {"cons"}; /* ** From Here, Do Not Change */ clear dat ; @ Define k and g @ k = cols(xx) ; g = cols(zz) ; let mask[1,4] = 0 1 1 1; let fmt[4,3] = "-*.*s" 8 8 "*.*lf" 10 4 "*.*lf" 10 4 "*.*lf" 10 4; @ Within with HET-AUTO adjustment @ {wb,wcovh} = w_ha(xx,yy,n,t) ; wsh = sqrt(diag(wcovh)) ; "Within Estimation Results (HETERO/AUTO ADJUSTED)" ; "------------------------" ; " dependent variable: " $vny ; ""; "variable coeff. std. err. t-st " ; yyprin = printfm(vnx~wb~wsh~(wb./wsh),mask,fmt); "" ; @ Kiefer's Estimation @ {kb,kcov,kcovh} = kiefer(xx,yy,n,t) ; ks = sqrt(diag(kcov)) ; ksh = sqrt(diag(kcovh)) ; "Kiefer's Within GLS Estimation Results" ; " The error terms are allowed to heteroskedastic or autocorrelated over time."; " But the errors are assumed to be iid over i." ; "------------------------" ; " dependent variable: " $vny ; ""; "variable coeff. std. err. t-st " ; yyprin = printfm(vnx~kb~ks~(kb./ks),mask,fmt); "" ; "Kiefer's Within Estimation Results (CROSS-SECTION HETERO ADJUSTED)" ; " The error terms are allowed to heteroskedastic or autocorrelated over time."; " The errors are also allowed to hetroskedastic over different individuals." ; "------------------------" ; " dependent variable: " $vny ; ""; "variable coeff. std. err. t-st " ; yyprin = printfm(vnx~kb~ksh~(kb./ksh),mask,fmt); "" ; @ RE-GLS Estimation @ {rb,rcov,rcovh} = regls(xx,yy,n,t) ; rs = sqrt(diag(rcov)) ; rsh = sqrt(diag(rcovh)) ; "RE-GLS Estimation Results" ; " The error terms are allowed to heteroskedastic or autocorrelated over time."; " But the errors are assumed to be iid over i." ; "------------------------" ; " dependent variable: " $vny ; ""; "variable coeff. std. err. t-st " ; yyprin = printfm(vnx~rb~rs~(rb./rs),mask,fmt); "" ; "RE-GLS Estimation Results (CROSS-SECTION HETERO ADJUSTED)" ; " The error terms are allowed to heteroskedastic or autocorrelated over time."; " The errors are also allowed to hetroskedastic over different individuals." ; "------------------------" ; " dependent variable: " $vny ; ""; "variable coeff. std. err. t-st " ; yyprin = printfm(vnx~rb~rsh~(rb./rsh),mask,fmt); "" ; output off