Saltar al contenido principal
LibreTexts Español

3.4: Ejemplos con datos

  • Page ID
    150413
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    En el laboratorio de correlación se le mostrará cómo calcular correlaciones en conjuntos de datos reales usando software. Para darte un breve adelanto, veamos algunos datos del reporte de felicidad mundial (2018). Este reporte midió diversas actitudes entre personas de diferentes países. Por ejemplo, se hizo una pregunta sobre cuánta libertad la gente pensaba que tenía para tomar decisiones de vida. Otra pregunta planteaba la confianza de las personas en su gobierno nacional. Aquí hay una gráfica de dispersión que muestra la relación entre estas dos medidas. Cada punto representa medias para diferentes países.

    library(data.table)
    library(ggplot2)
    suppressPackageStartupMessages(library(dplyr))
    whr_data <- fread("https://stats.libretexts.org/@api/deki/files/10477/WHR2018.csv")
    # select DVs and filter for NAs
    smaller_df <- whr_data %>%
                   dplyr::select(country,
                          `Freedom to make life choices`,
                          `Confidence in national government`) %>%
                   dplyr::filter(!is.na(`Freedom to make life choices`),
                          !is.na(`Confidence in national government`))
    # plot the data with best fit line
    ggplot(smaller_df, aes(x=`Freedom to make life choices`,
                         y=`Confidence in national government`))+
      geom_point(alpha=.5)+
      geom_smooth(method=lm, se=FALSE, formula=y ~ x)+
      theme_classic()
    Figura\(\PageIndex{1}\): Relación entre libertad para tomar decisiones de vida y confianza en el gobierno nacional. Datos del reporte de felicidad mundial para 2018.

    Ponemos una línea azul en la gráfica de dispersión para resumir la relación positiva. Parece que a medida que “sube la libertad para tomar decisiones de vida”, también lo hace la confianza en el gobierno nacional. Es una correlación positiva.

    La correlación real, medida por Pearson\(r\) es:

    library(data.table)
    suppressPackageStartupMessages(library(dplyr))
    whr_data <- fread("https://stats.libretexts.org/@api/deki/files/10477/WHR2018.csv")
    # select DVs and filter for NAs
    smaller_df <- whr_data %>%
                   dplyr::select(country,
                          `Freedom to make life choices`,
                          `Confidence in national government`) %>%
                   dplyr::filter(!is.na(`Freedom to make life choices`),
                          !is.na(`Confidence in national government`))
    # calculate correlation
    cor(smaller_df$`Freedom to make life choices`,
        smaller_df$`Confidence in national government`)
    0.408096292505333

    Harás mucho más de este tipo de cosas en el laboratorio. Al mirar la gráfica podrías empezar a preguntarte: ¿La libertad para tomar decisiones de vida provoca cambios en la confianza de las personas en su gobierno nacional? Nuestro ¿funciona al revés? ¿Tener confianza en su gobierno nacional le da un mayor sentido de libertad para tomar decisiones de vida? O, ¿es esto solo una relación aleatoria que no significa nada? Todas buenas preguntas. Estos datos no proporcionan las respuestas, solo sugieren una posible relación.


    This page titled 3.4: Ejemplos con datos is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by Matthew J. C. Crump via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.