tTest - start
This commit is contained in:
parent
bc7247353f
commit
1896c3cc83
@ -17,4 +17,9 @@ bootstrappedData <- ourBoot(Wynik, 200, 50)
|
||||
|
||||
par(mfrow=c(1,2))
|
||||
hist(Wynik,prob=T,main='')
|
||||
hist(bootstrappedData,prob=T,main='')
|
||||
hist(bootstrappedData,prob=T,main='')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -31,6 +31,61 @@ tapply(Blad,Kod,var)
|
||||
var.test(Blad~Kod)
|
||||
t.test(Blad~Kod,var.equal=T,alternative='less')
|
||||
|
||||
# tTest dla dwoch prób-------------------------------------------------------------------
|
||||
#wariancj
|
||||
|
||||
#podiał danych tak by tam gdzie jest 1 w blad był jeden zdbió® i tam gdzier 2 był drugi zbiór
|
||||
|
||||
x <- Bledy$Blad
|
||||
y <- Bledy$Kod
|
||||
|
||||
var1 <- var(x)
|
||||
var2 <- var(y)
|
||||
|
||||
#m0 i alpha- będzie przekazen w funcki
|
||||
m0 <- 0
|
||||
alpha = 0.05
|
||||
|
||||
m1 <- mean(x)
|
||||
m2 <- mean(y)
|
||||
n1 <- length(x)
|
||||
n2 <- length(y)
|
||||
|
||||
sigma1 <- sqrt(n1)
|
||||
sigma2 <- sqrt(n2)
|
||||
|
||||
# odchulylenie standardowe
|
||||
S <- sqrt((var1/n1)+(var2/n2))
|
||||
|
||||
#Test statistic used to compute the p-value.
|
||||
statistic <- (m1 - m2 - m0) / S
|
||||
|
||||
alternative = "less"
|
||||
|
||||
#p wartość
|
||||
p <- if (alternative == "two.sided") {
|
||||
2 * pnorm(abs(statistic), lower.tail = FALSE)
|
||||
} else if (alternative == "less") {
|
||||
pnorm(statistic, lower.tail = TRUE)
|
||||
} else {
|
||||
pnorm(statistic, lower.tail = FALSE)
|
||||
}
|
||||
|
||||
LCL <- (m1 - m2 - S * qnorm(1 - alpha / 2))
|
||||
UCL <- (m1 - m2 + S * qnorm(1 - alpha / 2))
|
||||
|
||||
value <- list(mean1 = m1, mean2 = m2, m0 = m0, sigma1 = sigma1, sigma2 = sigma2, S = S, statistic = statistic, p.value = p, LCL = LCL, UCL = UCL)
|
||||
var1
|
||||
var2
|
||||
|
||||
value
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#dwie próby zależne
|
||||
load("Cisnienie.RData")
|
||||
attach(Cisnienie)
|
||||
|
Loading…
Reference in New Issue
Block a user