1 / 30

Introducción al análisis descriptivo en R

Introducción al análisis descriptivo en R. Análisis descriptivo en R. Objetivo del análisis descriptivo Tipos de variables Gráficas básicas Histograma y estimación de la densidad Diagramas de dispersión Boxplot Cálculo de índices básicos Discusión de ejemplos.

jon
Download Presentation

Introducción al análisis descriptivo en R

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introducción al análisis descriptivo en R

  2. Análisis descriptivo en R • Objetivo del análisis descriptivo • Tipos de variables • Gráficas básicas • Histograma y estimación de la densidad • Diagramas de dispersión • Boxplot • Cálculo de índices básicos • Discusión de ejemplos

  3. Objetivo del análisis descriptivo • Explorar la estructura de los datos • Proponer una interpretación de la variación observada • Valorar la influencia de variables de confusión • Resumir las principales características de los datos

  4. Tipos de variables • Cuantitativas • Discretas: Número de accidentes, Número de hijos varones, Número de diagnósticos correctos, • Continuas: Edad, Peso, Tiempo, Volumen celular • Cualitativas • Nominales: Género (Hombre/Mujer), Diagnóstico (Sano/Emfermo), Fenotipo (AA/Aa/aa) • Ordinales: Gravedad (0,+,++), Obesidad (Normal/Sobrepeso/Obeso/Obeso Grave)

  5. Base de datos • Utilizaremos la base de datos fat disponible en el paquete UsingR

  6. Algunas cuestiones de interés • ¿Qué valores de BMI se han obtenido? • Estudiar la distribución de los valores en la muestra (histograma y densidad). • ¿Cómo se relaciona la altura con el peso? ¿La distribución del BMI depende de la edad? • Diagrama de dispersión. Regresión de cuantiles

  7. ¿Qué valores de BMI se han obtenido?

  8. Histograma

  9. Histograma

  10. Estimación de la densidad

  11. Estimación de la densidad

  12. Estimación de la densidadModelo normal

  13. Estimación de la densidadModelo normal

  14. ¿Cómo se relaciona la altura con el peso?

  15. ¿Cómo se relaciona la altura con el peso? Cuantil: Valor para el cual un determinado % de individuos tienen valores iguales o inferiores a el. Ejemplo: Si el cuantil 90 de peso es de 70 kg., entonces un 90% de individuos de esta población tienen valores de peso iguales o inferiores a 70 kg. La regresión de cuantiles permite estimar cómo varían los cuantiles de una varaible en función de otra(s) variable(s).

  16. ¿Depende el BMI de la edad? El análisis descriptivo indica que la variación del BMI con la edad no es muy importante. La dispersión por edades parece mantenerse constante.

  17. Datos de un ensayo clínico hipotético • Los datos AssaigClinic.Restan en formato de tabla. En cada caso, debéis copiar el fichero en un directorio. • Indicar el directorio en la instrucción read.table • El resultado es un data.frame que contiene la información del fichero.

  18. Datos de un ensayo clínico hipotético • Podemos explorar qué variables se han recogido: • Veamos qué tratamientos se han incluido: • Recordad que podemos acceder directamente a las variables de un data.frame mediante attach

  19. Tabulación de datos

  20. Tabulación de datos

  21. Tabulación de datos

  22. Gráfico debarras

  23. Gráfico debarras

  24. Boxplot

  25. Boxplot (subgrupos)

  26. Boxplot (subgrupos)

  27. Histograma (Subgrups)

  28. Medias por subgrupos

  29. #this next command defines a new function which can then be used #for making multiple histograms multi.hist <- function(x) {nvar <- dim(x)[2] #number of variables nsize=trunc(sqrt(nvar))+1 #size of graphic old.par <- par(no.readonly = TRUE) # all par settings which can be changed par(mfrow=c(nsize,nsize)) #set new graphic parameters for (i in 1:nvar) { name=names(x)[i] #get the names for the variables hist(x[,i],main=name,xlab=name) } #draw the histograms for each variable on.exit(par(old.par)) #set the graphic parameters back to the original } #now use the function on the data multi.hist(person.data) #draw the histograms for all variables (see above) #this next command defines a new function which can then be used #for making multiple histograms multi.hist <- function(x) {nvar <- dim(x)[2] #number of variables nsize=trunc(sqrt(nvar))+1 #size of graphic old.par <- par(no.readonly = TRUE) # all par settings which can be changed par(mfrow=c(nsize,nsize)) #set new graphic parameters for (i in 1:nvar) { name=names(x)[i] #get the names for the variables hist(x[,i],main=name,xlab=name) } #draw the histograms for each variable on.exit(par(old.par)) #set the graphic parameters back to the original } #now use the function on the data multi.hist(person.data) #draw the histograms for all variables (see above) #this next command defines a new function which can then be used #for making multiple histograms multi.hist <- function(x) {nvar <- dim(x)[2] #number of variables nsize=trunc(sqrt(nvar))+1 #size of graphic old.par <- par(no.readonly = TRUE) # all par settings which can be changed par(mfrow=c(nsize,nsize)) #set new graphic parameters for (i in 1:nvar) { name=names(x)[i] #get the names for the variables hist(x[,i],main=name,xlab=name) } #draw the histograms for each variable on.exit(par(old.par)) #set the graphic parameters back to the original } #now use the function on the data multi.hist(person.data) #draw the histograms for all variables (see above) #this next command defines a new function which can then be used #for making multiple histograms multi.hist <- function(x) {nvar <- dim(x)[2] #number of variables nsize=trunc(sqrt(nvar))+1 #size of graphic old.par <- par(no.readonly = TRUE) # all par settings which can be changed par(mfrow=c(nsize,nsize)) #set new graphic parameters for (i in 1:nvar) { name=names(x)[i] #get the names for the variables hist(x[,i],main=name,xlab=name) } #draw the histograms for each variable on.exit(par(old.par)) #set the graphic parameters back to the original } #now use the function on the data multi.hist(person.data) #draw the histograms for all variables (see above)

More Related