### BODOVE A INTERVALOVE ODHADY
# 6.1
data <- read.delim('TO-DO', sep = ';', dec = '.')
data.M <- 'TO-DO' # vyber muzi populace Tigara, promenne femur.LR, acetab.HR
'TO-DO' # odstraneni NA hodnot, prohlednuti dat
n <- 'TO-DO' # pocet objektu

# delka stehenni kosti
m.LR  <- 'TO-DO' # prumer
s2.LR <- 'TO-DO' # rozptyl
s.LR <- 'TO-DO' # smerodatna odchylka
v.LR <- 'TO-DO' # koeficient variace

'TO-DO' # sestaveni tabulky zaokrouhlene na 4 des. mista


# 6.2
m.HR  <- 'TO-DO' # prumer promenne acetab.HR
s2.HR <- 'TO-DO' # rozptyl
s.HR <- 'TO-DO' # sm. odchylka  

r12 <- cor(femur.LR, acetab.HR)
s12 <- cov(femur.LR, acetab.HR) # nebo s12 <- r12 * s.HR * s.LR

# lze i vzorcem : s12 <- 1 / (n - 1) * sum((femur.LR - m.LR) * (acetab.HR - m.HR))
# lze i vzorcem: r12 <- s12 / (sqrt(s2.LR) * sqrt(s2.HR))

'TO-DO' # sestaveni vektoru mu a matice Sigma


# 6.3
data <- read.delim('TO-DO', sep = ';', dec = '.')
ib.Tg <- data[data$pop == 'tsg' & data$sex == 'm', 'iblade.LL']
ib.Yo <- 'TO-DO'
ib.Ya <- 'TO-DO'
ib.Tg <- 'TO-DO' # odstraneni NA hodnot
ib.Yo <- 'TO-DO'
ib.Ya <- 'TO-DO'

n.Tg <- 'TO-DO' # pocet objektu
n.Yo <- 'TO-DO'
n.Ya <- 'TO-DO'

s2.Tg <- 'TO-DO' # vyberovy rozptyl
s2.Yo <- 'TO-DO'
s2.Ya <- 'TO-DO'

# vazeny prumer vyber. rozptylu pro 2 populace
sh.YoYa <- ((n.Yo - 1) * s2.Yo + (n.Ya - 1) * s2.Ya)/ (n.Yo + n.Ya - 2) 

# vazeny prumer vyber. rozptylu pro 3 populace
sh.TgYoYa <- ((n.Tg - 1) * s2.Tg + (n.Yo - 1) * s2.Yo + (n.Ya - 1) * s2.Ya) / 
  (n.Tg + n.Yo + n.Ya - 3) 

'TO-DO' # sestaveni tabulky vysledku


# 6.4
alpha <- 'TO-DO'

# oboustranny IS pro str. hodnotu
dh.mu <- (m.LR - s.LR / sqrt(n) * qt(1 - alpha / 2, n - 1))
hh.mu <- (m.LR - s.LR / sqrt(n) * qt(alpha / 2, n - 1))

# levostranny IS pro rozptyl
alpha <- 'TO-DO'
D.sig2 <- (n - 1) * s.LR ^ 2 / qchisq(1 - alpha, n - 1)

# pravostranny IS pro sm. odchylku
alpha <- 'TO-DO'
H.sig2 <- (n - 1) * s.LR ^ 2 / qchisq(alpha, n - 1)
H.sig <- sqrt(H.sig2)

tab <- data.frame(dh.mu, hh.mu, D.sig2, H.sig)
'TO-DO' # zaokrouhleni tabulky na 2 desetinna mista


# 6.5
data <- read.delim('TO-DO')
'TO-DO' # odstraneni NA hodnot

sex <- 'TO-DO' # vyber promenne sex.C
N <- 'TO-DO' # pocet objektu
p <- sum(sex == 'f') / N # bodovy odhad parametru p

alpha <- 'TO-DO'
# intervalovy odhad parametru p
dh.p <- p - qnorm(1 - alpha / 2) * sqrt(p * (1 - p) / N)
hh.p <- p - qnorm(alpha / 2) * sqrt(p * (1 - p) / N)

'TO-DO' # sestaveni tabulky a zaokrouhleni

