Adiciona o problema da moeda.

parent 64080ace
#=======================================================================
# Testes de hipótese Monte Carlo.
#-----------------------------------------------------------------------
#
# x <- scan()
# dput(x)
# Amostra observada.
x <- c(c(1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0),
c(1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0))
# Caracterização.
n <- length(x)
p <- mean(x)
d <- sum(abs(diff(x)))
D <- replicate(9999, {
# Amostras sob a H_0.
r <- rbinom(n = n, size = 1, prob = 0.5)
# Estatística calculada.
sum(abs(diff(r)))
})
D <- c(d, D)
plot(ecdf(D))
abline(v = d, col = 2)
abline(h = c(0.025, 0.975), col = 2, lty = 2)
2 * sum(D > d)/length(D)
#-----------------------------------------------------------------------
# Teste para independência de processo pontual.
......@@ -66,7 +96,8 @@ abline(h = c(0.025, 0.975), lty = 2)
abline(v = m, col = 2)
# P-valor.
2 * sum(M > m)/length(M)
2 * sum(M > m)/length(M) # Faz sentido esse teste ser bilateral?
sum(M > m)/length(M)
#-----------------------------------------------------------------------
# ATTENTION: dados um tanto patológicos.
......@@ -125,7 +156,8 @@ abline(h = c(0.025, 0.975), lty = 2)
abline(v = m, col = 2)
# P-valor.
2 * sum(M > m)/length(M)
# 2 * sum(M > m)/length(M)
sum(M > m)/length(M)
#-----------------------------------------------------------------------
# Moficando a estatística de teste 2.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment