library(boot)
#Datos del hotel
demanda <- c(78,82,75,80,85,88,92,90,86,84,80,73)
#Función para calcular la media (para el bootstrap)
bootstrap_media <- function(data, indices) {
return(mean(data[indices])) # Calcula la media de la muestra remuestreada
}
#Aplicar Bootstrap con 1000 repeticiones
set.seed(616) # Fijamos seed para reproducibilidad
bootstrap_result <- boot(data = demanda, statistic = bootstrap_media, R = 1000)
#Mostrar resumen de resultados
print(bootstrap_result)
##
## ORDINARY NONPARAMETRIC BOOTSTRAP
##
##
## Call:
## boot(data = demanda, statistic = bootstrap_media, R = 1000)
##
##
## Bootstrap Statistics :
## original bias std. error
## t1* 82.75 0.0545 1.605597
intervalo_confianza <- boot.ci(bootstrap_result, type = "perc")
print(intervalo_confianza)
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
##
## CALL :
## boot.ci(boot.out = bootstrap_result, type = "perc")
##
## Intervals :
## Level Percentile
## 95% (79.67, 86.00 )
## Calculations and Intervals on Original Scale
demanda1 <- c(78,82,75,80,85,88,92,90,86,84,80,73)
#Función para calcular la media (para el bootstrap)
bootstrap_media1 <- function(data, indices) {
return(mean(data[indices])) # Calcula la media de la muestra remuestreada
}
#Aplicar Bootstrap con 100000 repeticiones
set.seed(616) # Fijamos seed para reproducibilidad
bootstrap_result1 <- boot(data = demanda1, statistic = bootstrap_media1, R = 100000)
#Mostrar resumen de resultados
print(bootstrap_result1)
##
## ORDINARY NONPARAMETRIC BOOTSTRAP
##
##
## Call:
## boot(data = demanda1, statistic = bootstrap_media1, R = 1e+05)
##
##
## Bootstrap Statistics :
## original bias std. error
## t1* 82.75 -0.0033175 1.610442
intervalo_confianza1 <- boot.ci(bootstrap_result1, type = "perc")
print(intervalo_confianza1)
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 100000 bootstrap replicates
##
## CALL :
## boot.ci(boot.out = bootstrap_result1, type = "perc")
##
## Intervals :
## Level Percentile
## 95% (79.58, 85.92 )
## Calculations and Intervals on Original Scale
demanda3 <- c(78,82,75,80,85,88,92,90,86,84,80,73)
#Función para calcular la media (para el bootstrap)
bootstrap_media3 <- function(data, indices) {
return(mean(data[indices])) # Calcula la media de la muestra remuestreada
}
#Aplicar Bootstrap con 1000 repeticiones
set.seed(616) # Fijamos seed para reproducibilidad
bootstrap_result3 <- boot(data = demanda3, statistic = bootstrap_media3, R = 1000)
#Mostrar resumen de resultados
print(bootstrap_result3)
##
## ORDINARY NONPARAMETRIC BOOTSTRAP
##
##
## Call:
## boot(data = demanda3, statistic = bootstrap_media3, R = 1000)
##
##
## Bootstrap Statistics :
## original bias std. error
## t1* 82.75 0.0545 1.605597
intervalo_confianza3 <- boot.ci(bootstrap_result3, type = "perc")
print(intervalo_confianza3)
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
##
## CALL :
## boot.ci(boot.out = bootstrap_result3, type = "perc")
##
## Intervals :
## Level Percentile
## 95% (79.67, 86.00 )
## Calculations and Intervals on Original Scale
demanda4 <- c(78,82,75,80,85,88,92,90,86,84,80,73)
#Función para calcular la media (para el bootstrap)
bootstrap_media4 <- function(data, indices) {
return(mean(data[indices])) # Calcula la media de la muestra remuestreada
}
#Aplicar Bootstrap con 1000 repeticiones
set.seed(616) # Fijamos seed para reproducibilidad
bootstrap_result4 <- boot(data = demanda4, statistic = bootstrap_media4, R = 100000)
#Mostrar resumen de resultados
print(bootstrap_result4)
##
## ORDINARY NONPARAMETRIC BOOTSTRAP
##
##
## Call:
## boot(data = demanda4, statistic = bootstrap_media4, R = 1e+05)
##
##
## Bootstrap Statistics :
## original bias std. error
## t1* 82.75 -0.0033175 1.610442
intervalo_confianza4 <- boot.ci(bootstrap_result4, type = "perc")
print(intervalo_confianza4)
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 100000 bootstrap replicates
##
## CALL :
## boot.ci(boot.out = bootstrap_result4, type = "perc")
##
## Intervals :
## Level Percentile
## 95% (79.58, 85.92 )
## Calculations and Intervals on Original Scale
80%
Si un hotel tiene debajo del 80 porciento de ocupacion esto es una alerta roja para elmismo, esto significaria que tendrian que llenar arriba de este porcentaje para poder sobrevivir dentro del mercado, para los gastos y necesidadesde el hotel el 80 porciento seria muy bajo para poder sobrevivir