Intervalos de confianza
Estadística para las Ciencias Sociales
Diego Solís Delgadillo
Punto estimado
Intervalo estimado
Ejemplo
# A tibble: 50 × 2
ID year
<int> <dbl>
1 1 2002
2 2 1986
3 3 2017
4 4 1988
5 5 2008
6 6 1983
7 7 2008
8 8 1996
9 9 2004
10 10 2000
# ℹ 40 more rows
Tip
# A tibble: 1 × 1
mean_year
<chr>
1 1995.44
Warning
Tip
Tip
pennies_resample <- tibble(
year = c(1976, 1962, 1976, 1983, 2017, 2015, 2015, 1962, 2016, 1976,
2006, 1997, 1988, 2015, 2015, 1988, 2016, 1978, 1979, 1997,1974, 2013, 1978, 2015, 2008, 1982, 1986, 1979, 1981, 2004,
2000, 1995, 1999, 2006, 1979, 2015, 1979, 1998, 1981, 2015,
2000, 1999, 1988, 2017, 1992, 1997, 1990, 1988, 2006, 2000))
ggplot(pennies_resample, aes(x = year)) +
geom_histogram(binwidth = 10, color = "white") +
labs(title = "Remuestreo de 50 monedas")
Tip
# A tibble: 1,750 × 3
# Groups: name [35]
replicate name year
<int> <chr> <dbl>
1 1 Arianna 1988
2 1 Arianna 2002
3 1 Arianna 2015
4 1 Arianna 1998
5 1 Arianna 1979
6 1 Arianna 1971
7 1 Arianna 1971
8 1 Arianna 2015
9 1 Arianna 1988
10 1 Arianna 1979
# ℹ 1,740 more rows
resampled_means <- pennies_resamples %>%
group_by(name) %>%
summarize(mean_year = mean(year))
resampled_means
# A tibble: 35 × 2
name mean_year
<chr> <chr>
1 Arianna 1992.50
2 Artemis 1996.42
3 Bea 1996.32
4 Camryn 1996.90
5 Cassandra 1991.22
6 Cindy 1995.48
7 Claire 1995.52
8 Dahlia 1998.48
9 Dan 1993.86
10 Eindra 1993.56
# ℹ 25 more rows
Tip
remuestreo <- pennies_sample %>% rep_sample_n(size = 50, replace = TRUE, reps = 1000)
medias_remuestreo<-remuestreo %>%
group_by(replicate) %>%
summarize(mean_year = mean(year))
# A tibble: 1,000 × 2
replicate mean_year
<int> <dbl>
1 1 1994.
2 2 1993.
3 3 1995.
4 4 1993.
5 5 1999.
6 6 1995.
7 7 1996.
8 8 1992.
9 9 1995.
10 10 1999.
# ℹ 990 more rows
ggplot(medias_remuestreo, aes(x = mean_year)) +
geom_histogram(binwidth = 1, color = "white", boundary = 1990) +
labs(x = "media muestra")
library(infer)
pennies_sample %>%
specify(response = year) %>%
generate(reps = 1000, type = "bootstrap")
Response: year (numeric)
# A tibble: 50,000 × 2
# Groups: replicate [1,000]
replicate year
<int> <dbl>
1 1 1997
2 1 1990
3 1 2016
4 1 1995
5 1 1962
6 1 1985
7 1 1996
8 1 2016
9 1 2016
10 1 1992
# ℹ 49,990 more rows
distribucion_bootstrap <- pennies_sample %>%
specify(response = year) %>%
generate(reps = 1000) %>%
calculate(stat = "mean")
distribucion_bootstrap
Response: year (numeric)
# A tibble: 1,000 × 2
replicate stat
<chr> <chr>
1 1 1994.22
2 2 1994.78
3 3 1993.52
4 4 1994.52
5 5 1992.38
6 6 1998.58
7 7 1990.92
8 8 1997.32
9 9 1997.30
10 10 1997.70
# ℹ 990 more rows
Tip
Importante
Cómo NO interpretar el intervalo
Hay un 95% de probabilidad de que dentro del intervalo esté el valor verdadero
¿Cómo interpretar el intervalo?
Si no hay sesgo y repetimos nuestro estimador infinitamente, el valor del parámetro estará dentro del intervalo el 95% de las veces{style=“color: #3399ff”}
x_bar<-distribucion_bootstrap %>% summarise(mean(stat))
error_estandar_ic <- distribucion_bootstrap %>%
get_confidence_interval(type = "se", point_estimate = x_bar)
error_estandar_ic
# A tibble: 1 × 2
lower_ci upper_ci
<chr> <chr>
1 1991.351 1999.625
IC con método matemático
IC con método matemático
Distribución muestral de proporciones
Important
Margen de error
\(Puntuación Z * ErrorEstandar\)
Intervalo de confianza
\(PuntoEstimado \pm MargenError\)
Intervalo al 95%
Para un intervalo de confianza de 95%
\[ \hat{p} \pm 1.96(se) \]
Hay una muestra de 1,321 personas
637 están a favor del aumento de los precios
¿Cómo construir un intervalo de confianza de 95%?
\[ \hat{p}= \frac{637}{1,321}= 0.468 \]
.3 Para un intervalo de confianza de 95% la puntuación Z es 1.96
\[ 0.468 \pm 1.96(0.0135) \]
Resultado
\[ \hat{p} \pm 2.58(se) \]
Important
\[ se= \sqrt{\frac{\hat{p}(1-\hat{p})}{n}} \]
Note
La media de la muestra \(\bar{x}\) es el mejor estimador de la media poblacional \(\mu\)
El error estándar de la distribución de medias se expresa como
\[ se= \frac{s}{\sqrt{n}} \]
Note
\[ 3.09 \pm 1.96(0.0797) \]
Resultado