Tomáš Karel LS 2012/2013
Doplňkový materiál ke cvičení z předmětu 4ST201. Na případné faktické chyby v této presentaci mě prosím upozorněte. Děkuji. Tyto slidy berte pouze jako doplňkový materiál – není v nich obsaženo zdaleka všechno, co byste měli umět. Dalším studijním materiálem je učebnice, cvičebnice a také poznámky z přednášek a cvičení!
Tomáš Karel - 4ST201
5.12.2013
2
cv.
Program cvičení
1.
Úvod, popisná statistika
2.
Popisná statistika
3.
Míry variability, pravděpodobnost
4.
Pravděpodobnost, náhodné veličiny a jejich charakteristiky
5.
Pravděpodobnostní rozdělení
6.
TEST, odhady parametrů
7.
Testování hypotéz
8.
Chí – kvadrát test dobré shody, kontingenční tabulky, ANOVA
9.
Regrese, ANOVA
10. Regrese, 11. korelace, časové řady (bazické a řetězové indexy) 12. TEST, Časové řady 13. Indexní analýza
a) b) c) d)
U automobilu byla měřena spotřeba benzínu v závislosti na rychlosti. Údaje jsou uvedeny v následující tabulce: Rychlost
40
50
60
70
80
90
100
110
Spotřeba
5,7
5,4
5,2
5,2
5,8
6,0
7,5
8,1
vyrovnejte data regresní parabolou charakterizujte těsnost závislosti ověřte význam kvadratického členu v modelu proveďte bodový odhad spotřeby při rychlosti 80 km/h
Y = bo + b1x + b2x2 = = 9,752 – 0,151x + 0,001x2
Pro těsnost závislosti charakterizovanou indexem determinace a upraveným indexem determinace platí, že modelem bylo vysvětleno 96, 83 % veškeré variability
Y b0 b1x b 2 x 2 9, 752 0,151x 0, 001x 2 9, 752 0,151 80 0, 001 802 4, 072
Tabulka obsahuje údaje o stáří, počtu najetých km a ceně 20 ojetých aut značky Octavia Combi. 1) zkonstruujte regresní model závislosti ceny auta na jeho stáří a počtu najetých km 2) posuďte jeho kvalitu 3) a použijte jej k odhadu ceny auta starého 6 let, které má najeto 60 tis.km
Hodnota testového kritéria F
Hladina významnosti
Na obrázku je uveden výstup z vícenásobné regresní analýzy v Excelu, odpovídající modelu vícenásobné lineární regrese se dvěma vysvětlujícími proměnnými. Model má popisovat závislost pracovní neschopnosti (%) na průměrném věku pracovníků a na podílu žen na celkovém počtu pracovníků (%). Co všechno je možné z výstupu vyčíst? Vypočtěte hodnotu koeficientu determinace a upraveného koeficientu determinace.
jeden z možných způsobů, jak vybrat vhodný počet parametrů a vhodné proměnné regresního modelu může pomoci rozhodnout, zda má do modelu smysl přidat ještě další parametr nebo nikoliv apod. (např.: má smysl přejít od lineárního ke kvadratickému modelu; od modelu se třemi vysvětlujícími proměnnými k modelu se čtyřmi apod.) Upravený index determinace je tedy možné použít např. i proto, abychom rozhodli, zda je lepším modelem regresní přímka nebo regresní parabola ! Pro tyto účely nelze použít „klasický“ index determinace.
Rozhodněte, zda-li vhodnějším modelem pro popis závislosti proměnné y na proměnné x je přímka nebo parabola
předmětem je zkoumání vzájemných lineárních vztahů mezi dvěma nebo více číselnými proměnnými chceme-li posoudit sílu závislosti mezi dvěma proměnnými, můžeme použít korelační koeficient (odmocnina z koeficientu determinace)
rxy= 1 přímá funkční závislost rxy= -1 nepřímá funkční závislost rxy= 0 lineární nezávislost
Korelační koeficient podává informaci o intenzitě lineární závislosti a jejím směru (přímá, nepřímá) (horní řádek) nezachycuje však hodnotu sklonu této závislost, neboli nezachycuje, jakou změnu střední hodnoty jedné proměnné očekáváme, pokud se druhá proměnná změní „o jednotku“ (prostřední řádek) a ani nezachycuje nelineární závislost mezi proměnnými (dolní řádek)
k výběrovému korelačnímu koeficientu rxy existuje jeho „teoretický“ protějšek: tj. korelační koeficient ρxy základního souboru test hypotézy o nulové hodnotě korelačního koeficientu základního souboru je vzhledem k významu korelačního koeficientu testem o tom, zda mezi dvěma proměnnými existuje statisticky významná lineární závislost. Ekvivalentní test již umíme provést i nástroji jednoduché lineární regrese (např. dílcím t-testem o nulové hodnote regresního parametru β1 nebo testem o modelu)
• Korelační koeficient nemusí mít u všech „možných dat, která chceme analyzovat“ vždy dobrý smysl počítat a interpretovat jeho velikost (záleží totiž na tom, z jakého rozdělení provádíme výběr – korelační koeficient je šitý na míru tzv. dvourozměrnému normálnímu rozdělení). • V případe, že jsme jednu z proměnných pevně volili (např. v nějakém experimentu), je vhodnější použít regresní analýzu. • Navíc regresní analýza nám podává i informaci o hodnotě sklonu lineární závislosti, neboli informaci o tom, jakou změnu závisle proměnné odhadujeme, pokud se nezávisle proměnná změní o „jednotku“.
Máme k dispozici měření hmotnosti dětí a počtu jejich bodů za diktát. Student
1
2
3
4
5
6
7
8
9
10
Hmotnost
20
24
31
35
39
43
45
48
52
53
Počet bodů
34
36
38
42
45
48
51
55
58
62
a)
b)
c)
změřte těsnost lineární závislosti mezi počtem bodů za diktát a hmotností dětí otestujte na 5% hladině významnosti, zde je tato závislost statisticky významná uvažujte nad tím, zda-li můžeme určit směr závislosti a použít případně regresní funkci
a)
b)
c)
rxy = 0,975 t = 12,41 proti t0,975[8] = 2,306 spadá do kritického oboru, tudíž zamítáme nulovou hypotézu, která tvrdí, že korelační koeficient je roven nule prokázali jsme, že je statisticky významně odlišný od nuly je logicky nesmyslné, aby počet bodů z diktátu závisel na hmotnosti. Jedná se ve skutečnosti o tzv. falešnou korelaci, kdy obě proměnné závisí na proměnné třetí, zde neuvažované, a tou je věk testovaných dětí. Ne každá korelace je tudíž důkazem závislosti (!) a už vůbec nic neříká o směru této závislosti
U 15 chlapců jsme spočítali počet udělaných kliků a počet shybů. Spočítejte, jestli existuje vzájemná lineární závislost mezi počtem shybů a počtem kliků a vyčíslete intenzitu této závislosti.
MS Excel -> Data -> Analýza dat -> Korelace (popř. kovariance)
kovarianční matice = na diagonále rozptyly, mimo diagonálu kovariance (obojí výběrové)
korelační matice = na diagonále jedničky, mimo diagonálu korelační koeficient
obě matice jsou vždy symetrické
30 minut (na konci hodiny) 3-4 početní příklady (žádná teorie) možno používat: kalkulačku, Excel, vzorce, tabulky, absence na testu musí být předem omluvena na test je 1 pokus (žádné opravy)
Rozsah 6.-11. cvičení Normální rozdělení bodový a intervalový odhad testování hypotéz ◦ jednovýběrový test (test o jednom parametru) ◦ dvouvýběrový test (rovnost dvou parametrů) ◦ chí-kvadrát test dobré shody kontingenční tabulky – konstrukce, test nezávislosti, kontingenční koeficienty analýza rozptylu regresní analýza – odhad parametrů MNČ, součty čtverců, index determinace, upravený index determinace, regresní přímka, parabola, vícenásobná regrese, celkový F-test, jednotlivé t-testy korelační analýza, test o korelačním koeficientu