####################### ### JEDANAESTI CAS ### ###################### # 1. library(palmerpenguins) attach(penguins) plot(flipper_length_mm ~ species) jda1 <- aov(flipper_length_mm ~ species) summary(jda1) # postoji znacajna razlika medju vrstama # 2. pairwise.t.test(flipper_length_mm, species) TukeyHSD(jda1) plot(TukeyHSD(jda1)) # 3. library(palmerpenguins) attach(penguins) jda2 <- aov(flipper_length_mm ~ species + year) summary(jda2) # 4. lm.model <- lm(flipper_length_mm ~ species) summary(lm.model) # 5. mtcars mtcars$mpg library(BSDA) SIGN.test(mtcars$mpg, md = 25, alternative = "less") # 6. poeni <- c(31.2, 33.3, 26.4, 29.3, 31.3, 26.9, 32.5, 30.8, 30.6, 31.9) poeni wilcox.test(poeni, mu = 30) # implementacija testa peske poeni-30 sort(abs(poeni-30)) # 7. x <- c(4.4, 3.9, 5.2, 4.6, 4.3, 3.6, 4.4) y <- c(3.4, 3.2, 2.2, 2.8, 3.1, 2.6, 3.2) d <- x-y SIGN.test(x, y, md = 0, alternative = "greater") SIGN.test(d, md = 0, alternative = "greater") # 8. A <- c(1.5, 1.4, 1.4, 1, 1.1, 0.9, 1.3, 1.2, 1.1, 0.9, 0.7, 1.8) B <- c(2, 1.8, 0.7, 1.3, 1.2, 1.5, 1.1, 0.9, 1.5, 1.7, 0.9, 0.9) # test rankova wilcox.test(A-B, mu = 0, alternative = "less") # Vilkoksonov test zbira rangova A <- c(1.5, 1.4, 1.4, 1, 1.1, 0.9, 1.3, 1.2, 0.7, 1.8) B <- c(2, 1.8, 0.7, 1.3, 1.2, 1.5, 1.1, 0.9, 1.5, 1.7, 0.9, 0.9) wilcox.test(A-B, mu = 0, alternative = "less") # 9. PlantGrowth levels(PlantGrowth$group) kruskal.test(weight ~ group, data = PlantGrowth) # 10. pacijenti <- data.frame(person = rep(1:5, each = 4), drug = rep(c(1, 2, 3, 4), times = 5), score = c(30, 28, 16, 34, 14, 18, 10, 22, 24, 20, 18, 30, 38, 34, 20, 44, 26, 28, 14, 30)) pacijenti friedman.test(y = pacijenti$score, groups = pacijenti$drug, blocks = pacijenti$person)