Saltar al contenido principal
LibreTexts Español

8.4: Pruebas...

  • Page ID
    149935
  • \( \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}}\)

    La significancia de la diferencia entre medias para datos paramétricos pareados (prueba t para datos emparejados):

    Código\(\PageIndex{1}\) (R):

    data <- read.table("data/bugs.txt", h=TRUE)
    t.test(data$WEIGHT, data$LENGTH, paired=TRUE)

    ... prueba t para datos independientes:

    Código\(\PageIndex{2}\) (R):

    data <- read.table("data/bugs.txt", h=TRUE)
    t.test(data$WEIGHT, data$LENGTH, paired=FALSE)

    (El último ejemplo es para fines de aprendizaje solo porque nuestros datos están emparejados ya que cada fila corresponde con un animal. Además, “Paired=false” es el valor por defecto para el t.test (), por lo tanto se puede omitir.)

    Aquí es cómo comparar los valores de un carácter entre dos grupos usando la interfaz de fórmula:

    Código\(\PageIndex{3}\) (R):

    data <- read.table("data/bugs.txt", h=TRUE)
    t.test(data$WEIGHT ~ data$SEX)

    Se utilizó la fórmula porque nuestros datos de peso/sexo están en forma larga:

    Código\(\PageIndex{4}\) (R):

    data <- read.table("data/bugs.txt", h=TRUE)
    data[, c("WEIGHT", "SEX")]

    Convierta los datos de peso/sexo en la forma corta y pruebe:

    Código\(\PageIndex{5}\) (R):

    data <- read.table("data/bugs.txt", h=TRUE)
    data3 <- unstack(data[, c("WEIGHT", "SEX")])
    t.test(data3[[1]], data3[[2]])

    (Tenga en cuenta que los resultados de las pruebas son exactamente los mismos. El único formato era diferente.)

    Si el valor p es igual o menor que 0.05, entonces la diferencia se soporta estadísticamente. R no requiere que verifiques si la dispersión es la misma.

    Prueba no paramétrica de Wilcoxon para las diferencias:

    Código\(\PageIndex{6}\) (R):

    data <- read.table("data/bugs.txt", h=TRUE)
    wilcox.test(data$WEIGHT, data$LENGTH, paired=TRUE)

    Prueba unidireccional para las diferencias entre tres y más grupos (la variante simple de ANOVA, análisis de variación):

    Código\(\PageIndex{7}\) (R):

    data <- read.table("data/bugs.txt", h=TRUE)
    wilcox.test(data$WEIGHT ~ data$SEX)

    ¿Qué par (s) son significativamente diferentes?

    Código\(\PageIndex{8}\) (R):

    data <- read.table("data/bugs.txt", h=TRUE)
    pairwise.t.test(data$WEIGHT, data$COLOR, p.adj="bonferroni")

    (Se utilizó la corrección de Bonferroni para comparaciones múltiples.)

    Prueba no paramétrica de Kruskal-Wallis para diferencias entre tres y más grupos:

    Código\(\PageIndex{9}\) (R):

    data <- read.table("data/bugs.txt", h=TRUE)
    kruskal.test(data$WEIGHT ~ data$COLOR)

    ¿Qué pares son significativamente diferentes en esta prueba no paramétrica?

    Código\(\PageIndex{10}\) (R):

    data <- read.table("data/bugs.txt", h=TRUE)
    pairwise.wilcox.test(data$WEIGHT, data$COLOR)

    La significancia de la correspondencia entre los datos categóricos (chi-cuadrado de Pearson no paramétrico, o\(\chi^2\) prueba):

    Código\(\PageIndex{11}\) (R):

    data <- read.table("data/bugs.txt", h=TRUE)
    chisq.test(data$COLOR, data$SEX)

    La significancia de las proporciones (no paramétricas):

    Código\(\PageIndex{12}\) (R):

    data <- read.table("data/bugs.txt", h=TRUE)
    prop.test(sum(data$SEX), length(data$SEX), 0.5)

    (Aquí comprobamos si esto es cierto que la proporción de varones es diferente del 50%.)

    La significancia de la correlación lineal entre variables, vía paramétrica (prueba de correlación de Pearson):

    Código\(\PageIndex{13}\) (R):

    data <- read.table("data/bugs.txt", h=TRUE)
    cor.test(data$WEIGHT, data$LENGTH, method="pearson")

    ... y vía no paramétrica (prueba de correlación de Spearman):

    Código\(\PageIndex{14}\) (R):

    data <- read.table("data/bugs.txt", h=TRUE)
    cor.test(data$WEIGHT, data$LENGTH, method="spearman")

    La significancia (y muchos más) del modelo lineal que describe la relación de una variable sobre otra:

    Código\(\PageIndex{15}\) (R):

    data <- read.table("data/bugs.txt", h=TRUE)
    summary(lm(data$LENGTH ~ data$SEX))

    ... y análisis de variación (ANOVA) basado en el modelo lineal:

    Código\(\PageIndex{16}\) (R):

    data <- read.table("data/bugs.txt", h=TRUE)
    aov(lm(data$LENGTH ~ data$SEX))

    This page titled 8.4: Pruebas... is shared under a Public Domain license and was authored, remixed, and/or curated by Alexey Shipunov via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.