-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWIDA_CO_SGP_2022.R
177 lines (140 loc) · 6.76 KB
/
WIDA_CO_SGP_2022.R
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
################################################################################
### ###
### Calculate 2022 Student Growth Percentiles for Colorado WIDA/ACCESS ###
### ###
################################################################################
### Load required packages
require(SGP)
require(data.table)
### Load Data
load("Data/WIDA_CO_SGP.Rdata")
load("Data/WIDA_CO_Data_LONG_2022.Rdata")
### Add baseline matrices
SGPstateData <- SGPmatrices::addBaselineMatrices("WIDA_CO", "2021")
### Run updateSGP to produce cohort referrenced SGPs, etc.
WIDA_CO_SGP <- updateSGP(
what_sgp_object = WIDA_CO_SGP,
with_sgp_data_LONG = WIDA_CO_Data_LONG_2022,
steps = c("prepareSGP", "analyzeSGP", "combineSGP",
"summarizeSGP", "outputSGP"),
sgp.percentiles = TRUE,
sgp.projections = TRUE,
sgp.projections.lagged = TRUE,
sgp.percentiles.baseline = TRUE,
sgp.projections.baseline = TRUE,
sgp.projections.lagged.baseline = TRUE,
sgp.percentiles.equated = FALSE,
sgp.target.scale.scores = FALSE, # Run below
save.intermediate.results = FALSE,
parallel.config = list(
BACKEND = "PARALLEL",
WORKERS = list(
PERCENTILES = 8,
PROJECTIONS = 4,
LAGGED_PROJECTIONS = 2,
SUMMARY = 4)))
### Run combineSGP for Interim Target Levels (for both 2021 and 2022)
`%w/o%` <- function(x, y) x[!x %in% y]
## Preserve previously calculated "interim" variables
setnames(WIDA_CO_SGP@Data, "CATCH_UP_KEEP_UP_INTERIM_STATUS", "CUPKUP_IS")
interim.targets <- c("SGP_TARGET_INTERIM", "SGP_TARGET_INTERIM_CURRENT")
### Clean Up pre-combined data
simple.targets <- c("SGP_TARGET_3_YEAR_CURRENT", "SGP_TARGET_3_YEAR",
"SGP_TARGET_BASELINE_3_YEAR_CURRENT", "SGP_TARGET_BASELINE_3_YEAR")
WIDA_CO_SGP@Data[, (simple.targets) := NULL]
### Remove CUKU status vars tied to L3/L4 except original (3 Year)
setnames(WIDA_CO_SGP@Data,
c("CATCH_UP_KEEP_UP_STATUS_3_YEAR", "CATCH_UP_KEEP_UP_STATUS_BASELINE_3_YEAR"),
c("CUKU_ORIG", "CUKU_BASELINE_ORIG"))
## L1/L2
SGPstateData[["WIDA_CO"]][["Achievement"]][["Levels"]][["Proficient"]] <-
c("Not Proficient",
"Proficient", "Proficient", "Proficient", "Proficient", "Proficient", NA)
WIDA_CO_SGP <- combineSGP(
WIDA_CO_SGP,
years = c("2021", "2022"),
sgp.target.scale.scores = TRUE,
sgp.target.scale.scores.merge = "all_years_lagged_current",
max.sgp.target.years.forward = 0:1,
parallel.config = list(
BACKEND = "FOREACH", TYPE = "doParallel",
WORKERS = list(SGP_SCALE_SCORE_TARGETS = 4)))
tmp.target.names <- grep("SGP_TARGET", names(WIDA_CO_SGP@Data), value = TRUE) %w/o% interim.targets
setnames(WIDA_CO_SGP@Data, tmp.target.names,
gsub("SGP_TARGET", "SGP_LEVEL_1_TARGET", tmp.target.names))
setnames(WIDA_CO_SGP@Data,
gsub("CATCH_UP_KEEP_UP", "L1L2_CUKU", names(WIDA_CO_SGP@Data)))
target.ss.index <- grep("^(?!.*2020).*SCALE_SCORES",
names(WIDA_CO_SGP@SGP[["SGProjections"]]), perl = TRUE)
names(WIDA_CO_SGP@SGP[["SGProjections"]])[target.ss.index] <-
gsub("SCALE_SCORES", "SS_L1L2",
names(WIDA_CO_SGP@SGP[["SGProjections"]])[target.ss.index])
## L2/L3
SGPstateData[["WIDA_CO"]][["Achievement"]][["Levels"]][["Proficient"]] <-
c("Not Proficient", "Not Proficient",
"Proficient", "Proficient", "Proficient", "Proficient", NA)
WIDA_CO_SGP <- combineSGP(
WIDA_CO_SGP,
years = c("2021", "2022"),
sgp.target.scale.scores = TRUE,
sgp.target.scale.scores.merge = "all_years_lagged_current",
max.sgp.target.years.forward = 0:2,
parallel.config = list(
BACKEND = "FOREACH", TYPE = "doParallel",
WORKERS = list(SGP_SCALE_SCORE_TARGETS = 4)))
tmp.target.names <- grep("SGP_TARGET", names(WIDA_CO_SGP@Data), value = TRUE) %w/o% interim.targets
setnames(WIDA_CO_SGP@Data, tmp.target.names,
gsub("SGP_TARGET", "SGP_LEVEL_2_TARGET", tmp.target.names))
setnames(WIDA_CO_SGP@Data,
gsub("CATCH_UP_KEEP_UP", "L2L3_CUKU", names(WIDA_CO_SGP@Data)))
target.ss.index <- grep("^(?!.*2020).*SCALE_SCORES",
names(WIDA_CO_SGP@SGP[["SGProjections"]]), perl = TRUE)
names(WIDA_CO_SGP@SGP[["SGProjections"]])[target.ss.index] <-
gsub("SCALE_SCORES", "SS_L2L3",
names(WIDA_CO_SGP@SGP[["SGProjections"]])[target.ss.index])
## L4/L5 (Stay at above L5 - do before Official/L4)
SGPstateData[["WIDA_CO"]][["Achievement"]][["Levels"]][["Proficient"]] <-
c("Not Proficient", "Not Proficient", "Not Proficient", "Not Proficient",
"Proficient", "Proficient", NA)
WIDA_CO_SGP <- combineSGP(
WIDA_CO_SGP,
years = c("2021", "2022"),
sgp.target.scale.scores = TRUE,
sgp.target.scale.scores.merge = "all_years_lagged_current",
max.sgp.target.years.forward = 0:1,
parallel.config = list(
BACKEND = "FOREACH", TYPE = "doParallel",
WORKERS = list(SGP_SCALE_SCORE_TARGETS = 4)))
tmp.target.names <- grep("SGP_TARGET", names(WIDA_CO_SGP@Data), value = TRUE) %w/o% interim.targets
setnames(WIDA_CO_SGP@Data, tmp.target.names,
gsub("SGP_TARGET", "SGP_LEVEL_4_TARGET", tmp.target.names))
setnames(WIDA_CO_SGP@Data,
gsub("CATCH_UP_KEEP_UP", "L4L5_CUKU", names(WIDA_CO_SGP@Data)))
target.ss.index <- grep("^(?!.*2020).*SCALE_SCORES",
names(WIDA_CO_SGP@SGP[["SGProjections"]]), perl = TRUE)
names(WIDA_CO_SGP@SGP[["SGProjections"]])[target.ss.index] <-
gsub("SCALE_SCORES", "SS_L4L5",
names(WIDA_CO_SGP@SGP[["SGProjections"]])[target.ss.index])
## L3/L4 (Official)
SGPstateData[["WIDA_CO"]][["Achievement"]][["Levels"]][["Proficient"]] <-
c("Not Proficient", "Not Proficient", "Not Proficient",
"Proficient", "Proficient", "Proficient", NA)
WIDA_CO_SGP <- combineSGP(
WIDA_CO_SGP,
years = c("2021", "2022"),
sgp.target.scale.scores = TRUE,
sgp.target.scale.scores.merge = "all_years_lagged_current",
max.sgp.target.years.forward = 0:3,
parallel.config = list(
BACKEND = "FOREACH", TYPE = "doParallel",
WORKERS = list(SGP_SCALE_SCORE_TARGETS = 4)))
tmp.target.names <- grep("SGP_TARGET", names(WIDA_CO_SGP@Data), value = TRUE) %w/o% interim.targets
setnames(WIDA_CO_SGP@Data, tmp.target.names,
gsub("SGP_TARGET", "SGP_LEVEL_3_TARGET", tmp.target.names))
setnames(WIDA_CO_SGP@Data,
gsub("CATCH_UP_KEEP_UP", "L3L4_CUKU", names(WIDA_CO_SGP@Data)))
## Rename generic "CATCH_UP_KEEP_UP_STATUS" for all students as "Official"
setnames(WIDA_CO_SGP@Data, c("CUKU_ORIG", "CUPKUP_IS"),
c("CATCH_UP_KEEP_UP_STATUS", "CATCH_UP_KEEP_UP_INTERIM_STATUS"))
### Save results
save(WIDA_CO_SGP, file = "Data/WIDA_CO_SGP.Rdata")