library(psych)
library(haven)
library(dplyr)
library(ggplot2)
library(sjPlot)
library(RColorBrewer)
library(grid)
library(gridExtra)
library(lattice)
dbp <- read_sav("C:/Users/ASUS/Downloads/SchoolChoice_dataclean_withisei_06172019.sav")
db1 <- dbp %>%
select ("schtype", "q19", "q21", "q24", "momedu", "fathedu", "q39", "q40", "q41", "q42", "ISEI_08_mom", "ISEI_08_dad")
db2 <- dbp %>%
select ("momedu", "fathedu", "ISEI_08_mom", "ISEI_08_dad", "q27.1", "q27.10", "q27.3")
db1$schtype <- as.factor(db1$schtype)
db1$q19[db1$q19 == "1"] <- "да"
db1$q19[db1$q19 == "2"] <- "нет"
db1$q19 <- as.factor(db1$q19)
db1$q21[db1$q21 == "1"] <- "да"
db1$q21[db1$q21 == "2"] <- "нет"
db1$q21[db1$q21 == "3"] <- NA
db1$q21 <- as.factor(db1$q21)
db1$q24[db1$q24 == "1"] <- "да"
db1$q24[db1$q24 == "0"] <- "нет"
db1$q24[db1$q24 == "4"] <- NA
db1$q24 <- as.factor(db1$q24)
db1$fathedu[db1$fathedu == "1" |
db1$fathedu == "2"] <- "1 - НП"
db1$fathedu[db1$fathedu == "3"] <- "2 - СП"
db1$fathedu[db1$fathedu == "4"] <- "3 - ВО"
db1$fathedu <- as.factor(db1$fathedu)
db1$momedu[db1$momedu == "1" |
db1$momedu == "2"] <- "1 - НП"
db1$momedu[db1$momedu == "3"] <- "2 - СП"
db1$momedu[db1$momedu == "4"] <- "3 - ВО"
db1$momedu <- as.factor(db1$momedu)
db2$fathedu[db2$fathedu == "1" |
db2$fathedu == "2"] <- "1 - НП"
db2$fathedu[db2$fathedu == "3"] <- "2 - СП"
db2$fathedu[db2$fathedu == "4"] <- "3 - ВО"
db2$fathedu <- as.factor(db2$fathedu)
db2$momedu[db2$momedu == "1" |
db2$momedu == "2"] <- "1 - НП"
db2$momedu[db2$momedu == "3"] <- "2 - СП"
db2$momedu[db2$momedu == "4"] <- "3 - ВО"
db2$momedu <- as.factor(db2$momedu)
db1$q41[db1$q41 == "1" |
db1$q41 == "2"] <- "1 полка и меньше (<40 книг)"
db1$q41[db1$q41 == "3" |
db1$q41 == "4"] <- "2-3 полки (60-120 книг)"
db1$q41[db1$q41 == "5" ] <- "4-5 полок (120-200 книг)"
db1$q41[db1$q41 == "6" ] <- "6 и больше полок (>200 книг)"
db1$q41 <- as.factor(db1$q41)
db1$q42[db1$q42 == "2" |
db1$q42 == "3"|
db1$q42 == "5"] <- "Не знаю"
db1$q42[db1$q42 == "1"] <- "Да"
db1$q42[db1$q42 == "4"] <- "Нет"
db1$q42 <- as.factor(db1$q42)
db2$q27.1[db2$q27.1 == "1" |
db2$q27.1 == "2" |
db2$q27.1 == "3"] <- "Важно"
db2$q27.1[db2$q27.1 == "0"] <- "Нет"
db2$q27.3[db2$q27.3 == "1" |
db2$q27.3 == "2" |
db2$q27.3 == "3"] <- "Важно"
db2$q27.3[db2$q27.3 == "0"] <- "Нет"
db2$q27.10[db2$q27.10 == "1" |
db2$q27.10 == "2" |
db2$q27.10 == "3"] <- "Важно"
db2$q27.10[db2$q27.10 == "0"] <- "Нет"
Процентное соотношение в табличке. Статистической разницы нет.
t_momedu_271 <- with(db2, table(momedu, q27.1))
prop.table(t_momedu_271) %>% {. * 100} %>%
round(2)
## q27.1
## momedu Важно Нет
## 1 - НП 1.91 7.14
## 2 - СП 4.40 15.36
## 3 - ВО 17.86 53.33
chi_momedu_271 <- chisq.test(t_momedu_271)
chi_momedu_271
##
## Pearson's Chi-squared test
##
## data: t_momedu_271
## X-squared = 2.4189, df = 2, p-value = 0.2984
chi_momedu_271$stdres
## q27.1
## momedu Важно Нет
## 1 - НП -1.028502 1.028502
## 2 - СП -0.991216 0.991216
## 3 - ВО 1.523090 -1.523090
t_fathedu_271 <- with(db2, table(fathedu, q27.1))
prop.table(t_fathedu_271) %>% {. * 100} %>%
round(2)
## q27.1
## fathedu Важно Нет
## 1 - НП 2.85 10.32
## 2 - СП 6.40 20.33
## 3 - ВО 15.04 45.07
chi_fathedu_271 <- chisq.test(t_fathedu_271)
chi_fathedu_271
##
## Pearson's Chi-squared test
##
## data: t_fathedu_271
## X-squared = 1.3789, df = 2, p-value = 0.5018
chi_fathedu_271$stdres
## q27.1
## fathedu Важно Нет
## 1 - НП -1.0740681 1.0740681
## 2 - СП -0.2088363 0.2088363
## 3 - ВО 0.9302604 -0.9302604
Процентное соотношение в табличке. Статистическая разница ЕСТЬ :
** родители с высшим образованием считают важным баллые ЕГЭ**, родители с образованием ниже - баллы за ЕГЭ не считают важным критерием.
t_momedu_273 <- with(db2, table(momedu, q27.3))
prop.table(t_momedu_273) %>% {. * 100} %>%
round(2)
## q27.3
## momedu Важно Нет
## 1 - НП 1.13 7.93
## 2 - СП 2.94 16.83
## 3 - ВО 17.66 53.52
chi_momedu_273 <- chisq.test(t_momedu_273)
chi_momedu_273
##
## Pearson's Chi-squared test
##
## data: t_momedu_273
## X-squared = 28.77, df = 2, p-value = 5.659e-07
chi_momedu_273$stdres
## q27.3
## momedu Важно Нет
## 1 - НП -3.213045 3.213045
## 2 - СП -3.738824 3.738824
## 3 - ВО 5.322862 -5.322862
t_fathedu_273 <- with(db2, table(fathedu, q27.3))
prop.table(t_fathedu_273) %>% {. * 100} %>%
round(2)
## q27.3
## fathedu Важно Нет
## 1 - НП 1.93 11.23
## 2 - СП 4.78 21.95
## 3 - ВО 15.55 44.56
chi_fathedu_273 <- chisq.test(t_fathedu_273)
chi_fathedu_273
##
## Pearson's Chi-squared test
##
## data: t_fathedu_273
## X-squared = 23.368, df = 2, p-value = 8.426e-06
chi_fathedu_273$stdres
## q27.3
## fathedu Важно Нет
## 1 - НП -3.148823 3.148823
## 2 - СП -2.824697 2.824697
## 3 - ВО 4.726732 -4.726732
Процентное соотношение в табличке. Статистической разницы нет для образования мамы и ЕСТЬ по образованию отца :
в семьях, где у ОТЦА есть ВЫСШЕЕ ОБРАЗОВАНИЕ близость к дому НЕ считают важным критерием
t_momedu_2710 <- with(db2, table(momedu, q27.10))
prop.table(t_momedu_2710) %>% {. * 100} %>%
round(2)
## q27.10
## momedu Важно Нет
## 1 - НП 5.97 3.08
## 2 - СП 13.11 6.65
## 3 - ВО 44.52 26.66
chi_momedu_2710 <- chisq.test(t_momedu_2710)
chi_momedu_2710
##
## Pearson's Chi-squared test
##
## data: t_momedu_2710
## X-squared = 2.449, df = 2, p-value = 0.2939
chi_momedu_2710$stdres
## q27.10
## momedu Важно Нет
## 1 - НП 0.6951562 -0.6951562
## 2 - СП 1.2759227 -1.2759227
## 3 - ВО -1.5622548 1.5622548
t_fathedu_2710 <- with(db2, table(fathedu, q27.10))
prop.table(t_fathedu_2710) %>% {. * 100} %>%
round(2)
## q27.10
## fathedu Важно Нет
## 1 - НП 8.89 4.27
## 2 - СП 17.84 8.89
## 3 - ВО 36.79 23.32
chi_fathedu_2710 <- chisq.test(t_fathedu_2710)
chi_fathedu_2710
##
## Pearson's Chi-squared test
##
## data: t_fathedu_2710
## X-squared = 6.917, df = 2, p-value = 0.03148
chi_fathedu_2710$stdres
## q27.10
## fathedu Важно Нет
## 1 - НП 1.453431 -1.453431
## 2 - СП 1.788737 -1.788737
## 3 - ВО -2.620004 2.620004
Статистической разницы нет . Различия в средних значениях:
t.test(db2$ISEI_08_mom ~ db2$q27.1)
##
## Welch Two Sample t-test
##
## data: db2$ISEI_08_mom by db2$q27.1
## t = 1.0331, df = 599.92, p-value = 0.302
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.7132936 2.2965950
## sample estimates:
## mean in group Важно mean in group Нет
## 51.12209 50.33044
t.test(db2$ISEI_08_dad ~ db2$q27.1)
##
## Welch Two Sample t-test
##
## data: db2$ISEI_08_dad by db2$q27.1
## t = 1.1017, df = 626.44, p-value = 0.271
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.6907956 2.4565326
## sample estimates:
## mean in group Важно mean in group Нет
## 52.17647 51.29360
db2 <- na.omit(db2)
Визуализация:
g11 <- ggplot(db2, aes(x = q27.1, y = ISEI_08_mom, fill = q27.1)) +
geom_boxplot() +
labs(y="Социально-профессиональный статус", x = "Важен ли статус школы",
title="СПС матери") +
theme_bw() +
theme(legend.position = "none", axis.text = element_text(size=13)) +
scale_fill_manual(values=c("mistyrose", "palevioletred3"))
g12 <- ggplot(db2, aes(x = q27.1, y = ISEI_08_dad, fill = q27.1)) +
geom_boxplot() +
labs(y="", x = "Важен ли статус школы",
title="СПС отца") +
theme_bw() +
theme(legend.position = "none", axis.text = element_text(size=11)) +
scale_fill_manual(values=c("lightblue1", "lightskyblue3"))
gg1 <- grid.arrange(g11, g12, ncol=2, top = textGrob("Важность статуса школы",gp=gpar(fontsize=17)))
Статистическая разница есть:
t.test(db2$ISEI_08_mom ~ db2$q27.3)
##
## Welch Two Sample t-test
##
## data: db2$ISEI_08_mom by db2$q27.3
## t = 2.3852, df = 476.92, p-value = 0.01746
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.3606068 3.7331308
## sample estimates:
## mean in group Важно mean in group Нет
## 52.68070 50.63383
t.test(db2$ISEI_08_dad ~ db2$q27.3)
##
## Welch Two Sample t-test
##
## data: db2$ISEI_08_dad by db2$q27.3
## t = 4.1891, df = 484.66, p-value = 3.328e-05
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 1.957180 5.415043
## sample estimates:
## mean in group Важно mean in group Нет
## 54.36491 50.67880
Визуализация:
g21 <- ggplot(db2, aes(x = q27.3, y = ISEI_08_mom, fill = q27.3)) +
geom_boxplot() +
labs(y="Социально-профессиональный статус", x = "Важны ли баллы ЕГЭ",
title="СПС матери") +
theme_bw() +
theme(legend.position = "none", axis.text = element_text(size=13)) +
scale_fill_manual(values=c("mistyrose", "palevioletred3"))
g22 <- ggplot(db2, aes(x = q27.3, y = ISEI_08_dad, fill = q27.3)) +
geom_boxplot() +
labs(y="", x = "Важны ли баллы ЕГЭ",
title="СПС отца") +
theme_bw() +
theme(legend.position = "none", axis.text = element_text(size=11)) +
scale_fill_manual(values=c("lightblue1", "lightskyblue3"))
gg2 <-grid.arrange(g21, g22, ncol=2, top = textGrob("Важность баллов ЕГЭ",gp=gpar(fontsize=17)))
Статистическая разница есть:
t.test(db2$ISEI_08_mom ~ db2$q27.10)
##
## Welch Two Sample t-test
##
## data: db2$ISEI_08_mom by db2$q27.10
## t = -1.6316, df = 925.01, p-value = 0.1031
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -2.7407026 0.2523717
## sample estimates:
## mean in group Важно mean in group Нет
## 50.65718 51.90135
t.test(db2$ISEI_08_dad ~ db2$q27.10)
##
## Welch Two Sample t-test
##
## data: db2$ISEI_08_dad by db2$q27.10
## t = -2.8494, df = 957.13, p-value = 0.004474
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -3.7670239 -0.6943897
## sample estimates:
## mean in group Важно mean in group Нет
## 50.72445 52.95516
Визуализация:
g31 <- ggplot(db2, aes(x = q27.10, y = ISEI_08_mom, fill = q27.10)) +
geom_boxplot() +
labs(y="Социально-профессиональный статус", x = "Важна ли близость школы к дому",
title="СПС матери") +
theme_bw() +
theme(legend.position = "none", axis.text = element_text(size=13)) +
scale_fill_manual(values=c("mistyrose", "palevioletred3"))
g32 <- ggplot(db2, aes(x = q27.10, y = ISEI_08_dad, fill = q27.10)) +
geom_boxplot() +
labs(y="", x = "Важна ли близость школы к дому",
title="СПС отца") +
theme_bw() +
theme(legend.position = "none", axis.text = element_text(size=11)) +
scale_fill_manual(values=c("lightblue1", "lightskyblue3"))
gg3 <- grid.arrange(g31, g32, ncol=2, top = textGrob("Важность близости школы к дом",gp=gpar(fontsize=17)))
grid.arrange(gg1, gg2, gg3, ncol=3)