% Calculate f-tests for least squares quadratic fit % for Testmreg.m example. Modify this code for other input. % References: Middleton, p. 58-72; % Davis (2002), p. 191-214. % FtestTestmreg.m % Data are: % t = [0 .3 .8 1.1 1.6 2.3]'; % y = [0.5 0.82 1.14 1.25 1.35 1.40]'; % use output table from Testmreg.m % TEST FOR GOODNESS OF FIT: msr2mse = 0.3035/0.0016 % MSR2/MSE, calculate f-value % for the significance of the quadratic fit fstat2 = finv(0.95,2,3) % f-test value from tables % for testing the significance of the quadratic fit; % if MSR2/MSE (the calculated f-value) is greater than % the f-test value from tables (fstat2), then the % quadratic fit is statistically significant. % Use help finv to view description of the input to finv. p2 = fcdf(msr2mse,2,3); p2 = 1 - p2 % Calculates the probability of % a value as high as msr2mse resulting from a set of % random imputs. % ------------------------------------------------------ % TEST FOR IMPROVEMENT IN THE FIT BY ADDING THE EXTRA TERM msr2m1mse = 0.1025/0.0016 % MSR2-1/MSE, calculate f-value % for the significance of adding the quadratic fit (the % improvement of the fit compared to the straightline fit). fstat2m1 = finv(0.95,1,3) % f-test value from tables % for testing the significance improvement in the fit % by ADDING the quadratic term; % if MSR2m1/MSE (the calculated f-value) is greater than % the f-test value from tables (fstat2m1), then the % quadratic fit is a statistically significant improvement % over the straight line fit. % The calculated and test statistics (from tables; finv % output) are printed for this example. p2m1 = fcdf(msr2m1mse,1,3); p2m1 = 1 - p2m1 % Calculates the probability of % a value as high as msr2m1mse resulting from a set of % random imputs.