Descargar y separar datos
##install.packages("tidyverse")
##library(tydiverse)
file.choose()
## [1] "C:\\Users\\sguerra\\Downloads\\Act-3.3.Rmd"
base <- read.csv("C:\\Users\\sguerra\\Downloads\\B2.csv")
base[is.na(base)] <- 0
españa <- base[base$Q13 == 2,]
mexico <- base[base$Q13 == 1,]
#Hipotesis 1; Hipotesis Alterna
q9 <- as.numeric(españa$Q9)
q9data <- sum(q9 == 1) / length(q9)
hipotesis1 <- 0.866
##res1 <- t.test(q9data, alternative = "two.sided", conf.level = 0.95, mu = hipotesis1)
#Hipotesis 2; Hipotesis Alterna
q6 <- as.numeric(mexico$Q6_4)
q6data <- mean(q6)
hipotesis2 <- .50
res2 <- t.test(q6, alternative = "less", conf.level = 0.95, mu = hipotesis2)
res2
##
## One Sample t-test
##
## data: q6
## t = 61.873, df = 531, p-value = 1
## alternative hypothesis: true mean is less than 0.5
## 95 percent confidence interval:
## -Inf 5.048437
## sample estimates:
## mean of x
## 4.930451
#Hipotesis 3; Hipotesis Alterna
q611 <- as.numeric(españa$Q6_11)
q6media <- mean(q611)
hipotesis3 <- 0.55
res3 <- t.test(q611, alternative = "less", conf.level = 0.95, mu = hipotesis3)
res3
##
## One Sample t-test
##
## data: q611
## t = 21.395, df = 400, p-value = 1
## alternative hypothesis: true mean is less than 0.55
## 95 percent confidence interval:
## -Inf 2.681153
## sample estimates:
## mean of x
## 2.528678
#Hipotesis4; Hipotesis Alterna
vmex <- mexico$Q7
vesp <- españa$Q7
res4 <- t.test(vmex, vesp)
res4
##
## Welch Two Sample t-test
##
## data: vmex and vesp
## t = 0.61111, df = 700.75, p-value = 0.5413
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.3876877 0.7380993
## sample estimates:
## mean of x mean of y
## 3.753759 3.578554
#Hipotesis 5; Hipotesis Alterna
q12 <- as.numeric(mexico$Q12)
hipotesis5 <- c(25, 36)
res5 <- t.test(q12, mu = mean(hipotesis5), conf.level = 0.95)
res5
##
## One Sample t-test
##
## data: q12
## t = 12.66, df = 531, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 30.5
## 95 percent confidence interval:
## 39.57236 42.90508
## sample estimates:
## mean of x
## 41.23872
#Hipotesis6; Hipotesis Alterna
q12 <- as.numeric(españa$Q12)
hipotesis6 <- c(15,29)
res6 <- t.test(q12, mu = mean(hipotesis6), conf.level = 0.95)
res6
##
## One Sample t-test
##
## data: q12
## t = 17.396, df = 400, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 22
## 95 percent confidence interval:
## 35.26723 38.64798
## sample estimates:
## mean of x
## 36.95761