Testing EdSurvey, WeMix, Dire, MICE and Other Important R packages with Sample Educational Research PART 3
# Loading Files
<- read.csv("C:/Users/nghimire/OneDrive - The University of Texas at Tyler/Redirected Folders/Documents/edsurvey_PISA_USA/teacher_data_final.csv",
teacher_final as.is = TRUE
)str(teacher_final)
'data.frame': 3526 obs. of 14 variables:
$ school_id : int 1 1 1 1 1 1 1 1 1 1 ...
$ teacher_id : int 593 3408 1829 471 2114 1269 1379 3595 2183 669 ...
$ gender : int 0 0 0 0 0 NA 1 1 0 0 ...
$ age : int 49 42 50 50 56 NA 45 31 55 48 ...
$ teacher_type : int 1 1 1 1 1 NA 0 1 1 1 ...
$ full_time : int 0 0 0 0 0 NA 0 0 0 0 ...
$ emp_stat : int 0 0 0 0 0 NA 0 0 0 0 ...
$ teaching_exp : int 20 12 21 26 29 NA 16 8 13 25 ...
$ teacher_edu : int 2 2 2 2 2 NA 2 2 2 1 ...
$ initial_qual : int 0 0 0 0 0 NA 0 0 0 0 ...
$ training : int 0 1 1 1 1 NA NA 1 1 1 ...
$ workshop : int 0 0 0 0 0 NA NA 0 0 1 ...
$ prof_dev : int 0 0 0 0 0 NA 0 0 0 0 ...
$ reading_score: num 510 510 510 510 510 ...
# summary(teacher_final)
<- read.csv("C:/Users/nghimire/OneDrive - The University of Texas at Tyler/Redirected Folders/Documents/edsurvey_PISA_USA/imputed_teacher_data.csv",
teacher_imputed as.is = TRUE
)str(teacher_imputed)
'data.frame': 3526 obs. of 14 variables:
$ school_id : int 1 1 1 1 1 1 1 1 1 1 ...
$ teacher_id : int 593 3408 1829 471 2114 1269 1379 3595 2183 669 ...
$ gender : int 0 0 0 0 0 1 1 1 0 0 ...
$ age : int 49 42 50 50 56 31 45 31 55 48 ...
$ teacher_type : int 1 1 1 1 1 0 0 1 1 1 ...
$ full_time : int 0 0 0 0 0 0 0 0 0 0 ...
$ emp_stat : int 0 0 0 0 0 0 0 0 0 0 ...
$ teaching_exp : int 20 12 21 26 29 9 16 8 13 25 ...
$ teacher_edu : int 2 2 2 2 2 1 2 2 2 1 ...
$ initial_qual : int 0 0 0 0 0 0 0 0 0 0 ...
$ training : int 0 1 1 1 1 0 0 1 1 1 ...
$ workshop : int 0 0 0 0 0 0 0 0 0 1 ...
$ prof_dev : int 0 0 0 0 0 0 0 0 0 0 ...
$ reading_score: num 510 510 510 510 510 ...
# Teacher Data
$teacher_id <- as.factor(teacher_final$teacher_id)
teacher_final$gender <- factor(teacher_final$gender, levels = c(0, 1), labels = c("Female", "Male"))
teacher_final$teacher_type <- factor(teacher_final$teacher_type, levels = c(0, 1), labels = c("Reading-Language Teacher", "General Teacher"))
teacher_final$full_time <- factor(teacher_final$full_time, levels = c(0, 1), labels = c("Full-Time", "Part-Time"))
teacher_final$emp_stat <- factor(teacher_final$emp_stat, levels = c(0, 1, 2, 3), labels = c("Full-Time", "Part-Time, 71-90% of Full-Time Hours", "Part-Time, 50-70% of Full-Time Hours", "Part-Time, less than 50% of Full-Time Hours"))
teacher_final$teacher_edu <- factor(teacher_final$teacher_edu, levels = c(0, 1, 2), labels = c("None. No Teacher Education", "Program of 1 Year or Less", "Yes, Program Longer than 1 Year"))
teacher_final$initial_qual <- factor(teacher_final$initial_qual, levels = c(0, 1, 2, 3, 4), labels = c("Pre-service: Strandard Teacher Training Program", "In-service: Teacher Training Program", "Work-Based Teacher Training", "Training on Another Pedagogical Profession", "Other"))
teacher_final$training <- factor(teacher_final$training, levels = c(0, 1), labels = c("Participated", "Didn't Participate"))
teacher_final$workshop <- factor(teacher_final$workshop, levels = c(0, 1), labels = c("Participated", "Didn't Participate"))
teacher_final$prof_dev <- factor(teacher_final$prof_dev, levels = c(0, 1), labels = c("Participated", "Didn't Participate"))
teacher_final
summary(teacher_final)
school_id teacher_id gender age
Min. : 1.00 1 : 1 Female:1784 Min. :20.00
1st Qu.: 47.00 2 : 1 Male :1019 1st Qu.:34.00
Median : 88.00 3 : 1 NA's : 723 Median :42.00
Mean : 88.29 4 : 1 Mean :42.87
3rd Qu.:131.00 5 : 1 3rd Qu.:51.00
Max. :175.00 6 : 1 Max. :70.00
(Other):3520 NA's :700
teacher_type full_time
Reading-Language Teacher:1049 Full-Time:2773
General Teacher :1812 Part-Time: 60
NA's : 665 NA's : 693
emp_stat teaching_exp
Full-Time :2773 Min. : 0.00
Part-Time, 71-90% of Full-Time Hours : 22 1st Qu.: 7.00
Part-Time, 50-70% of Full-Time Hours : 21 Median :14.00
Part-Time, less than 50% of Full-Time Hours: 17 Mean :14.95
NA's : 693 3rd Qu.:21.00
Max. :50.00
NA's :741
teacher_edu
None. No Teacher Education : 229
Program of 1 Year or Less : 577
Yes, Program Longer than 1 Year:2022
NA's : 698
initial_qual
Pre-service: Strandard Teacher Training Program:2303
In-service: Teacher Training Program : 113
Work-Based Teacher Training : 241
Training on Another Pedagogical Profession : 31
Other : 142
NA's : 696
training workshop prof_dev
Participated : 429 Participated :1637 Participated :2753
Didn't Participate:1311 Didn't Participate: 128 Didn't Participate: 51
NA's :1786 NA's :1761 NA's : 722
reading_score
Min. :260.3
1st Qu.:468.2
Median :502.7
Mean :505.1
3rd Qu.:537.1
Max. :608.0
# Imputed Data
$teacher_id <- as.factor(teacher_imputed$teacher_id)
teacher_imputed$gender <- factor(teacher_imputed$gender, levels = c(0, 1), labels = c("Female", "Male"))
teacher_imputed$teacher_type <- factor(teacher_imputed$teacher_type, levels = c(0, 1), labels = c("Reading-Language Teacher", "General Teacher"))
teacher_imputed$full_time <- factor(teacher_imputed$full_time, levels = c(0, 1), labels = c("Full-Time", "Part-Time"))
teacher_imputed$emp_stat <- factor(teacher_imputed$emp_stat, levels = c(0, 1, 2, 3), labels = c("Full-Time", "Part-Time, 71-90% of Full-Time Hours", "Part-Time, 50-70% of Full-Time Hours", "Part-Time, less than 50% of Full-Time Hours"))
teacher_imputed$teacher_edu <- factor(teacher_imputed$teacher_edu, levels = c(0, 1, 2), labels = c("None. No Teacher Education", "Program of 1 Year or Less", "Yes, Program Longer than 1 Year"))
teacher_imputed$initial_qual <- factor(teacher_imputed$initial_qual, levels = c(0, 1, 2, 3, 4), labels = c("Pre-service: Strandard Teacher Training Program", "In-service: Teacher Training Program", "Work-Based Teacher Training", "Training on Another Pedagogical Profession", "Other"))
teacher_imputed$training <- factor(teacher_imputed$training, levels = c(0, 1), labels = c("Participated", "Didn't Participate"))
teacher_imputed$workshop <- factor(teacher_imputed$workshop, levels = c(0, 1), labels = c("Participated", "Didn't Participate"))
teacher_imputed$prof_dev <- factor(teacher_imputed$prof_dev, levels = c(0, 1), labels = c("Participated", "Didn't Participate"))
teacher_imputed
summary(teacher_imputed)
school_id teacher_id gender age
Min. : 1.00 1 : 1 Female:2217 Min. :20.00
1st Qu.: 47.00 2 : 1 Male :1309 1st Qu.:34.00
Median : 88.00 3 : 1 Median :42.00
Mean : 88.29 4 : 1 Mean :42.82
3rd Qu.:131.00 5 : 1 3rd Qu.:51.00
Max. :175.00 6 : 1 Max. :70.00
(Other):3520
teacher_type full_time
Reading-Language Teacher:1325 Full-Time:3457
General Teacher :2201 Part-Time: 69
emp_stat teaching_exp
Full-Time :3457 Min. : 0.00
Part-Time, 71-90% of Full-Time Hours : 26 1st Qu.: 7.00
Part-Time, 50-70% of Full-Time Hours : 25 Median :14.00
Part-Time, less than 50% of Full-Time Hours: 18 Mean :14.73
3rd Qu.:21.00
Max. :50.00
teacher_edu
None. No Teacher Education : 305
Program of 1 Year or Less : 736
Yes, Program Longer than 1 Year:2485
initial_qual
Pre-service: Strandard Teacher Training Program:2838
In-service: Teacher Training Program : 148
Work-Based Teacher Training : 316
Training on Another Pedagogical Profession : 37
Other : 187
training workshop prof_dev
Participated : 850 Participated :3287 Participated :3466
Didn't Participate:2676 Didn't Participate: 239 Didn't Participate: 60
reading_score
Min. :260.3
1st Qu.:468.2
Median :502.7
Mean :505.1
3rd Qu.:537.1
Max. :608.0
Various Teachers’ Characteristics and Students’ Reading Score
a. Teacher Education
|>
teacher_final na.omit() |>
group_by(teacher_edu) |>
summarise(
M_EAN = mean(reading_score),
S_D = sd(reading_score),
total_teacher = n()
)
# A tibble: 3 × 4
teacher_edu M_EAN S_D total_teacher
<fct> <dbl> <dbl> <int>
1 None. No Teacher Education 492. 55.0 144
2 Program of 1 Year or Less 506. 48.9 334
3 Yes, Program Longer than 1 Year 507. 45.7 1197
b. Teachers’ Gender
|>
teacher_final na.omit() |>
group_by(gender) |>
summarise(
M_EAN = mean(reading_score),
S_D = sd(reading_score),
total_teacher = n()
)
# A tibble: 2 × 4
gender M_EAN S_D total_teacher
<fct> <dbl> <dbl> <int>
1 Female 504. 49.3 949
2 Male 507. 44.8 726
c. Teacher Type
|>
teacher_imputed na.omit() |>
group_by(teacher_type) |>
summarise(
M_EAN = mean(reading_score),
S_D = sd(reading_score),
total_teacher = n()
)
# A tibble: 2 × 4
teacher_type M_EAN S_D total_teacher
<fct> <dbl> <dbl> <int>
1 Reading-Language Teacher 507. 49.2 1325
2 General Teacher 504. 49.0 2201
d. Teaching Status
|>
teacher_final na.omit() |>
group_by(full_time) |>
summarise(
M_EAN = mean(reading_score),
S_D = sd(reading_score),
total_teacher = n()
)
# A tibble: 2 × 4
full_time M_EAN S_D total_teacher
<fct> <dbl> <dbl> <int>
1 Full-Time 505. 47.0 1635
2 Part-Time 536. 51.5 40
e. Teaching Status Imputed Data
|>
teacher_imputed group_by(full_time) |>
summarise(
M_EAN = mean(reading_score),
S_D = sd(reading_score),
total_teacher = n()
)
# A tibble: 2 × 4
full_time M_EAN S_D total_teacher
<fct> <dbl> <dbl> <int>
1 Full-Time 504. 48.9 3457
2 Part-Time 536. 47.3 69
f. Employment Status
|>
teacher_final na.omit() |>
group_by(emp_stat) |>
summarise(
M_EAN = mean(reading_score),
S_D = sd(reading_score),
total_teacher = n()
)
# A tibble: 4 × 4
emp_stat M_EAN S_D total_teacher
<fct> <dbl> <dbl> <int>
1 Full-Time 505. 47.0 1635
2 Part-Time, 71-90% of Full-Time Hours 546. 39.0 11
3 Part-Time, 50-70% of Full-Time Hours 540. 58.3 15
4 Part-Time, less than 50% of Full-Time Hours 523. 53.4 14
g. Initial Qualification
|>
teacher_final na.omit() |>
group_by(initial_qual) |>
summarise(
M_EAN = mean(reading_score),
S_D = sd(reading_score),
total_teacher = n()
)
# A tibble: 5 × 4
initial_qual M_EAN S_D total_teacher
<fct> <dbl> <dbl> <int>
1 Pre-service: Strandard Teacher Training Program 507. 46.8 1348
2 In-service: Teacher Training Program 498. 53.1 80
3 Work-Based Teacher Training 497. 50.1 145
4 Training on Another Pedagogical Profession 483. 39.6 22
5 Other 500. 44.9 80
g. Teacher Training Opportunities in Last 12-Months’ Period
|>
teacher_final na.omit() |>
group_by(training) |>
summarise(
M_EAN = mean(reading_score),
S_D = sd(reading_score),
total_teacher = n()
)
# A tibble: 2 × 4
training M_EAN S_D total_teacher
<fct> <dbl> <dbl> <int>
1 Participated 503. 46.4 405
2 Didn't Participate 506. 47.7 1270
h. Workshop Opportunities in Last 12-Months’ Period
|>
teacher_final na.omit() |>
group_by(workshop) |>
summarise(
M_EAN = mean(reading_score),
S_D = sd(reading_score),
total_teacher = n()
)
# A tibble: 2 × 4
workshop M_EAN S_D total_teacher
<fct> <dbl> <dbl> <int>
1 Participated 505. 46.7 1552
2 Didn't Participate 504. 54.9 123
i. Professional Development Opportunity in Last 12-Months’ Period
|>
teacher_final na.omit() |>
group_by(prof_dev) |>
summarise(
M_EAN = mean(reading_score),
S_D = sd(reading_score),
total_teacher = n()
)
# A tibble: 2 × 4
prof_dev M_EAN S_D total_teacher
<fct> <dbl> <dbl> <int>
1 Participated 505. 47.0 1644
2 Didn't Participate 519. 64.8 31
Teacher Education and Students’ Reading Scores
<- teacher_imputed |>
teacher_edu_density ggplot(aes(x = reorder(teacher_edu, reading_score), y = reading_score)) +
geom_boxplot(fill = "white", colour = "blue", varwidth = TRUE) +
geom_hline(yintercept = 505, label = "National Average", hjust = 1, vjust = 0.5, size = .3) +
labs(
title = "Comparative Reading Scores Based on Teachers' Education",
x = "Teacher Education",
y = "Reading Scores"
+
) geom_text(
label = "National Average",
x = 1.4, y = 370,
family = "serif",
size = 2.3
+
) geom_segment(aes(x = 1.4, y = 400, xend = 1.4, yend = 500),
linewidth = 0.06,
arrow = arrow(length = unit(.05, "cm"))
+
) theme(legend.position = "none") +
coord_flip() +
theme_classic()
teacher_edu_density
# ggsave("teacher_education_vs_reading_scores.tiff", units="in", width=6.5, height=4, #dpi=300, compression = 'lzw')
Teacher Type, Teaching Experience, and Students’ Readign Scores
library(dendextend)
<- subset(teacher_imputed, teacher_type == "Reading-Language Teacher")
english_teacher # head(english_teacher)
<- subset(teacher_imputed, teacher_type == "General Teacher")
general_teacher # head(general_teacher)
<- ggplot(
et_box
teacher_imputed,aes(teacher_type, reading_score)
+
) geom_boxplot(alpha = 0.5, width = 0.3) +
stat_summary(fun = mean, size = 2, geom = "point") +
stat_summary(
fun = mean, geom = "text", vjust = -0.6,
aes(label = paste(round(..y.., digits = 2)))
+
) scale_x_discrete(labels = c("Reading Teacher", "General Teacher")) +
::theme_classic2()
ggpubr# et_box
library(geomtextpath)
<- ggplot(
te_scat
teacher_imputed,aes(x = reading_score, y = teaching_exp, color = teacher_type, label = teacher_type)
+
) geom_labelsmooth(method = "lm", boxlinewidth = 0) +
labs(
title = "",
x = "Reading Scores",
y = "Teaching Experience"
+
) theme_classic() +
theme(legend.position = "none")
# Putting Plots Together
<- ggpubr::ggarrange(et_box, te_scat,
comined_plot ncol = 2, align = "h",
common.legend = FALSE
) comined_plot
# ggsave("teacher_type_experience_reading_scores.tiff", units="in", width=6.5, height=4, #dpi=300, compression = 'lzw')
Hierarchical Linear Models
Null Models
<- nlme::gls(reading_score ~ 1, data = teacher_final, method = "ML")
hlm_null
<- nlme::lme(reading_score ~ 1, data = teacher_imputed, random = ~ 1 | school_id, method = "ML")
hlm_null_intercept
anova(hlm_null, hlm_null_intercept)
Model df AIC BIC logLik Test L.Ratio
hlm_null 1 2 37461.77 37474.11 -18728.88
hlm_null_intercept 2 3 -183939.50 -183921.00 91972.75 1 vs 2 221403.3
p-value
hlm_null
hlm_null_intercept <.0001
Null Model with Imputed Data
<- nlme::gls(reading_score ~ 1, data = teacher_imputed, method = "ML")
hlm_null_1
summary(hlm_null_1)
Generalized least squares fit by maximum likelihood
Model: reading_score ~ 1
Data: teacher_imputed
AIC BIC logLik
37461.77 37474.11 -18728.88
Coefficients:
Value Std.Error t-value p-value
(Intercept) 505.0998 0.8260463 611.4666 0
Standardized residuals:
Min Q1 Med Q3 Max
-4.9921366 -0.7526429 -0.0486434 0.6515983 2.0980977
Residual standard error: 49.04378
Degrees of freedom: 3526 total; 3525 residual
Null Model with Random Intercept
<- nlme::lme(reading_score ~ 1, data = teacher_imputed, random = ~ 1 | school_id, method = "ML")
hlm_null_1_intercept
summary(hlm_null_1_intercept)
Linear mixed-effects model fit by maximum likelihood
Data: teacher_imputed
AIC BIC logLik
-183939.5 -183921 91972.75
Random effects:
Formula: ~1 | school_id
(Intercept) Residual
StdDev: 410.8049 2.195108e-13
Fixed effects: reading_score ~ 1
Value Std.Error DF t-value p-value
(Intercept) 94.52194 5.924571 3368 15.95422 0
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-2.58955 -1.03582 0.00000 1.03582 2.58955
Number of Observations: 3526
Number of Groups: 158
Model Comparison
anova(hlm_null_1, hlm_null_1_intercept)
Model df AIC BIC logLik Test L.Ratio
hlm_null_1 1 2 37461.77 37474.11 -18728.88
hlm_null_1_intercept 2 3 -183939.50 -183921.00 91972.75 1 vs 2 221403.3
p-value
hlm_null_1
hlm_null_1_intercept <.0001
Teacher Null
<- nlme::gls(reading_score ~ 1, data = teacher_imputed, method = "ML")
teacher_null summary(teacher_null)
Generalized least squares fit by maximum likelihood
Model: reading_score ~ 1
Data: teacher_imputed
AIC BIC logLik
37461.77 37474.11 -18728.88
Coefficients:
Value Std.Error t-value p-value
(Intercept) 505.0998 0.8260463 611.4666 0
Standardized residuals:
Min Q1 Med Q3 Max
-4.9921366 -0.7526429 -0.0486434 0.6515983 2.0980977
Residual standard error: 49.04378
Degrees of freedom: 3526 total; 3525 residual
<- nlme::lme(reading_score ~ 1, data = teacher_imputed, random = ~ 1 | teacher_id, method = "ML")
teacher_null_rintercept summary(teacher_null_rintercept)
Linear mixed-effects model fit by maximum likelihood
Data: teacher_imputed
AIC BIC logLik
37463.77 37482.27 -18728.88
Random effects:
Formula: ~1 | teacher_id
(Intercept) Residual
StdDev: 45.92112 17.22042
Fixed effects: reading_score ~ 1
Value Std.Error DF t-value p-value
(Intercept) 505.0998 0.8260463 3526 611.4666 0
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-1.75285618 -0.26427058 -0.01707984 0.22879143 0.73669128
Number of Observations: 3526
Number of Groups: 3526
anova(teacher_null, teacher_null_rintercept)
Model df AIC BIC logLik Test
teacher_null 1 2 37461.77 37474.11 -18728.88
teacher_null_rintercept 2 3 37463.77 37482.27 -18728.88 1 vs 2
L.Ratio p-value
teacher_null
teacher_null_rintercept 2.910383e-11 1
HLM Full
{r hlm_gender}
hlm_full <- lmer(reading_score ~ gender + age + teacher_type + full_time + teaching_exp + teacher_edu + initial_qual + training + workshop + prof_dev + (gender + age + teacher_type + full_time + teaching_exp + teacher_edu + initial_qual + training + workshop + prof_dev| school_id), data = teacher_imputed)
summary(hlm_full)
#effectsize::standardize_parameters(hlm_full, method = "pseudo")
#confint(hlm_full)
Quantile Regression for Visualiztion
library(quantreg)
<- rq(formula = reading_score ~ teaching_exp, tau = c(.05, .25, .50, .75, .95), data = teacher_imputed, method = "fn")
quant_1 summary(quant_1, se = "nid")
Call: rq(formula = reading_score ~ teaching_exp, tau = c(0.05, 0.25,
0.5, 0.75, 0.95), data = teacher_imputed, method = "fn")
tau: [1] 0.05
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 424.04053 2.18066 194.45492 0.00000
teaching_exp 0.44547 0.11647 3.82486 0.00013
Call: rq(formula = reading_score ~ teaching_exp, tau = c(0.05, 0.25,
0.5, 0.75, 0.95), data = teacher_imputed, method = "fn")
tau: [1] 0.25
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 461.07650 2.04513 225.45113 0.00000
teaching_exp 0.57290 0.14809 3.86867 0.00011
Call: rq(formula = reading_score ~ teaching_exp, tau = c(0.05, 0.25,
0.5, 0.75, 0.95), data = teacher_imputed, method = "fn")
tau: [1] 0.5
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 498.88172 1.47120 339.09852 0.00000
teaching_exp 0.34250 0.09786 3.50003 0.00047
Call: rq(formula = reading_score ~ teaching_exp, tau = c(0.05, 0.25,
0.5, 0.75, 0.95), data = teacher_imputed, method = "fn")
tau: [1] 0.75
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 531.30341 1.60117 331.82253 0.00000
teaching_exp 0.43676 0.13088 3.33706 0.00086
Call: rq(formula = reading_score ~ teaching_exp, tau = c(0.05, 0.25,
0.5, 0.75, 0.95), data = teacher_imputed, method = "fn")
tau: [1] 0.95
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 575.74579 3.23678 177.87625 0.00000
teaching_exp 0.55283 0.09599 5.75935 0.00000
# Plotting the Output and Saving as .pdf
pdf("teaching_experience_readin_score.pdf", width = 6.5, height = 7)
plot(quant_1)
dev.off()
png
2
“nid” for SE are computed using the Hall-Sheather bandwidth rule. We can use “ker” instead, if we want Powell kernel version, “boot” for bootstrap, etc. (visit: https://cran.r-project.org/web/packages/quantreg/vignettes/rq.pdf)
$reading_score <- as.numeric(as.factor(teacher_imputed$reading_score))
teacher_imputed$teaching_exp <- as.numeric(as.factor(teacher_imputed$teaching_exp))
teacher_imputedattach(teacher_imputed)
png("quantile_experience_vs_reading_scores.png")
plot(reading_score, teaching_exp, xlab = "Students' Reading Scores", ylab = "Teacher Experience in Years", type = "n", xaxt = "n")
<- c(.1, .25, .75, .95)
tau_s
abline(rq(log10(reading_score) ~ log10(teaching_exp), tau = .5), col = "blue")
abline(lm(log10(reading_score) ~ log10(teaching_exp), lty = 3), col = "red")
for (i in 1:length(tau_s)) {
abline(rq(log10(reading_score) ~ log10(teaching_exp), tau = tau_s[i]), col = "gray")
}
dev.off()
png
2
Age and Students’ Reading Scores
<- rq(formula = reading_score ~ age, tau = c(0.05, .25, .50, .75, 0.95), data = teacher_imputed, method = "fn")
quant_3 summary(quant_3)
Call: rq(formula = reading_score ~ age, tau = c(0.05, 0.25, 0.5, 0.75,
0.95), data = teacher_imputed, method = "fn")
tau: [1] 0.05
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 6.14286 2.43443 2.52333 0.01167
age 0.11429 0.05760 1.98425 0.04731
Call: rq(formula = reading_score ~ age, tau = c(0.05, 0.25, 0.5, 0.75,
0.95), data = teacher_imputed, method = "fn")
tau: [1] 0.25
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 40.82143 4.33812 9.40994 0.00000
age 0.03571 0.09872 0.36177 0.71755
Call: rq(formula = reading_score ~ age, tau = c(0.05, 0.25, 0.5, 0.75,
0.95), data = teacher_imputed, method = "fn")
tau: [1] 0.5
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 79.28571 4.93394 16.06944 0.00000
age 0.07143 0.11427 0.62506 0.53197
Call: rq(formula = reading_score ~ age, tau = c(0.05, 0.25, 0.5, 0.75,
0.95), data = teacher_imputed, method = "fn")
tau: [1] 0.75
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 111.65217 4.26656 26.16913 0.00000
age 0.21739 0.09644 2.25425 0.02424
Call: rq(formula = reading_score ~ age, tau = c(0.05, 0.25, 0.5, 0.75,
0.95), data = teacher_imputed, method = "fn")
tau: [1] 0.95
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 144.23077 2.06996 69.67806 0.00000
age 0.15385 0.04276 3.59797 0.00033
plot(quant_3)
# Plotting the Output and Saving as .pdf
pdf("age_reading_score.pdf", width = 6.5, height = 7)
plot(quant_3)
dev.off()
png
2
Age and Teacher Experience
<- rq(formula = age ~ teaching_exp, tau = c(.1, .25, 0.5, .75, .95), data = teacher_imputed)
quant_4 summary(quant_4)
Call: rq(formula = age ~ teaching_exp, tau = c(0.1, 0.25, 0.5, 0.75,
0.95), data = teacher_imputed)
tau: [1] 0.1
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 20.00000 0.21461 93.19064 0.00000
teaching_exp 1.00000 0.01168 85.63326 0.00000
Call: rq(formula = age ~ teaching_exp, tau = c(0.1, 0.25, 0.5, 0.75,
0.95), data = teacher_imputed)
tau: [1] 0.25
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 22.00000 0.15928 138.12062 0.00000
teaching_exp 1.00000 0.00867 115.38145 0.00000
Call: rq(formula = age ~ teaching_exp, tau = c(0.1, 0.25, 0.5, 0.75,
0.95), data = teacher_imputed)
tau: [1] 0.5
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 25.38095 0.27053 93.82019 0.00000
teaching_exp 0.95238 0.01257 75.76389 0.00000
Call: rq(formula = age ~ teaching_exp, tau = c(0.1, 0.25, 0.5, 0.75,
0.95), data = teacher_imputed)
tau: [1] 0.75
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 33.33333 0.54053 61.66837 0.00000
teaching_exp 0.83333 0.02270 36.70662 0.00000
Call: rq(formula = age ~ teaching_exp, tau = c(0.1, 0.25, 0.5, 0.75,
0.95), data = teacher_imputed)
tau: [1] 0.95
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 50.50000 0.70267 71.86861 0.00000
teaching_exp 0.50000 0.02896 17.26674 0.00000
# Plotting the Output and Saving as .pdf
plot(quant_4)
Reading Scores Description
# (3526) reading scores
|>
teacher_final summarise(
M_EAN = mean(reading_score),
S_D = sd(reading_score),
total_teacher = n()
)
M_EAN S_D total_teacher
1 505.0998 49.05074 3526
# (1675 teachers)
|>
teacher_final na.omit() |>
summarise(
M_EAN = mean(age),
S_D = sd(age),
total_teacher = n()
)
M_EAN S_D total_teacher
1 43.65313 11.16418 1675
# (1675 teachers)
|>
teacher_final na.omit() |>
summarise(
M_EAN = mean(teaching_exp),
S_D = sd(teaching_exp),
total_teacher = n()
)
M_EAN S_D total_teacher
1 15.32896 9.588603 1675
Comments
Post a Comment