?*********************************************************************** ?*********************************************************************** ?*********************************************************************** ?*********************************************************************** ?======================================================================= ? I. Regression: Uses healthcare.lpj ?======================================================================= ?*********************************************************************** ?*********************************************************************** ?*********************************************************************** ?*********************************************************************** SETPANEL ; group = id ; pds = ti $ ti = the group size CREATE ; t = ndx(id,1) $ t = the within group index, 1,2,...,Ti ? Note, yr is the index of the actual year. t is the simple index ? within the group. t = 1 for the first observation in the group ? regardless of what the year is. t is for 'exchangeable' operations. CREATE ; yr = map(year) $ year - 1983 ; if(yr=8)yr=6 ; if(yr=11)yr=7 $ ?======================================================================= ? Section I. Basic Regression ? Part 1. Descriptive Statistics ?======================================================================= DSTAT ; rhs = * $ (The * means all variables in the active data set.) CREATE ; loginc=log(income) $ CALC ; incbar=xbr(loginc);sdvinc=sdv(loginc)$ CREATE ; normal=rnn(incbar,sdvinc)$ KERNEL ; if[year = 1994] ; rhs=loginc,normal ; title=Kernel Estimator for Log of Income $ BOXPLOT; If[Female=1 & Income < 2] ; Rhs = Income ; Str=yr ; Labels = 1984,1985,1986,1987,1988,1991,1994 ; Title=Boxplots of Income by Year in GSOEP Data$ HISTOGRAM ; if [ year = 1994] ; rhs = educ $ CREATE ; yrseduc = int(educ) $ HISTOGRAM ; if[year = 1994] ; rhs = yrseduc ; title=Full Years of Education $ KERNEL ; if[year = 1994] ; Rhs = educ $ ?======================================================================= ?Part 2. Linear Regression and Testing Hypotheses ?======================================================================= NAMELIST ; demogrfc = age, female, married $ NAMELIST ; years = year1984, year1985,year1986,year1987,year1988,year1991 $ REGRESS ; lhs = loginc ; rhs = one, demogrfc, years $ REGRESS ; lhs = loginc ; rhs = one, demogrfc, #yr $ CALC ; rsq0 = rsqrd $ REGRESS ; lhs = loginc ; rhs = one, demogrfc, years, educ $ CALC ; rsq1 = rsqrd $ CALC ; list ; fstat = ((rsq1 - rsq0)/1) / ((1-rsq1)/(n-kreg)) $ CALC ; list ; Ftb(.95,1,(n-kreg))$ REGRESS ; lhs = loginc ; rhs = one,demogrfc,years ; cls: married = 0 $ REGRESS ; lhs = income ; rhs = one,demogrfc,years; cluster=id ; test : demogrfc$ REGRESS ; lhs = loginc ; rhs = one,demogrfc,years ; test: years $ MATRIX ; by=b(5:10) ; vy=varb(5:10,5:10) $ MATRIX ; list ; wld = by'by $ ?======================================================================= ?Part 3. Partial Effects ?======================================================================= REGRESS ; Lhs = loginc ; rhs = one,age, educ, female, age*educ, age^2, age*female, educ*female $ ?======================================================================= ? Part 3(a) ?======================================================================= PARTIAL ; effects: age | educ = 12,14,16,18,20 $ ?======================================================================= ? Part 3(b) ?======================================================================= PARTIAL ; effects: educ & age = 25(3)64 ; plot(ci) $ ?======================================================================= ? Part 3(c) ?======================================================================= PARTIAL ; effects: female | educ = 12,16,20 & age = 25(5)64 ; plot $ SIMULATE; scenario: female | educ = 12,16,20 & age = 25(5)64 ; plot $ ?======================================================================= ?Part 3(d) Examine threshold effects of education ?======================================================================= Create;yrseduc = int(educ)$ CREATE ; LTHS = YrsEduc < 12 ; HS = YrsEduc = 12 ; COLL = (yrseduc > 12)*(yrseduc<=16) ; GRAD = yrseduc > 16 $ NAMELIST; degree = LTHS,HS,COLL,GRAD $ ? Note dot after degree. Drops last category when it is expanded. REGRESS ; lhs = income ; rhs = one,age,degree., female, degree.*age, age^2, age*female, degree.*female $ PARTIALS ; effects: degree ; transition $ ?======================================================================= ? Part 4 Panel Data ?======================================================================= REGRESS ; lhs = loginc ; rhs = one,demogrfc,years ; Table = OLS $ REGRESS ; lhs = loginc ; rhs = one,demogrfc,years ; cluster=id ; Table = Cluster $ MAKETABLE ; OLS,Cluster ; Standard Errors $ REGRESS ; lhs = loginc ; rhs = one,demogrfc,years ; panel $