Neparametricke testy (motto: „Hypotézy jsou lešením, které se staví před budovu a pak se strhává, je-li budova postavena. Jsou nutné pro vědeckou práci, avšak skutečný vědec nepokládá hypotézy za předmětnou pravdu, podobně jako nelze pokládat lešení za stavbu samu.“ J. W. Goethe)
1. Příklad V předloňském semestru se zúčastnilo zkoušky z předmětu 4ST201 – Statistika 1491 studentů, z nichž 7,5 % dostalo jedničku, 24,5 % dvojku, 37 % trojku a 31 % čtyřku nebo bylo omluveno. Z mých cvičení dostalo jedničku 6 studentů, dvojku 8 studentů, trojku 16 studentů a čtyřku nebo omluveno 10 studentů. Otestujte na 5% hladině významnosti tvrzení, že rozložení známek studentů z mých cvičení odpovídá celoškolskému rozložení známek.
χ20,95[3] = 7,81 W0,05 = {G ≥ 7,81} i 1 2 3 4
ni 6 8 16 10 40
Pii 7,50% 24,50% 37% 31%
nPii 3 9,8 14,8 12,4
Rozdil 3 0,330612 0,097297 0,464516 3,892426
G = 3,89 Nezamítáme H0, nezamítli jsme tvrzení, že rozložení známek studentů z mých cvičení odpovídá celoškolskému rozložení známek.
2. Příklad Byly sledovány rodinné stavy nevěst a ženichů při uzavírání sňatků a byla vytvořena následující tabulka četností. Stav
Svobodný
Rozvedený
Vdovec
Svobodná
37
10
6
Rozvedená
8
12
8
Vdova
5
8
6
Zjistěte na 1% hladině významnosti, zda existuje statistická závislost mezi rodinným stavem ženicha a nevěsty. Vypočítejte míru těsnosti této závislosti.
Jedná se o obdobu Chí-kvadrát testu dobré shody, kde musíme porovnat tuto četnostní tabulku s hypotetickou četnostní tabulkou, jež představuje rozvrstvení těchto dvojic stavů za předpokladu, že jsou na sobě stav nevěsty a ženicha nezávislé. Stav Svobodný Rozvedený Vdovec Celkem Svobodná 37 10 6 53 Rozvedená 8 12 8 28 Vdova 5 8 6 19 Celkem 50 30 20 100 Předchozí tabulka doplněná o součty. Nyní vytvoříme tabulku nezávislých četností. V každém políčku bude počet odpovídající násobku součtu příslušného řádku a sloupce dělený celkovým počtem sňatků. Pro dvojici SvobodnýXSvobodná tedy 53*50/100 = 26,5. Toto číslo odpovídá počtu sňatků svobodných, jestliže by tento počet nezávisel na jejich stavu. Nyní tedy: Stav Svobodný Rozvedený Svobodná 26,5 15,9 Rozvedená 14 8,4 Vdova 9,5 5,7 Celkem 50 30 Součtové řádky a sloupce se navzájem musí rovnat.
Vdovec 10,6 5,6 3,8 20
Celkem 53 28 19 100
Následuje výpočet samotné statistiky G, která je počítána stejně jako v předchozím příkladě, tedy čtverec rozdílu mezi skutečnou a teoretickou četností dělený teoretickou četností. Tyto jednotlivé mezivýpočty se sečtou a tento součet je hledanou hodnotou statistiky G. Příklad pro svobodné: (37 – 26,5)2/26,5 Stav Svobodný Rozvedený Svobodná 4,16 2,19 Rozvedená 2,57 1,54 Vdova 2,13 0,93 Celkem
Vdovec Celkem 2,00 1,03 1,27 17,82
G = 17,82 χ20,99[4] = 13,3; r = 3 (počet řádků), s = 3 (počet sloupců) W0,01 = [G ≥ 13,3] Spadá do kritického oboru, zamítáme nulovou hypotézu ve prospěch hypotézy alternativní, že existuje vztah mezi rodinným stavem nevěsty a ženicha. C=√ V=√
√ √
3. Příklad Následující tabulka udává region pijáka piva a preferenci pití piva točeného nebo z lahve. Posuďte na jejím základě, zdali existují rozdíly v preferenci pití piva (z plechovky nebo točeného) v různých částech země. Hladina významnosti je 10%. Vypočítejte míru těsnosti této závislosti.
Sever
Jih
Západ
Plechovka
300
190
60
Točené
200
110
40
χ20,90[2] = 4,61; r = 2 (počet řádků), s = 3 (počet sloupců) W0,1 = [G ≥ 4,61]
Sever Plechovka 300 Točené 200 Součty 500
Jih 190 110 300
Západ 60 40 100
Součty 550 350 900
Sever Plechovka 305,55556 Točené 194,44444 Součty 500
Jih 183,33333 116,66667 300
Západ 61,111111 38,888889 100
Součty 550 350 900
Sever Plechovka 0,10101 Točené 0,15873
Jih 0,242424 0,380952
Západ 0,020202 0,031746 G=
0,935065
Nespadá do kritického oboru, nezamítáme nulovou hypotézu ve prospěch hypotézy alternativní, že existuje vztah mezi regionem a preferencí způsobu pití piva. C=√
√
V=√
√
4. Příklad Ve 12 supermarketech byl testován vliv způsobu vystavení zboží na jeho odbyt. Zboží bylo umístěno 2 různými způsoby (A a B), vždy v 6 supermarketech stejně a sledoval se počet prodaných kusů za
určitou dobu. Rozhodněte pomocí testu, zda způsob umístění zboží statisticky významně ovlivňuje počet prodaných kusů na hladině významnosti 0,01. Zhodnoťte kvalitu vytvořeného modelu.
A
42
46
37
48
53
92
B
104
79
122
115
71
89
H0: μ1 = μ2 H1: non H0 F0,99 [1; 10] = 10,044 W0,01 = {F ≥ 10,044} Vnitroskupinový součet čtverců
4033, 33
Čtvercová odchylka od průměru 1. skupina skupiny
2. skupina
Čtvercová odchylka od průměru skupiny
42
121
104
53,77778
46
49
79
312,1111
37
256
122
641,7778
48
25
115
336,1111
53
0
71
658,7778
92
1521
89
58,77778
celkem
1972
průměr 53
2061,333 96,66667
Meziskupinový součet čverců: Sy,m = 5 720,33 Čtvercová odchylka Průměry od průměru A
53
2860,167
B
96,66667 2860,167
Celkem
74,83333 5720,333
4033,333
Celkový součet čtverců = 9753,66
Spadá do kritického oboru, tedy zamítáme nulovou hypotézu, že jsou si střední hodnoty v jednotlivých skupinách rovny a tudíž způsob umístění neovlivňuje prodej, ve prospěch alternativní, že způsob prodeje ovlivňuje prodejnost. Síla závislosti je dána poměrem determinace P2 = Sy,m/Sy = 5 720,33/9 753,66 = 0,586480; znamená to, že model vysvětluje 58,65% variability sledované proměnné.
V SAS: Znovu je potřeba vytvořit správně datový soubor – v jednom sloupci zapíšeme všechny způsoby prodeje pro všechny napočítané hodnoty (tedy šestkrát A, šestkrát B). Ke každému ze způsobů do vedlejšího sloupce zapíšeme právě jedno množství prodaných výrobků. Nyní pokračujeme přes záložky Analyze – ANOVA – One-Way ANOVA. V Task Roles je Dependent Value (závislá proměnná) sloupec s množstvím prodaných kusů a Independent Value sloupec se způsobem prodeje. V zásadě nic více nepotřebujeme, můžeme si nechat například vyjet nějaký z grafů znázorňující rozdílné průměry ve skupinách. Ve výsledcích vidíme hodnoty Sum of Squares – ty značí součty čtverců meziskupinový (Model) – 5 720,33 a vnitroskupinový (Error) – 4033,33. Celkem (Corrected Total) = 9753,66. DF značí stupně volnosti; F Value značí hodnotu testového kritéria F; Pr > F značí hladinu významnosti, na které je model označen jako významný ve smyslu zamítnutí nulové hypotézy. Na 5% hladině hypotézu zamítáme. R-Square je poměr determinace, množství variability vysvětlené modelem.