library(readr)
StudentsPerformance <- read_csv("StudentsPerformance.csv")
## Rows: 1000 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (5): gender, race/ethnicity, parental level of education, lunch, test pr...
## dbl (3): math score, reading score, writing score
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
N1 = 518
FM1 = StudentsPerformance[StudentsPerformance$gender=="female","math score"]
mean1 = (sum(FM1)/518)/100
sd1 = sqrt(var(FM1))
sd1
## math score
## math score 15.49145
##Hombres - p2
N2 = 482
HM1<-StudentsPerformance[StudentsPerformance$gender=="male","math score"]
mean2=(sum(HM1)/482)/100
mean2
## [1] 0.6872822
sd2=sqrt(var(HM1))
sd2
## math score
## math score 14.35628
#Prueba de hipotesis H0:{M1-M2>0} HA:{M1-M2<0}
D.E = sqrt(((sd1^2)/N1)+((sd2^2/N2)))
D.E
## math score
## math score 0.9438701
pnorm(mean1-mean2,0,D.E, lower.tail = FALSE)
## [1] 0.5215245
M.E = 1.96*D.E
M.E
## math score
## math score 1.849985
mean1-mean2
## [1] -0.05095011
####0.52 es mayor a 0.05 por ende no rechazo. ####0.05 es menor a 1.84 por ende no rechazo.
NE1 = 518
FE1 = StudentsPerformance[StudentsPerformance$gender=="female","writing score"]
meanE1 = (sum(FE1)/518)/100
sdE1 = sqrt(var(FE1))
sdE1
## writing score
## writing score 14.84484
##Hombres - p2
NE2 = 482
HME<-StudentsPerformance[StudentsPerformance$gender=="male","writing score"]
meanE2=(sum(HME)/482)/100
meanE2
## [1] 0.633112
sdE2=sqrt(var(HME))
sdE2
## writing score
## writing score 14.11383
DEE = sqrt((sdE1^2)/N1)+((sdE2^2/N2))
DEE
## writing score
## writing score 1.065523
pnorm(meanE1-meanE2,0,DEE, lower.tail = FALSE)
## [1] 0.4657613
####0.46 es mayor a 0.05 por ende no rechaza.
MEE = 0.96*DEE
MEE
## writing score
## writing score 1.022902
meanE1-meanE2
## [1] 0.09155978
####0.09 es menor a 1.02 por ende no rechazo. # Pruebas de lectura. -L1
NE1 = 518
FR1 = StudentsPerformance[StudentsPerformance$gender=="female","reading score"]
meanR1 = (sum(FR1)/518)/100
sdR1 = sqrt(var(FR1))
sdR1
## reading score
## reading score 14.37825
##Hombres - p2
NE2 = 482
HRE<-StudentsPerformance[StudentsPerformance$gender=="male","reading score"]
meanR2=(sum(HRE)/482)/100
meanR2
## [1] 0.6547303
sdR2=sqrt(var(HRE))
sdR2
## reading score
## reading score 13.93183
DER = sqrt((sdR1^2)/N1)+((sdR2^2/N2))
DER
## reading score
## reading score 1.034433
pnorm(meanR1-meanR2,0,DER, lower.tail = FALSE)
## [1] 0.4725044
####0.47 es mayor a 0.05 por ende no rechaza.
MER = 0.96*DER
MER
## reading score
## reading score 0.9930552
meanR1-meanR2
## [1] 0.07135079
####0.07 es menor a a 0.99 por ende no rechazo.
Muestra 1
ns= 645
means = 645/1000
####Muestra 2
nn = 642
meann = 642/1000
P = 0.648
Q = 1-P
Q
## [1] 0.352
D.E2 = sqrt(P*Q*(1/ns+1/nn))
D.E2
## [1] 0.02662568