nombre <- "Sabrina Adrian Zelaya"
print(nombre)
## [1] "Sabrina Adrian Zelaya"
#dataset
data("quakes")
#Tamaño muestral
n <- 150
#Semilla para reproducibilidad
set.seed(120)
#Muestra aleatoria simple sin reemplazo
muestra <- quakes[sample(1:nrow(quakes), size = n, replace = FALSE), ]
media_muestral <- mean(muestra$mag)
media_muestral
## [1] 4.612667
s_muestral <- sd(muestra$mag)
error_estandar <- s_muestral / sqrt(n)
error_estandar
## [1] 0.0330317
#Valor crítico t
t_crit <- qt(0.95, df = n - 1)
#Límites del intervalo de confianza
IC_inf <- media_muestral - t_crit * error_estandar
IC_sup <- media_muestral + t_crit * error_estandar
c(IC_inf, IC_sup)
## [1] 4.557994 4.667339
#Población
prop_poblacional <- mean(quakes$mag >= 5)
#Muestra
prop_muestral <- mean(muestra$mag >= 5)
prop_poblacional
## [1] 0.198
prop_muestral
## [1] 0.2133333
error_estandar_prop <- sqrt(prop_muestral * (1 - prop_muestral) / n)
error_estandar_prop
## [1] 0.03344869