rm(list=ls()) #Limpiar entorno de trabajo
setwd("/home/daniel/Dropbox/U CENTRAL/02 2020/01 Primer semestre 2020/Analisis de datos cuantitativos I/Clases/11") #Escribir el directorio en que va a trabajar
#Si su pc no tiene instalado los paquetes, primero ejecutar:
#install.packages("animation")
library(animation) #Cargar paquete para demostraciones animadas
Utilizando el paquete R “animation” desarrollado por Xie , Mueller, Yu y Zhu, demostraremos el funcionamiento de los intervalos de confianza y cómo se afectan sus características, al variar el nivel de confianza en la estimación.
Nivel de confianza del 90%.
saveVideo({
ani.options(interval = 0.1, nmax = 200)
conf.int(level = 0.90, size = 500, main = "Demostración de los intervalos de confianza (90%)")
}, video.name = "ci90.mp4", other.opts = "-pix_fmt yuv420p -b 300k")
## Executing: 'ffmpeg' -y -framerate 10 -i Rplot%d.png -pix_fmt yuv420p -b 300k ci90.mp4
##
##
## Video has been created at: /home/daniel/Dropbox/U CENTRAL/02 2020/01 Primer semestre 2020/Analisis de datos cuantitativos I/Clases/11/ci90.mp4
Nivel de confianza del 95%.
saveVideo({
ani.options(interval = 0.1, nmax = 200)
conf.int(level = 0.95, size = 500, main = "Demostración de los intervalos de confianza (95%)")
}, video.name = "ci95.mp4", other.opts = "-pix_fmt yuv420p -b 300k")
## Executing: 'ffmpeg' -y -framerate 10 -i Rplot%d.png -pix_fmt yuv420p -b 300k ci95.mp4
##
##
## Video has been created at: /home/daniel/Dropbox/U CENTRAL/02 2020/01 Primer semestre 2020/Analisis de datos cuantitativos I/Clases/11/ci95.mp4
Nivel de confianza del 99%.
saveVideo({
ani.options(interval = 0.1, nmax = 200)
conf.int(level = 0.99, size = 500, main = "Demostración de los intervalos de confianza (99%)")
}, video.name = "ci99.mp4", other.opts = "-pix_fmt yuv420p -b 300k")
## Executing: 'ffmpeg' -y -framerate 10 -i Rplot%d.png -pix_fmt yuv420p -b 300k ci99.mp4
##
##
## Video has been created at: /home/daniel/Dropbox/U CENTRAL/02 2020/01 Primer semestre 2020/Analisis de datos cuantitativos I/Clases/11/ci99.mp4
Nivel de confianza del 99.9%.
saveVideo({
ani.options(interval = 0.1, nmax = 200)
conf.int(level = 0.999, size = 500, main = "Demostración de los intervalos de confianza (99.9%)")
}, video.name = "ci999.mp4", other.opts = "-pix_fmt yuv420p -b 300k")
## Executing: 'ffmpeg' -y -framerate 10 -i Rplot%d.png -pix_fmt yuv420p -b 300k ci999.mp4
##
##
## Video has been created at: /home/daniel/Dropbox/U CENTRAL/02 2020/01 Primer semestre 2020/Analisis de datos cuantitativos I/Clases/11/ci999.mp4
Podemos observar como la tasa de acierto o cobertura aumenta al aumentar el nivel de confianza y también, como el rango de los intervalos de confianza se va haciendo más ancho.