Assignment 4 Stata Handout

2.
. * Problem 2 -- use file yule.dta 
. reg paup outratio propold pop
. *next calculate leverage, studentized residual, and cook
. predict leverage, leverage
. predict student, rstudent
. predict cook, cooksd
. * next identify cases with high values of student
. list union student if abs(student) > 2
. * next calculate Bonferroni significance for student
. display .01/(2*32)
.00015625
. * next calculate 2(p/n) cutoff for leverage
. display 2*4/32
.25
. list union leverage if leverage > 2*4/32
. * next do stem and leaf display for cook (can't find
. * how to make index plot in STATA)
. stem cook
. list union cook if cook > .3
. * green-colored lines added 18 Apr 2005
. * next do index plot (I found out how)
. gen secno=_n
. * this generates sequence number secno; next do plot
. graph cook secno, twoway connect(l[.])
. * next calculate percentile of F distribution
. gen fperc=100*F(4,28,cook)
. list union cook fperc if fperc>10
. * next use Hadi procedure creating variables hadiout (1 if
. * Hadi outlier, 0 otherwise) and Mahalanobis distance
. hadimvo paup outratio propold pop, generate (hadiout mahadist)
. * next list Hadi outliers
. list union mahadist if hadiout
. * next do regressions with 30 cases that are not outliers
. reg paup outratio if ~hadiout
. reg paup outratio propold if ~hadiout
. reg paup outratio propold pop if ~hadiout 
. reg paup outratio pop if ~hadiout
. * next do robust regression with original 32 cases
. rreg paup outratio propold pop

 

3.   reg y x1 x2 x3

     corr x1 x2 x3

 

4.   reg y x1 x2 x3

     vif

     reg y x1

 

5.  reg y x

    predict residuals, residuals

    predict yhat, xb

    scatter residuals yhat

    reg y x

    hettest

    reg y x, robust

    reg y x, hc2

    reg y x, hc3

 

6.  reg y x

    predict resids, residuals

    *use excel to create an “obs” variable 1-20

    scatter residuals obs

    reg y x

    dwstat

   

7.  tsset x

    prais y x, rhotype(reg)

    prais y x, corc

   


Last modified 18 Apr 2005