clear all; close all; clc; %=============================================== %Example 12.1. Heteroscedastic Regression %=============================================== %Initial Data Setup. Used for all examples Data_orig = ... [0 1 38 4.52 124.98 1 0 0 1 33 2.42 9.85 0 0 0 1 34 4.50 15.00 1 0 0 1 31 2.54 137.87 0 0 0 1 32 9.79 546.50 1 0 0 1 23 2.50 92.00 0 0 0 1 28 3.96 40.83 0 0 0 1 29 2.37 150.79 1 0 0 1 37 3.80 777.82 1 0 0 1 28 3.20 52.58 0 0 0 1 31 3.95 256.66 1 0 0 0 42 1.98 0.00 1 0 0 0 30 1.73 0.00 1 0 0 1 29 2.45 78.87 1 0 0 1 35 1.91 42.62 1 0 0 1 41 3.20 335.43 1 0 0 1 40 4.00 248.72 1 0 7 0 30 3.00 0.00 1 0 0 1 40 10.00 548.03 1 1 3 0 46 3.40 0.00 0 0 0 1 35 2.35 43.34 1 0 1 0 25 1.88 0.00 0 0 0 1 34 2.00 218.52 1 0 1 1 36 4.00 170.64 0 0 0 1 43 5.14 37.58 1 0 0 1 30 4.51 502.20 0 0 0 0 22 3.84 0.00 0 1 0 1 22 1.50 73.18 0 0 0 0 34 2.50 0.00 1 0 0 1 40 5.50 1532.77 1 0 0 1 22 2.03 42.69 0 0 1 1 29 3.20 417.83 0 0 1 0 25 3.15 0.00 1 0 0 1 21 2.47 552.72 1 0 0 1 24 3.00 222.54 0 0 0 1 43 3.54 541.30 1 0 0 0 43 2.28 0.00 0 0 0 1 37 5.70 568.77 1 0 0 1 27 3.50 344.47 0 0 0 1 28 4.60 405.35 1 0 0 1 26 3.00 310.94 1 0 0 1 23 2.59 53.65 0 0 0 1 30 1.51 63.92 0 0 0 1 30 1.85 165.85 0 0 0 1 38 2.60 9.58 0 0 0 0 28 1.80 0.00 0 1 0 1 36 2.00 319.49 0 0 0 0 38 3.26 0.00 0 0 0 1 26 2.35 83.08 0 0 0 1 28 7.00 644.83 1 0 0 0 50 3.60 0.00 0 0 0 1 24 2.00 93.20 0 0 0 1 21 1.70 105.04 0 0 0 1 24 2.80 34.13 0 0 0 1 26 2.40 41.19 0 0 1 1 33 3.00 169.89 0 0 0 1 34 4.80 1898.03 0 0 0 1 33 3.18 810.39 0 0 0 0 45 1.80 0.00 0 0 0 1 21 1.50 32.78 0 0 2 1 25 3.00 95.80 0 0 0 1 27 2.28 27.78 0 0 0 1 26 2.80 215.07 0 0 0 1 22 2.70 79.51 0 0 3 0 27 4.90 0.00 1 0 0 0 26 2.50 0.00 0 1 0 1 41 6.00 306.03 0 1 0 1 42 3.90 104.54 0 0 0 0 22 5.10 0.00 0 0 0 1 25 3.07 642.47 0 0 0 1 31 2.46 308.05 1 0 0 1 27 2.00 186.35 0 0 0 1 33 3.25 56.15 0 0 0 1 37 2.72 129.37 0 0 0 1 27 2.20 93.11 0 0 1 0 24 4.10 0.00 0 0 0 1 24 3.75 292.66 0 0 0 1 25 2.88 98.46 0 0 0 1 36 3.05 258.55 0 0 0 1 33 2.55 101.68 0 0 0 0 33 4.00 0.00 0 0 1 1 55 2.64 65.25 1 0 0 1 20 1.65 108.61 0 0 0 1 29 2.40 49.56 0 0 3 0 40 3.71 0.00 0 0 0 1 41 7.24 235.57 1 0 0 0 41 4.39 0.00 1 0 0 0 35 3.30 0.00 1 0 0 0 24 2.30 0.00 0 0 1 0 54 4.18 0.00 0 0 2 0 34 2.49 0.00 0 0 0 0 45 2.81 0.00 1 0 0 1 43 2.40 68.38 0 0 4 0 35 1.50 0.00 0 0 2 0 36 8.40 0.00 0 0 0 1 22 1.56 0.00 0 0 1 1 33 6.00 474.15 1 0 1 1 25 3.60 234.05 0 0 0 1 26 5.00 451.20 1 0 0 1 46 5.50 251.52 1 0]; Names = strvcat('Derogs','Card','Age','Income','Exp','OwnRent','SelfEmpl'); %vypusteni pozorovani s nulovymi vydaji index = find(Data_orig(:,5)); Data = Data_orig(index,:); [Nobs,Nvar]=size(Data); Derogs = Data(:,1); Card = Data(:,2); Age = Data(:,3); Income = Data(:,4); Exp = Data(:,5); OwnRent = Data(:,6); SelfEmpl = Data(:,7); Incomesq = Income.^2; Iota = ones(Nobs,1); X = [Iota Age OwnRent Income Incomesq]; y = Exp; vnames = strvcat('Exp','Iota','Age','OwnRent','Income','Incomesq'); result_ols = ols(y,X); prt_reg(result_ols,vnames); %White's test testWhite = white_test(result_ols,X) %Goldfeld-Quandt test testGQ = GQ_test(y,X,4,36,36) %index = 4 ... tridime podle Income %Breusch-Pagan test Z = [Iota Income Incomesq]; testBP = BP_test(result_ols,Z) %Breusch-Pagan test (Koenker and Basset variant) Z = [Iota Income Incomesq]; testBPKB = BPKB_test(result_ols,Z) %Glesjer test Z = [Iota Income Incomesq]; testGlesjer = glejser_test(result_ols,Z)