### 11 HODNOCENI KONTINGENCNICH TABULEK
## 11.1 Pearsonuv chi-kvadrat test
data <- read.delim('TO-DO', sep = ';', dec = '.', header = T, row.names = 1)

# overeni podminky dobre aproximace
round(chisq.test(data, correct = F)$expected, 1) # tabulka ocekavanych (teoretickych) cetnosti 

# Pearsonuv chi-kvadrat test
chisq.test(data, correct = F)
alpha <- 0.01
r <- 3
s <- 4
q <- qchisq(1 - alpha, (r - 1) * (s - 1))
(tab <- data.frame(q))

# Crameruv koeficient
V <- lsr::cramersV(data)
(tab <- data.frame(Crameruv.koeficient = V))



## 11.2 Test podilem verohodnosti
data <- data.frame(Mech = c(16, 50 - 16), Rajbanshi = c(17, 87 - 17), 
                   row.names = c('stredni', 'ostatni')) # vytvoreni datove tabulky
alpha <- 'TO-DO'

# podminka dobre aproximace
'TO-DO'

# vypocet logaritmu podilu sanci
a <- 16; b <- 17; c <- 34; d <- 70
OR <- (a * d) / (b * c)
lnOR <- log(OR)
(tab <- data.frame(OR, lnOR))

# test podilem sanci
source('TO-DO')
odds.ratio.test(data, conf.level = 1 - alpha)
alpha <- 'TO-DO'
q1 <- qnorm(alpha / 2)
q2 <- qnorm(1 - alpha / 2)
(tab <- data.frame(q1, q2))



## 11.3 Fisheruv faktorialovy test
fisher.test(data, alternative = 'TO-DO', conf.level = 1 - alpha)

