Repaso Pruebas de hipótesis para un promedio

x = seq(-4,4,0.1)
y = dt(x,df = 2)

plot(x,y,type = "l",
     main="t distribution \n with 2 df")

Prueba para pH

pH = rnorm(50,5.6,0.2)

mean(pH) # Media de pH
## [1] 5.599352
sd(pH) # Desviacion estandar de pH
## [1] 0.1850624
plot(density(pH))

Simulación

set.seed(2022)
sim1= replicate(n = 200,
                expr = rnorm(50,5.6,0.2))

mean(sim1[,1]) # Media de columna 1
## [1] 5.574225
medias = colMeans(sim1)

hist(medias,nclass = 70,xlim=c(5.5,5.82))
abline(v=mean(sim1[,1]),
       col="red",lwd=2,lty=2)
abline(v=5.8,col="blue")

T-test

pr1 =t.test(x = pH,mu = 5.8,
       alternative = "l")

ifelse(pr1$p.value<0.05,
       "Rechazo Ho","No Rechazo Ho")
## [1] "Rechazo Ho"

Prueba de hipotesis para una prevalencia

set.seed(2022)

fumagina =round(runif(n = 80 ,
                min = 0.35,
                max = 1),0) 

table(fumagina)[1]/sum(table(fumagina))*100
##    0 
## 22.5
pr2 = prop.test(x = table(fumagina)[1],
          n = 80,
          p = 0.05,alternative = "g")
## Warning in prop.test(x = table(fumagina)[1], n = 80, p = 0.05, alternative =
## "g"): Chi-squared approximation may be incorrect
ifelse(pr2$p.value<0.05,
       "Rechazo Ho",
       "No rechazo Ho")
## [1] "Rechazo Ho"