Saltar al contenido principal
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
LibreTexts Español

8.4: Pruebas...

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

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

Código8.4.1 (R):

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

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

... prueba t para datos independientes:

Código8.4.2 (R):

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

data <- read.table("data/bugs.txt", h=TRUE)
t.test(data$WEIGHT, data$LENGTH, paired=FALSE)
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ódigo8.4.3 (R):

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

data <- read.table("data/bugs.txt", h=TRUE)
t.test(data$WEIGHT ~ data$SEX)
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ódigo8.4.4 (R):

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

data <- read.table("data/bugs.txt", h=TRUE)
data[, c("WEIGHT", "SEX")]
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ódigo8.4.5 (R):

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

data <- read.table("data/bugs.txt", h=TRUE)
data3 <- unstack(data[, c("WEIGHT", "SEX")])
t.test(data3[[1]], data3[[2]])
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ódigo8.4.6 (R):

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

data <- read.table("data/bugs.txt", h=TRUE)
wilcox.test(data$WEIGHT, data$LENGTH, paired=TRUE)
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ódigo8.4.7 (R):

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

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

¿Qué par (s) son significativamente diferentes?

Código8.4.8 (R):

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

data <- read.table("data/bugs.txt", h=TRUE)
pairwise.t.test(data$WEIGHT, data$COLOR, p.adj="bonferroni")
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ódigo8.4.9 (R):

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

data <- read.table("data/bugs.txt", h=TRUE)
kruskal.test(data$WEIGHT ~ data$COLOR)
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ódigo8.4.10 (R):

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

data <- read.table("data/bugs.txt", h=TRUE)
pairwise.wilcox.test(data$WEIGHT, data$COLOR)
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χ2 prueba):

Código8.4.11 (R):

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

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

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

Código8.4.12 (R):

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

data <- read.table("data/bugs.txt", h=TRUE)
prop.test(sum(data$SEX), length(data$SEX), 0.5)
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ódigo8.4.13 (R):

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

data <- read.table("data/bugs.txt", h=TRUE)
cor.test(data$WEIGHT, data$LENGTH, method="pearson")
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ódigo8.4.14 (R):

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

data <- read.table("data/bugs.txt", h=TRUE)
cor.test(data$WEIGHT, data$LENGTH, method="spearman")
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ódigo8.4.15 (R):

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

data <- read.table("data/bugs.txt", h=TRUE)
summary(lm(data$LENGTH ~ data$SEX))
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ódigo8.4.16 (R):

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

data <- read.table("data/bugs.txt", h=TRUE)
aov(lm(data$LENGTH ~ data$SEX))
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.

Support Center

How can we help?