/* Vacation data taken from Hill Undergraduate Econometrics textbook. */ Data vacation; input miles income age kids; datalines; 902. 41. 26. 0. 491. 31. 38. 3. 1841. 87. 40. 2. 406. 54. 48. 4. 0. 77. 43. 4. 1899. 70. 55. 2. 724. 43. 24. 0. 1404. 40. 39. 0. 1367. 69. 55. 2. 560. 38. 29. 2. 1676. 89. 42. 3. 1376. 65. 50. 3. 1059. 69. 45. 3. 924. 68. 42. 0. 1382. 59. 59. 3. 700. 70. 54. 3. 254. 47. 32. 2. 808. 60. 46. 3. 938. 80. 32. 1. 1337. 54. 46. 2. 471. 98. 36. 3. 1426. 84. 26. 0. 1250. 80. 40. 4. 1077. 57. 51. 3. 660. 27. 49. 0. 1091. 80. 41. 3. 433. 48. 50. 2. 1135. 51. 48. 2. 915. 78. 59. 3. 2086. 85. 43. 1. 1454. 71. 33. 2. 844. 56. 32. 2. 1283. 50. 42. 3. 959. 79. 52. 2. 1383. 62. 33. 1. 1485. 62. 45. 0. 615. 49. 53. 4. 657. 57. 26. 1. 728. 66. 47. 1. 421. 59. 43. 2. 647. 44. 23. 0. 870. 53. 58. 2. 249. 88. 42. 1. 535. 72. 38. 1. 1265. 56. 33. 1. 1601. 80. 45. 4. 1513. 82. 30. 2. 1175. 45. 56. 3. 464. 41. 37. 3. 1115. 44. 55. 2. 701. 55. 35. 2. 1034. 66. 45. 3. 1820. 91. 48. 0. 1185. 81. 41. 2. 0. 71. 29. 0. 1288. 60. 32. 1. 1682. 78. 44. 0. 772. 101. 41. 3. 1419. 92. 58. 3. 1670. 69. 48. 2. 846. 63. 52. 2. 811. 83. 37. 0. 59. 34. 32. 3. 1311. 61. 49. 2. 61. 44. 26. 1. 1342. 70. 32. 1. 1863. 65. 44. 4. 1600. 62. 47. 1. 811. 40. 48. 3. 779. 49. 43. 1. 1849. 84. 51. 1. 1412. 69. 46. 0. 957. 51. 43. 0. 583. 32. 42. 3. 573. 51. 49. 0. 748. 40. 36. 1. 881. 61. 54. 2. 1698. 92. 54. 3. 1323. 72. 52. 0. 465. 44. 38. 0. 670. 51. 37. 0. 169. 51. 30. 0. 1888. 72. 42. 1. 594. 82. 37. 2. 1932. 95. 48. 0. 1534. 45. 44. 0. 2354. 86. 38. 1. 1045. 75. 50. 0. 702. 53. 34. 2. 1786. 78. 30. 0. 766. 34. 35. 1. 1055. 52. 40. 1. 155. 59. 39. 3. 504. 51. 31. 0. 1640. 79. 49. 0. 98. 28. 36. 4. 430. 57. 28. 1. 624. 49. 33. 3. 0. 67. 38. 3. 1034. 52. 34. 0. 956. 81. 46. 1. 1459. 82. 54. 3. 2185. 76. 55. 3. 926. 44. 56. 2. 0. 67. 35. 1. 863. 50. 36. 2. 980. 62. 42. 3. 939. 43. 52. 0. 696. 86. 52. 3. 1583. 51. 53. 1. 1757. 71. 42. 0. 1057. 89. 58. 2. 1341. 74. 52. 2. 841. 56. 42. 1. 1056. 61. 49. 0. 482. 63. 42. 1. 1151. 57. 51. 0. 890. 56. 49. 0. 100. 39. 40. 3. 1284. 99. 23. 0. 1100. 54. 52. 2. 537. 55. 33. 0. 881. 62. 29. 0. 1662. 76. 48. 0. 441. 22. 38. 1. 535. 90. 57. 2. 1623. 85. 50. 1. 1580. 82. 57. 2. 773. 53. 31. 1. 1722. 67. 39. 0. 792. 52. 23. 0. 1031. 73. 41. 3. 1957. 73. 34. 2. 479. 49. 35. 2. 1239. 78. 55. 3. 1154. 65. 45. 1. 1630. 97. 51. 3. 2609. 84. 32. 3. 1647. 67. 50. 3. 603. 69. 31. 2. 716. 51. 53. 3. 986. 79. 48. 2. 747. 60. 46. 4. 493. 50. 37. 0. 1581. 59. 52. 0. 358. 95. 31. 1. 552. 52. 55. 3. 1183. 49. 59. 3. 1200. 58. 24. 0. 2464. 119. 38. 3. 647. 63. 54. 2. 1135. 69. 54. 3. 498. 60. 31. 2. 553. 25. 49. 1. 1250. 59. 45. 3. 1007. 48. 42. 3. 742. 61. 51. 0. 1316. 59. 34. 3. 867. 42. 35. 2. 2327. 85. 42. 1. 914. 43. 33. 0. 1444. 51. 47. 2. 0. 84. 46. 4. 2211. 100. 52. 0. 201. 19. 26. 1. 806. 46. 50. 2. 867. 39. 41. 4. 1731. 62. 32. 1. 480. 31. 28. 0. 1060. 38. 56. 4. 586. 51. 36. 3. 853. 74. 34. 0. 1558. 101. 53. 3. 864. 74. 52. 2. 1496. 93. 43. 1. 1450. 74. 57. 4. 1654. 101. 50. 3. 1740. 68. 51. 1. 770. 48. 32. 0. 0. 53. 30. 1. 1093. 68. 49. 3. 2053. 103. 46. 0. 2474. 82. 55. 1. 1873. 96. 50. 2. 1012. 55. 27. 1. 1121. 86. 51. 0. 674. 56. 46. 2. 1080. 62. 36. 1. 1893. 92. 53. 2. 1374. 66. 50. 1. 734. 83. 47. 3. 1695. 87. 41. 1. 1552. 53. 50. 2. 290. 51. 24. 0. 841. 56. 51. 2. 330. 52. 35. 1. 1301. 69. 55. 2. 999. 51. 54. 3. 1467. 63. 38. 0. 764. 39. 28. 0. ; /* Applying OLS to vacation equation and retrieving OLS residuals. */ proc reg data = vacation; title 'OLS Estimation of Vacation Equation'; model miles = income age kids; output out=result r=resid; data vacation; merge vacation result; run; /* Producing residual plots by means of Proc Plot. Could also use SAS INSIGHT if one wanted to. */ proc plot data = vacation; title 'Residuals Plots for Vacation Equation'; plot resid*income; plot resid*age; plot resid*kids; run; /* Here creating White's Heteroskedasticity test by "brute" force. */ data vacation; set vacation; r2 = resid**2; income2 = income**2; age2 = age**2; kids2 = kids**2; income_age = income*age; income_kids = income*kids; age_kids = age*kids; /* Here is the White's Heteroskedasticity test without cross product terms. Look at Overall F-statistic in ANOVA table for this test equation. If it is insignificant we accept the null hypothesis of homoskedasticity and statistical inference can proceed by means of OLS. On the other hand, if the overall F-statistic is significant we accept the alternative hypothesis of heteroskedasticity and we must seek remedial action through either weighted least squares or at least correct the standard errors of the OLS estimates by means of White's Heteroskedasticity-Consistent standard errors and in so doing calculate White's Heteroskedasticity-Consistent t-statistics. */ proc reg data = vacation; title 'Whites Heteroskedasticity test without cross product terms'; model r2 = income age kids income2 age2 kids2; run; /* Here we construct White's Heterosskedasticity test with cross product terms. The null and alternative hypothesis are the same. */ proc reg data = vacation; title 'Whites Heteroskedasticity test with cross product terms'; model r2 = income age kids income2 age2 kids2 income_age income_kids age_kids; run; /* Now we are going to apply Weighted Least Squares to the Vacation equation. We will assume that the heteroskedasticity is proportional in income. Therefore the weight variable is (in SAS Notation) w = 1/income. NOTE: In EVIEWS the comparable weight is w = 1/(income^0.5). That is, for SAS the weight is that weight applied to the squared residuals while in EVIEWS the weight is applied to the residuals (equivalently the observations.) */ data vacation; set vacation; w = 1/income; proc reg data = vacation; title 'Weighted Least Squares using Proportional Heteroskedasticity'; model miles = income age kids; weight w; run; /* Now we calculate WLS by "brute" force. We directly transform the Vacation equation by multiplying all observations by (1/income^2) including the intercept. Then we apply OLS to the transformed equation while suppressing the intercept in the run. */ data vacation; set vacation; trans = 1/(income**0.5); milest = miles*trans; interceptt = 1*trans; incomet = income*trans; aget = age*trans; kidst = kids*trans; proc reg data = vacation; title 'OLS Applied to the Transformed Equation = WLS'; model milest = interceptt incomet aget kidst/noint; run; /* An Alternative Remedial Action: We construct the White's Heteroskedasity standard errors by using the "Cova" option in Proc REG. Unfortunately, these calculations have to be done by hand. */ proc reg data = vacation; title 'Obtaining the Whites Heteroskedasticity-Consistent Variance-Covariance of the OLS estimates'; model miles = income age kids/cova; run; /* Here we use Proc Model and the "white hccme = 1" to adjust our multiple regression results using White's Heteroskedasticity-Consistent Standard Errors and, in particular, use the Davidson-McKinnon Method 1 Modified Version of White's standard errors. Notice that White's Heteroskedasticity test with cross-product terms is produced as a by-product (reporting the chi-square form rather than the F-statistic form. */ title1 'Robust Regression Results with Whites Heteroskedasticity Consistent Standard Errors'; title2 'Using the Davidson-McKinnon Modified Version 1 (HCCME = 1)'; proc model data = vacation; parms const b1 b2 b3 b4; miles = const + b1*income + b2*age + b3*kids; fit miles / white hccme = 1; run;