Álvaro Alonso Fernández
Departamento de Ciencias de la Vida
Universidad de Alcalá (España)
ASIGNATURA: Introducción a los TFGs orientados a la investigación
Transversal Ciencias Ambientales
Se puede reproducir íntegro para usos no comerciales, sin modificar y citando a los autores.
Hemos seguido el método científico. Ahora toca explorar nuestros datos y ver si tenemos alguna tendencia clara.
setwd(dir = "F:/R/Introtfg2024/")
datos<-read.table("Muestreo_inTFG.csv", sep = ";", header = TRUE, dec = ".")
datos
## Id_individuo sexo estudios orden papel movil mov_pap
## 1 Promedio A-01 Hombre Biosan PM 65 85 20
## 2 Promedio A-02 Mujer Biosan MP 90 75 -15
## 3 Promedio A-03 Mujer Biosan PM 75 90 15
## 4 Promedio A-04 Mujer Biosan PM 100 95 -5
## 5 Promedio A-08 Mujer Bio MP 75 75 0
## 6 Promedio A-09 Mujer Biosan PM 95 85 -10
## 7 Promedio A-10 Mujer Biosan MP 80 85 5
## 8 Promedio A-11 Mujer Biosan MP 100 100 0
## 9 Promedio A-12 Mujer Biosan PM 95 95 0
## 10 Promedio A-13 Mujer Biosan PM 80 75 -5
## 11 Promedio A-14 Mujer Biosan MP 80 80 0
## 12 Promedio A-15 Hombre Biosan PM 90 80 -10
## 13 Promedio A-16 Mujer Biosan MP 100 70 -30
## 14 Promedio A-17 Mujer Biosan PM 80 65 -15
## 15 Promedio A-18 Hombre Bio MP 75 90 15
## 16 Promedio A-32 Mujer Biosan PM 90 75 -15
## 17 Promedio A-33 Hombre Biosan MP 75 75 0
## 18 Promedio A-34 Hombre Biosan PM 70 90 20
## 19 Promedio A-35 Mujer Biosan PM 90 65 -25
## 20 Promedio A-36 Mujer Biosan PM 80 90 10
## 21 Promedio A-37 Mujer Biosan PM 85 90 5
## 22 Promedio A-38 Mujer Biosan MP 100 95 -5
## 23 Promedio A-39 Mujer Biosan MP 95 100 5
## 24 Promedio A-40 Hombre Biosan PM 90 95 5
str(datos)
## 'data.frame': 24 obs. of 7 variables:
## $ Id_individuo: chr "Promedio A-01 " "Promedio A-02" "Promedio A-03" "Promedio A-04" ...
## $ sexo : chr "Hombre" "Mujer " "Mujer " "Mujer " ...
## $ estudios : chr "Biosan" "Biosan" "Biosan" "Biosan" ...
## $ orden : chr "PM" "MP" "PM" "PM" ...
## $ papel : int 65 90 75 100 75 95 80 100 95 80 ...
## $ movil : int 85 75 90 95 75 85 85 100 95 75 ...
## $ mov_pap : int 20 -15 15 -5 0 -10 5 0 0 -5 ...
library(ggplot2)
gr00<-ggplot(datos, aes(x=0, y=papel))+ geom_boxplot(color="red", fill="orange")+
labs(x='Tratamiento Papel', y='Porcentaje de recuerdo')
gr11<-ggplot(datos, aes(x=0, y=movil))+ geom_boxplot(color="darkgreen", fill="green")+
labs(x='Tratamiento Móvil', y='Porcentaje de recuerdo')
library(patchwork)
(gr00|gr11)
grDifs<-ggplot(datos, aes(x=0, y=mov_pap))+ geom_boxplot(color="black", fill="red",width = 0.25)+
labs(x='Población de estudio', y='Diferencias de recuerdo')+
geom_jitter()
grDifs
###Grafico de dispersión Papel vs movil
plot(papel~movil,data=datos,pch=16)
abline(lm(papel~movil,data=datos),col="red")
###Veamos la regresión lineal
model<-lm(papel~movil,data=datos)
summary(model)
##
## Call:
## lm(formula = papel ~ movil, data = datos)
##
## Residuals:
## Min 1Q Median 3Q Max
## -20.8100 -7.3376 0.3002 7.3849 17.5206
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 66.9367 17.3768 3.852 0.000865 ***
## movil 0.2220 0.2049 1.083 0.290337
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 10.31 on 22 degrees of freedom
## Multiple R-squared: 0.05066, Adjusted R-squared: 0.007503
## F-statistic: 1.174 on 1 and 22 DF, p-value: 0.2903
library(ggplot2)
qplot(datos$movil,datos$papel,geom = c("point", "smooth"))
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
###NORMALIDAD DE LAS VARIABLES
shapiro.test(datos$papel)
##
## Shapiro-Wilk normality test
##
## data: datos$papel
## W = 0.93303, p-value = 0.1139
shapiro.test(datos$movil)
##
## Shapiro-Wilk normality test
##
## data: datos$movil
## W = 0.9378, p-value = 0.1457
shapiro.test(datos$mov_pap)
##
## Shapiro-Wilk normality test
##
## data: datos$mov_pap
## W = 0.9675, p-value = 0.6059
###VARIANZAS
var.test(datos$papel,datos$movil)
##
## F test to compare two variances
##
## data: datos$papel and datos$movil
## F = 0.97327, num df = 23, denom df = 23, p-value = 0.9488
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
## 0.4210313 2.2498574
## sample estimates:
## ratio of variances
## 0.973273
#Se cumplen todos los requisitos
Para esta figura haremos un test no pareado, es decir se compararán todos los valores de una variable con todos los valores de la otra:
library(patchwork)
(gr00|gr11)
###Test de t-student no pareada:
t.test(datos$papel,datos$movil, var.equal=TRUE, paired=FALSE)
##
## Two Sample t-test
##
## data: datos$papel and datos$movil
## t = 0.4846, df = 46, p-value = 0.6303
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -4.599139 7.515806
## sample estimates:
## mean of x mean of y
## 85.62500 84.16667
Ahora haremos lo mismo pero con un test pareado, es decir se compara el resultado de cada individuo:
###Test de t-student pareada:
t.test(datos$papel,datos$movil, var.equal=TRUE, paired=TRUE)
##
## Paired t-test
##
## data: datos$papel and datos$movil
## t = 0.55049, df = 23, p-value = 0.5873
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -4.021868 6.938535
## sample estimates:
## mean of the differences
## 1.458333
Para esta figura haremos una comparación entre los valores y cero, es decir se compararán si ese conjunto de datos difiere de cero o no:
grDifs
###Test t-student diferencias igual a cero
t.test(datos$mov_pap)
##
## One Sample t-test
##
## data: datos$mov_pap
## t = -0.55049, df = 23, p-value = 0.5873
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## -6.938535 4.021868
## sample estimates:
## mean of x
## -1.458333
ahora toca pensar, ¿qué se puede discutir? ¿es correcto lo que hemos hecho? ¿se puede sacar alguna conclusión?
Departamento de Ciencias de la Vida
Universidad de Alcalá (España)