#install.packages("DAAG") library(DAAG) data <- pair65 y <- pair65$heated - pair65$ambient # test for the mean equal zero help("t.test") t.test(y) # null distribution n <- length(y) curve(dt(x, 8), xlim=c(-6,6)) t_obs <- mean(y)/sqrt(var(y)/n) # fixed level of significance alpha <- 0.05 q.t.1 <- qt(alpha/2, 8) q.t.2 <- qt(1-alpha/2,8) segments(q.t.1, -0.1, q.t.1, dt(q.t.1,8), col ="red") segments(q.t.2, -0.1, q.t.2, dt(q.t.2,8), col ="red") t_obs segments(t_obs, -0.1, t_obs, dt(t_obs,8), col ="blue") # p-value p_value <- 2*(1-pt(t_obs, n-1)) # temptative to make independent samples comparison x1 <- pair65$heated x2 <- pair65$ambient t.test(x1, x2, var.equal = TRUE) # t.test wit alpha = 0.001 t.test(y, conf.level = 0.99) # wilcoxon rank test wilcox.test(y)