library(BSDA)
## Warning: package 'BSDA' was built under R version 4.5.2
## Cargando paquete requerido: lattice
##
## Adjuntando el paquete: 'BSDA'
## The following object is masked from 'package:datasets':
##
## Orange
# DATOS ALEATORIOS
data=c(30, 35, 36, 20,39,39, 38, 34, 30, 40,
25, 20, 28, 29,29, 29, 28, 24, 25, 26,
32, 36, 36, 25, 20, 24, 23, 23, 28, 29) # años
# Prueba hipótesis de doble cola
# HO: mu == 30
# HA: mu != 30
# Valor crítico
Alpha=0.05
Zc=abs(qnorm(Alpha/2))
Zc
## [1] 1.959964
z.test( x = data,
alternative = "two.sided",
mu = 30,
sigma.x = sd(data),
conf.level = 0.95 # nivel de significancia: alpha
)
##
## One-sample z-Test
##
## data: data
## z = -0.60897, p-value = 0.5425
## alternative hypothesis: true mean is not equal to 30
## 95 percent confidence interval:
## 27.18767 31.47899
## sample estimates:
## mean of x
## 29.33333
# Prueba hipótesis de cola Izquiera
# HO: mu >= 50
# HA: mu < 50
# Valor crítico
Alpha=0.05
Zc=qnorm(Alpha)
Zc
## [1] -1.644854
z.test( x = data,
alternative = "less",
mu = 50,
sigma.x = sd(data),
conf.level = 0.95 # nivel de significancia: alpha
)
##
## One-sample z-Test
##
## data: data
## z = -18.878, p-value < 2.2e-16
## alternative hypothesis: true mean is less than 50
## 95 percent confidence interval:
## NA 31.13403
## sample estimates:
## mean of x
## 29.33333
# Prueba hipótesis de cola derecha
# HO: mu <= 30
# HA: mu > 30
# Valor crítico
Alpha=0.05
Zc=qnorm(Alpha)
Zc
## [1] -1.644854
z.test( x = data,
alternative = "greater",
mu = 30,
sigma.x = sd(data),
conf.level = 0.95 # nivel de significancia: alpha
)
##
## One-sample z-Test
##
## data: data
## z = -0.60897, p-value = 0.7287
## alternative hypothesis: true mean is greater than 30
## 95 percent confidence interval:
## 27.53264 NA
## sample estimates:
## mean of x
## 29.33333