#========================================================== # P R I K L A D 6.1 #========================================================== data <- read.delim('01-one-sample-mean-skull-mf.txt') data <- na.omit(data) skull.BM <- data[data$sex == 'm', 'skull.B'] length(skull.BM) # H0: Data pochazi z normalniho rozdeleni. # H1: Data nepochazi z normalniho rozdeleni. # hladina vyznamnosti alpha = 0.05 # (neni-li uvedena hladina vyznamnosti v zadani, volime ji sami. Nejcastejsi volbou byva alpha = 0.05) library(nortest) lillie.test(skull.BM) # p-hodnota = 0.07662 # Protoze p-hodnota = 0.07622 > alpha = 0.05, H0 nezamitame na hladine vyznamnosti alpha = 0.05. # Data pochazi z normalniho rozdeleni. #========================================================== # P R I K L A D 6.2 #========================================================== # Histogram b <- seq(123, 150, by = 3) centr <- seq(124.5, 148.5, by = 3) par(mar = c(4, 5, 1, 1)) hist(skull.BM, col = 'dodgerblue', prob = T, breaks = b, density = 30, axes = F, xlab = 'nejvetsi sirka mozkovny (mm) - muzi', ylab = 'relativni cetnosti', main = '', ylim = c(0, 0.085)) box(bty = 'o') axis(side = 1, centr) axis(side = 2, las = 1) x <- seq(min(skull.BM) - 10, max(skull.BM) + 10, length = 512) y <- dnorm(x, mean = mean(skull.BM), sd = sd(skull.BM)) lines(x, y, col = 'dodgerblue3', lwd = 2) # Q-Q graf qqnorm(skull.BM, main = '', las = 1, xlab = 'teoreticky kvantil', ylab = 'vyberovy kvantil', pch = 21, col = 'dodgerblue3') qqline(skull.BM, col = 'dodgerblue4', lwd = 2) #========================================================== # P R I K L A D 7.1 #========================================================== # H0: mu = 136.402 # H1: mu != 136.402 (oboustranna alternativa) m <- mean(skull.BM) s <- sd(skull.BM) c <- 136.402 n <- length(skull.BM) alpha <- 0.05 # hladina vyznamnosti alpha = 0.05 (zvolena podle zadani) # Testovani kriticky oborem (t0 <- (m - c) / (s / sqrt(n))) # testovaci statistika t0 qt(alpha / 2, n - 1) # -1.9711 qt(1 - alpha / 2, n - 1) # 1.9711 # t0 = 2.3856; kriticky obor W = (-infty ; -1.9711> U <1.9711 ; infty) # Protoze t0 nalezi do W, H0 zamitame na hladine vyznamnosti alpha = 0.05. # Teestovani intervalem spolehlivosti (dh <- m - s / sqrt(n) * qt(1 - alpha / 2, n - 1)) # dolni hranice (hh <- m - s / sqrt(n) * qt(alpha / 2, n - 1)) # horni hranice # IS = (136.5381 ; 137.8322) # Protoze c = 136.402 nenalezi do IS, H0 zamitame na hladine vyznamnosti alpha = 0.05. # Testovani p-hodnotou (pval <- 2 * min(pt(t0, n - 1), 1 - pt(t0, n - 1))) # p-hodnota # Protoze p-hodnota = 0.01791 < alpha = 0.05, H0 zamitame na hladine vyznamnosti alpha = 0.05. # Zaver testovani: Všemi tremi zpusoby H0 zamitame. # Interpretace vysledku: Mezi stredni hodnotou nejvetsi sirky mozkovny # u muzu staroveke a novoveke egyptske populace existuje statisticky vyznamny rozdil. # Krabicovy diagram par(mar = c(2,4,1,1)) boxplot(skull.BM, ylab = 'nejvetsi sirka mozkovny (mm)', col = 'mintcream', las = 1, border = 'darkblue') points(mean(skull.BM), pch = 19, col = 'blue') points(136.402, pch = 19, col = 'red') legend('topright', col = c('blue', 'red'), pch = 19, legend = c('staroveka pop.', 'novoveka pop.'), bty = 'n') #========================================================== # P R I K L A D 7.2 #========================================================== # H0: sigma^2 >= 6.411^2 # H1: sigma^2 < 6.411^2 (levostranna alternativa) # alpha = 0.1 (ze zadani) data <- read.delim('01-one-sample-mean-skull-mf.txt') data <- na.omit(data) skull.BM <- data[data$sex == 'm', "skull.B"] m <- mean(skull.BM) s <- sd(skull.BM) c <- 6.411^2 n <- length(skull.BM) alpha <- 0.1 # Testovani kritickym oborem (t0 <- (n-1) * s ^ 2 / c) # tetsovaci statistika qchisq(alpha, n - 1) # kriticky obor W # W = (0; 188.9801); t0 = 121.7635; t0 nalezi do W -> H0 zamitame. # Testovani Intervalem spolehlivosti (HH <- (n - 1) * s ^ 2 / qchisq(alpha, n - 1)) # horni hranice IS # IS = (-infty ; 26.4947); 6.411^2 = 41.10092 nenalezi do IS -> H0 zamitame. # Testovani p-hodnotou (pval <- pchisq(t0, n - 1)) # p-hodnota # p-hodnota = 4.35 x 10^(-8), alpha = 0.1; p-hodnota < alpha -> H0 zamitame. # Interpretace vysledku: Rozptyl nejvetsi sirky mozkovny muzu staroveke # egyptske populace je statisticky vyznamne mensi nez rozptyl nejvetsi sirky mozkovny # muzu novoveke egyptske populace. #========================================================== # P R I K L A D 7.3 #========================================================== # H0: sigma >= 6.411 -> H0: sigma^2 >= 6.411^2 # H1: sigma < 6.411 -> H1: sigma^2 < 6.411^2 (levostranna alternativa) # alpha = 0.1 (ze zadani) # Test o smerodatne odchylce prevedeme na test o rozptylu a vsimneme si, # ze zadani vede na uplne stejne reseni jako v prikladu 7.2. # Vypocet by byl tedy totozny s vypoctem uvedenym v prikladu 7.2. # Zaver: Smerodatna odchylka nejvetsi sirky mozkovny muzu staroveke # egyptske populace je statisticky vyznamne mensi nez smerodatna odchylka nejvetsi sirky mozkovny # muzu novoveke egyptske populace.