/* ** Lesson 9.2: Goldfeld-Quandt Test and ** Correction for Heteroscedasticity */ use gpe2; output file = gpe\output9.2 reset; load greene[52,3]= gpe\greene.txt; data = greene[2:52,.]; data = miss(data,"NA"); @ NA to missing value @ data = packr(data); @ deletes row w/missing value @ data = sortc(data,3); @ sort data according income @ spending = data[.,2]; income = data[.,3]/10000; /* Goldfeld-Quandt Test */ call reset; _names = {"spending","income","income^2"}; _begin = 1; _end = 17; call estimate(spending,income~income^2); mss1 =__rss/14; @ N-K = 17-3 = 14 @ _begin = 34; _end = 50; call estimate(spending,income~income^2); mss2 =__rss/14; @ N-K = 17-3 = 14 @ print "Goldfeld-Quandt Test Statistic = " mss2/mss1; /* Weighted Least Squares */ call reset; _weight = 1/income; call estimate(spending,income~income^2); end;