1 / 25

chisquare-GoF

Chi-square goodness of fit

Terry66
Download Presentation

chisquare-GoF

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 9/22/23 The Chi-Square Distribution Goodness of Fit 1 Chi-Square Distribution 1 ! !!!∗!!!! ! ! = ∗ ! 2!/!Γ! 2 2 1

  2. 9/22/23 Chi-Square Distribution * R code * Produces graph to the right 3 Chi-Square Table 4 2

  3. 9/22/23 Chi-square: Goodness of fit test • We can test to see if our observed frequencies “fit” our expectations • This is the c2 Goodness-of-Fit test • This converts the difference between the frequencies we observe and the frequencies we expect to a distribution with known probabilities 2 ( ) O−E E ∑ χ2= ;df = #categories−1 5 P-value for χ2 • Upper tail (only) • P-value = pchisq(χ2 calc,df,lower.tail=FALSE); 6 3

  4. 9/22/23 Critical Value for χ2 • Upper tail (only) • χ2crit = qchisq(1- α,df); 7 P-Value Rules for χ2 • If the P-value is greater than α, you will fail to reject H0 • If the P-value is less than α, you will reject H0 8 4

  5. 9/22/23 Critical Value Rules for χ2 • Upper tail (only) • If χ2calc is greater than χ2crit , you will reject H0 • If χ2calc is less than χ2crit , you will fail to reject H0 9 Goodness-of-Fit: An Example • It has been reported that • 10.3% of U.S. farmer do not own a tractor, • 34.2% owning 1 tractor, • 38.4% owning 2 tractors, and • 17.1% owning 3 or more tractors. 10 5

  6. 9/22/23 Goodness-of-Fit • The data for a random sample of 100 farmers in Florida are summarized below. Can we reject the possibility that the tractor-ownership distribution in this state differs from that of the nation as a whole? (α=0.05) # Tractors Owned 0 1 2 3 or more # Farmers 20 35 23 22 11 Goodness-of-Fit H0: p0 = 0.103, p1 = 0.342, p2 = 0.384, p3+ = 0.171 tractor-ownership distribution in this state is the same as it is in the nation as a whole. HA: At least one of the proportions does not equal the stated value. Tractor- ownership distribution in this state is not the same as it is in the nation as a whole. 12 6

  7. 9/22/23 Goodness-of-Fit # Tractors Owned Observed Expected 0 20 10.3 1 35 34.2 2 23 38.4 3 or more 22 17.1 13 Goodness-of-Fit (O-E)2 (O-E)2/E # Tractors Owned 0 Observed Expected (O-E) 20 10.3 9.7 94.09 9.13 1 35 34.2 0.8 0.64 0.02 2 23 38.4 -15.4 237.16 6.18 3 or more 22 17.1 4.9 24.01 1.40 Σ = 16.73 d.f. = 3 14 7

  8. 9/22/23 P-value for χ2 • Upper tail (only) • P-value = pchisq(χ2 calc,df,lower.tail=FALSE); 15 Critical Value for χ2 • Upper tail (only) • χ2crit = qchisq(1- α,df); 16 8

  9. 9/22/23 P-Value Rules for χ2 • If the P-value is greater than α, you will fail to reject H0 • If the P-value is less than α, you will reject H0 17 Critical Value Rules for χ2 • Upper tail (only) • If χ2calc is greater than χ2crit , you will reject H0 • If χ2calc is less than χ2crit , you will fail to reject H0 18 9

  10. 9/22/23 P- value pchisq(16.73,3,lower.tail=FALSE) = 0.0008030961 19 critical value qchisq(.95,3) = 7.814728 20 10

  11. 9/22/23 Goodness-of-Fit a = 0.05 df = k – 1 = 4 – 1 = 3 II. Test Statistic: c2 = 16.73 III. Conclusion: Since the test statistic of c2 = 16.73 is greater than the critical value of c2 = 7.815, we reject H0 with at least 95% confidence. Implications: There is enough evidence to show that tractor ownership in this state differs from that in the nation as a whole. 21 Goodness-of-Fit: An Example •On a large dairy farm, the manager used two sources of semen for artificial insemination: conventional and sexed. • Of the 521 calves resulting from conventional semen, 47% were female. • Of the 514 calves resulting from sexed semen, 84% were female. 22 11

  12. 9/22/23 Goodness-of-Fit: An Example •We want to know if: 1. Does sex of calf from the conventional semen agree with biological expectations (i.e. 1:1 ratio)? 2. Does sex of calf from the sexed semen agree with biological expectations (i.e. 1:1 ratio)? 3. Using the conventional semen as a control (expectation), does sex of calf agree with internal control? • α=0.05 23 Goodness-of-Fit: Conventional Semen H0: pf = 0.50, pm = 0.50 sex ratio agrees with biological expectations. Ha: sex ratio does NOT agree with biological expectations. 24 12

  13. 9/22/23 Goodness-of-Fit: Conventional Semen (O-E)2 (O-E)2/E Sex of Calf Observed Expected (O-E) Heifer 521×0.47 = 244.87 521×0.53 = 276.13 521×0.50 = 260.5 521×0.50 = 260.5 -15.63 244.30 0.94 Bull 15.63 244.30 0.94 χ2 = 1.88 d.f. = 1 25 P-value for χ2 • Upper tail (only) • P-value = pchisq(χ2calc,df,lower.tail=FALSE); 26 13

  14. 9/22/23 Critical Value for χ2 • Upper tail (only) • χ2crit = qchisq(1- α,df); 27 P-Value Rules for χ2 • If the P-value is greater than α, you will fail to reject H0 • If the P-value is less than α, you will reject H0 28 14

  15. 9/22/23 Critical Value Rules for χ2 • Upper tail (only) • If χ2calc is greater than χ2crit , you will reject H0 • If χ2calc is less than χ2crit , you will fail to reject H0 29 P- value pchisq(1.88,1,lower.tail=FALSE) = 0.1703341 30 15

  16. 9/22/23 critical value qchisq(.95,1) = 3.841459 31 Goodness-of-Fit: Conventional Semen • Conclusion: • Because the p-value of 0.1703341 is greater than 0.05 (α), we fail to reject the null hypothesis. • Because the test statistic of 1.88 is less than the critical value of 3.841459, we fail to reject the null hypothesis. • Implications: • for conventional semen, sex ratio agrees with biological expectations. 32 16

  17. 9/22/23 Goodness-of-Fit: Sexed Semen H0: pf = 0.50, pm = 0.50 sex ratio agrees with biological expectations. Ha: sex ratio does NOT agree with biological expectations. 33 Goodness-of-Fit: Sexed Semen (O-E)2 (O-E)2/E Sex of Calf Observed Expected (O-E) Heifer 514×0.84 = 431.8 514×0.16 = 82.2 514×0.50 = 257.0 514×0.50 = 257.0 174.8 30,555 118.9 Bull -174.8 30,555 118.9 χ2 = 237.8 d.f. = 1 34 17

  18. 9/22/23 P-value for χ2 • Upper tail (only) • P-value = pchisq(χ2calc,df,lower.tail=FALSE); 35 Critical Value for χ2 • Upper tail (only) • χ2crit = qchisq(1- α,df); 36 18

  19. 9/22/23 P-Value Rules for χ2 • If the P-value is greater than α, you will fail to reject H0 • If the P-value is less than α, you will reject H0 37 Critical Value Rules for χ2 • Upper tail (only) • If χ2calc is greater than χ2crit , you will reject H0 • If χ2calc is less than χ2crit , you will fail to reject H0 38 19

  20. 9/22/23 P- value pchisq(237.8,1,lower.tail=FALSE) = 1.186896e-53 39 critical value qchisq(.95,1) = 3.841459 40 20

  21. 9/22/23 Goodness-of-Fit: Conventional Semen • Conclusion: • Because the p-value of 1.186896e-53 is less than 0.05 (α), we reject the null hypothesis. • Because the test statistic of 237.8 is greater than the critical value of 3.841459, we reject the null hypothesis. • Implications: • for sexed semen, sex ratio does NOT agree with biological expectations; predominately heifer calves. 41 Goodness-of-Fit: Sexed Semen, internal control H0: pf = 0.47, pm = 0.53 sex ratio agrees with internal control (conventional semen) expectations. Ha: sex ratio does NOT agree with internal control (conventional semen) expectations. 42 21

  22. 9/22/23 Goodness-of-Fit: Sexed Semen, internal control (O-E)2 (O-E)2/E Sex of Calf Observed Expected (O-E) Heifer 514×0.84 = 431.8 514×0.16 = 82.2 514×0.47 = 241.6 514×0.53 = 272.4 190.2 36,176 149.7 Bull -190.2 36,176 132.8 χ2 = 282.5 d.f. = 1 43 P-value for χ2 • Upper tail (only) • P-value = pchisq(χ2calc,df,lower.tail=FALSE); 44 22

  23. 9/22/23 Critical Value for χ2 • Upper tail (only) • χ2crit = qchisq(1- α,df); 45 P-Value Rules for χ2 • If the P-value is greater than α, you will fail to reject H0 • If the P-value is less than α, you will reject H0 46 23

  24. 9/22/23 Critical Value Rules for χ2 • Upper tail (only) • If χ2calc is greater than χ2crit , you will reject H0 • If χ2calc is less than χ2crit , you will fail to reject H0 47 P- value pchisq(282.5,1,lower.tail=FALSE) = 2.14196e-63 48 24

  25. 9/22/23 critical value qchisq(.95,1) = 3.841459 49 25

More Related