-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnalysis1.Rmd
More file actions
331 lines (232 loc) · 11.1 KB
/
Analysis1.Rmd
File metadata and controls
331 lines (232 loc) · 11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
---
title: "Analysis 1- Comparing transition to middle school"
author: "Arun Sharma"
date: "1/1/2020"
output:
html_document:
theme: paper
highlight: tango
toc: true
toc_depth: 5
---
```{r global_options, include=FALSE, fig.width = 10}
knitr::opts_chunk$set(warning=FALSE, message=FALSE)
```
```{r}
library(tidyverse)
library(ggplot2)
library(sqldf)
```
# Estimatng the growth pattern amongst students into the middle school
## Imports
```{r}
rm(list=ls())
library(data.table)
#getting the data for the year 2017-18
Fall1718 <- fread("2018_NWEA/NWEA Fall 2017-hashed.csv")
Winter1718 <- fread("2018_NWEA/NWEA_Winter_2017-2018-hashed.csv")
Spring1718 <- fread("2018_NWEA/NWEA_Spring_2017-2018-hashed.csv")
#getting the data for the year 2018-19
Fall1819 <- fread("2019_NWEA/NWEA Fall 2018-hashed.csv")
Winter1819 <- fread("2019_NWEA/NWEA_Winter_2018-2019-hashed.csv")
Spring1819 <- fread("2019_NWEA/NWEA_Spring_2018-2019-hashed.csv")
#read only elementary students from 17-18 and only middle school students from 18-19
combined.elementary1718 <- fread("2017-18 elementary.csv")
combined.middle1819 <- fread("2018-19 middleschool.csv")
```
```{r}
#identifying the middle school students , create a new column and set it to zero
combined.elementary1718$is.middle <- 0
combined.middle1819$is.middle <- 0
```
```{r}
LongData_1718 <- rbind(Fall1718,Winter1718,Spring1718)
LongData_1819 <- rbind(Fall1819,Winter1819,Spring1819)
student.analysis1 <- rbind(LongData_1718, LongData_1819)
#total number of students prior to analysis
total.number <- student.analysis1 %>%
group_by(StudentID)%>%
summarise(n())
nrow(total.number)
```
## Number of students in each schools for 17-18 and 18-19
```{r}
#Greenock
greenock1718 <- LongData_1718[LongData_1718$SchoolName == "Greenock Elementary"]
greenock1819 <- LongData_1819[LongData_1819$SchoolName == "Greenock Elementary"]
#central Elementary
central1718 <- LongData_1718[LongData_1718$SchoolName == "Central Elementary"]
central1819 <- LongData_1819[LongData_1819$SchoolName == "Central Elementary"]
#Mount Vernon Elementary
mountvernon1718 <- LongData_1718[LongData_1718$SchoolName == "Mount Vernon Elementary"]
mountvernon1819 <- LongData_1819[LongData_1819$SchoolName == "Mount Vernon Elementary"]
#William Penn Elementary
williampenn1718 <- LongData_1718[LongData_1718$SchoolName == "William Penn Elementary"]
williampenn1819 <- LongData_1819[LongData_1819$SchoolName == "William Penn Elementary"]
#Elizabeth Forward Middle School
Elizabethmiddle1718 <- LongData_1718[LongData_1718$SchoolName == "Elizabeth Forward Middle School"]
Elizabethmiddle1819 <- LongData_1819[LongData_1819$SchoolName == "Elizabeth Forward Middle School"]
```
```{r}
number.students <- c(rapply(greenock1718[,2], function(x)length(unique(x))),
rapply(greenock1819[,2], function(x)length(unique(x))),
rapply(central1718[,2], function(x)length(unique(x))),
rapply(central1819[,2], function(x)length(unique(x))),
rapply(williampenn1718[,2], function(x)length(unique(x))),
rapply(williampenn1819[,2], function(x)length(unique(x))),
rapply(mountvernon1718[,2], function(x)length(unique(x))),
rapply(mountvernon1819[,2], function(x)length(unique(x))),
rapply(Elizabethmiddle1718[,2], function(x)length(unique(x))),
rapply(Elizabethmiddle1819[,2], function(x)length(unique(x))))
Schools <- c("Greenock1718", "Greenock1819", "Central1718", "Central1819", "Williampenn1718", "Williampenn1819","Mountvernon1718", "MountVernon1819", "ElizabethMiddle1718", "Elizabethmiddle1819")
df <- data.frame(Schools,number.students)
df
```
####?data Identifying those students who were in elementary schools for 17-18 and middle school in 18-19
for (i in 1:nrow(combined.elementary1718)) {
for(j in 1:nrow(combined.middle1819)){
if(combined.elementary1718[[i,2]] == combined.middle1819[[j,2]]){
combined.elementary1718$is.middle[i] <- 1
combined.middle1819$is.middle[j] <- 1
}
}
}
```{r}
filtered1718 <- fread("filtered1718.csv")
filtered1819 <- fread("filtered1819.csv")
```
```{r}
analysis.data <- rbind(filtered1718, filtered1819)
number.students <- analysis.data %>%
group_by(StudentID)%>%
summarise(n())
nrow(number.students)
```
```{r}
analysis.data <- filter(analysis.data, is.middle == 1)
nomiddle.transition <- student.analysis1[ !(student.analysis1$StudentID %in% analysis.data$StudentID),]
```
```{r}
```
```{r}
analysis.data <- filter(analysis.data, (Discipline != "Language" & Discipline != "Science"))
str(as.factor(analysis.data$Discipline))
elementary.middle.data <- analysis.data %>%
group_by(StudentID)%>%
summarise(n())
nrow(elementary.middle.data)
```
```{r}
df <- student.analysis1[ !(student.analysis1$StudentID %in% analysis.data)]
```
Of the total students = `r nrow(total.number)`, only `r nrow(elementary.middle.data)` were those who went to elementary school in 2017-18 and graduated to middle school in 2018-19.
```{r, fig.width = 10, fig.height=10}
analysis.data.sum <- analysis.data %>%
group_by(StudentID, SchoolName, Discipline) %>%
summarise( rit.score = mean(TestRITScore))
analysis.data.sum %>%
ggplot(aes(y= rit.score, x=SchoolName, fill = Discipline))+
geom_boxplot()+
theme(axis.text.x = element_text(angle = 60, hjust =1, vjust =1)) +
ggtitle("Discipline wise Avg RIT scores for different Elementary and Middle School")
```
```{r}
analysis.data <- analysis.data %>%
group_by(StudentID, TermName, Discipline) %>%
summarise( rit.score = mean(TestRITScore))
nrow(analysis.data)
```
```{r}
#merge demographic info
demographicInfo <- fread(input = "Studnet ID_IEP_Econ_Ethn_EF-hashed.csv")
names(demographicInfo)[1] <- names(analysis.data)[1]
analysis.data<- merge(analysis.data,demographicInfo)
summary(as.factor(analysis.data$Ethnicity))
```
#### measuring growth rates in elementary and middle school for the same student
```{r, fig.width = 10, fig,height = 10}
#recofing factors
analysis.data$term <- analysis.data$TermName
analysis.data <- mutate(analysis.data, term = recode_factor(analysis.data$term, `1` = "Fall 2017-2018", `2` = "Winter 2017-2018", `3` = "Spring 2017-2018", `4` = "Fall 2018-2019", `5` = "Winter 2018-2019", `6` = "Spring 2018-2019" ))
analysis.data$TermName <- factor (analysis.data$TermName, levels = c("Fall 2017-2018", "Winter 2017-2018", "Spring 2017-2018", "Fall 2018-2019", "Winter 2018-2019", "Spring 2018-2019"))
#converting levels into integers for geom_line()
g<- analysis.data$term
g <- as.integer(g)
analysis.data$term <- g
avg.race.maths <- analysis.data[analysis.data$Discipline=="Mathematics"&analysis.data$Ethnicity%in%c("B","H","W"),] %>%
group_by(Ethnicity, term) %>%
summarise(rit.score = mean(rit.score), count = n())
avg.race.maths
#plot for mathematics
ggplot(analysis.data[analysis.data$Discipline=="Mathematics"&analysis.data$Ethnicity%in%c("B","H","W"),],
aes(TermName, y = rit.score, color = Ethnicity)) +
geom_line(aes(group = StudentID), alpha = .3) +
geom_line(data = avg.race.maths, aes(x = term, y = rit.score, color = Ethnicity), alpha = 1, size = 2)+
theme_bw()+
theme(axis.text.x = element_text(angle = 60, hjust =1, vjust =1)) +
ggtitle("Growth Mathematics : From elementary to middle school for different ethnicities")
#plot for reading
avg.race.reading <- analysis.data[analysis.data$Discipline=="Reading"&analysis.data$Ethnicity%in%c("B","H","W"),] %>%
group_by(Ethnicity, term) %>%
summarise(rit.score = mean(rit.score), count = n())
avg.race.reading
#plot for reading
ggplot(analysis.data[analysis.data$Discipline=="Reading"&analysis.data$Ethnicity%in%c("B","H","W"),], aes(x = TermName, y = rit.score, color = Ethnicity)) +
geom_line(aes(group = StudentID), alpha = .3) +
geom_line(data = avg.race.reading, aes(x = term, y = rit.score, color = Ethnicity), alpha = 1, size = 2)+
theme_bw()+
theme(axis.text.x = element_text(angle = 60, hjust =1, vjust =1)) +
ggtitle("Growth Reading : From elementary to middle school for different ethnicities")
```
```{r, fig.width = 10, fig.height = 10}
avg.rit.econdis <- analysis.data[analysis.data$Discipline=="Mathematics"&analysis.data$EconDis%in%c("1","0", NA),] %>%
group_by(EconDis, term) %>%
summarise(avg.rit = mean(rit.score), count = n())
avg.rit.econdis$economy <- avg.rit.econdis$EconDis
avg.rit.econdis$EconDisLabel <- ifelse(avg.rit.econdis$EconDis==0,"Economically Disadvantaged",ifelse(avg.rit.econdis$EconDis==1,"Not Economically Disadvataged",NA))
avg.rit.econdis
```
```{r, fig.width = 10, fig.height =10}
analysis.data$economy <- analysis.data$EconDis
analysis.data$economy <- ifelse(analysis.data$economy==0,"Economically Disadvantaged",ifelse(analysis.data$economy==1,"Not Economically Disadvataged",NA))
ggplot(analysis.data[analysis.data$Discipline=="Mathematics"&analysis.data$EconDis%in%c("1","0", NA),],
aes(x= TermName, y = rit.score, color = economy)) +
geom_line(aes(group = StudentID), alpha = 1) +
geom_line(data = avg.rit.econdis,mapping = aes(x = term, y = avg.rit, color = EconDisLabel), alpha = 1, size =2) +
theme_bw() +
theme(axis.text.x = element_text(angle = 60, hjust =1, vjust =1)) +
ggtitle("Growth Mathematics : From elementary to middle school by economic disadvantage")
```
```{r}
#changing the race for minoritised vs non-minoritised
analysis.data$new.race <- ifelse(analysis.data$Ethnicity %in% c("B", "H", "O"),0,ifelse(analysis.data$Ethnicity %in% c("W", "A"),1,NA))
analysis.data$race <- ifelse(analysis.data$new.race == 0,"Minoritised",ifelse(analysis.data$new.race == 1, "Non-Minoritised",NA))
avg.race.maths <- analysis.data[analysis.data$Discipline=="Mathematics",] %>%
group_by(race, term) %>%
summarise(rit.score = mean(rit.score), count = n())
avg.race.maths
#plot for mathematics
ggplot(analysis.data[analysis.data$Discipline=="Mathematics",], aes(TermName, y = rit.score, color = race)) +
geom_line(aes(group = StudentID), alpha = .3) +
geom_line(data = avg.race.maths, aes(x = term, y = rit.score, color = race), alpha = 1, size = 2)+
theme_bw()+
theme(axis.text.x = element_text(angle = 60, hjust =1, vjust =1)) +
ggtitle("Growth Mathematics : From elementary to middle school for minoritised vs non-minoritised")
#plot for mathematics
avg.race.reading <- analysis.data[analysis.data$Discipline=="Reading",] %>%
group_by(race, term) %>%
summarise(rit.score = mean(rit.score), count = n())
#plot for mathematics
ggplot(analysis.data[analysis.data$Discipline=="Reading",], aes(TermName, y = rit.score, color = race)) +
geom_line(aes(group = StudentID), alpha = .3) +
geom_line(data = avg.race.maths, aes(x = term, y = rit.score, color = race), alpha = 1, size = 2)+
theme_bw()+
theme(axis.text.x = element_text(angle = 60, hjust =1, vjust =1)) +
ggtitle("Growth Reading : From elementary to middle school for minoritised vs non-minoritised")
```
```{r}
#analysis.data.school <- analysis.data %>%
# group_by(StudentID, SchoolName, Discipline, TermName) %>%
#summarise( rit.score = mean(TestRITScore))
#analysis.data.school$school <- ifelse(analysis.data.school$SchoolName == "Mount Vernon Elementary",1, #ifelse(analysis.data.school$SchoolName == "Central Elementary", 10, ifelse(analysis.data.school$SchoolName == "William Penn Elementary", #100, NA)))
```