## Calculate 4th grade student growth percentiles using included sgpData
sgp_g4 <- studentGrowthPercentiles(panel.data=sgpData,
sgp.labels=list(my.year=2012, my.subject="Reading"),
percentile.cuts=c(1,35,65,99),
subset.grade=4,
num.prior=1)
## NOTE: "grade.progression" can be used in place of "subset.grade" and "num.prior"
sgp_g4_v2 <- studentGrowthPercentiles(panel.data=sgpData,
sgp.labels=list(my.year=2012, my.subject="Reading"),
percentile.cuts=c(1,35,65,99),
grade.progression=c(3,4))
identical(sgp_g4$SGPercentiles, sgp_g4_v2$SGPercentiles)
## Established state Knots and Boundaries are available in the supplied SGPstateData
## file and used by supplying the appropriate two letter state acronym.
sgp_g4_DEMO <- studentGrowthPercentiles(panel.data=sgpData,
sgp.labels=list(my.year=2012, my.subject="Reading"),
use.my.knots.boundaries="DEMO",
grade.progression=c(3,4))
## Sample code for running non-sequential grade progression analysis.
sgp_g8_DEMO <- studentGrowthPercentiles(panel.data=sgpData,
sgp.labels=list(my.year=2012, my.subject="Reading"),
use.my.knots.boundaries="DEMO",
grade.progression=c(5,6,8))
## NOTE: Goodness of Fit results are stored as a graphical object in the
## Goodness_of_Fit slot. To view or save (using any R output device) try:
grid.draw(sgp_g4$Goodness_of_Fit$READING.2012$GRADE_4)
pdf(file="Grade_4_Reading_2012_GOF.pdf", width=8.5, height=4.5)
grid.draw(sgp_g4$Goodness_of_Fit$READING.2012$GRADE_4)
dev.off()
# Other grades
sgp_g5 <- studentGrowthPercentiles(panel.data=sgpData,
sgp.labels=list(my.year=2012, my.subject="Reading"),
percentile.cuts=c(1,35,65,99),
grade.progression=3:5)
sgp_g6 <- studentGrowthPercentiles(panel.data=sgpData,
sgp.labels=list(my.year=2012, my.subject="Reading"),
percentile.cuts=c(1,35,65,99),
grade.progression=3:6)
sgp_g7 <- studentGrowthPercentiles(panel.data=sgpData,
sgp.labels=list(my.year=2012, my.subject="Reading"),
percentile.cuts=c(1,35,65,99),
grade.progression=3:7)
sgp_g8 <- studentGrowthPercentiles(panel.data=sgpData,
sgp.labels=list(my.year=2012, my.subject="Reading"),
percentile.cuts=c(1,35,65,99),
grade.progression=4:8)
## All output of studentGrowthPercentiles (e.g., coefficient matrices) is contained
## in the object. See, for example, names(sgp_g8), for all included objects.
## Results are stored in the slot SGPercentiles.
# Combine all results
sgp_all <- rbind(sgp_g4$SGPercentiles$READING.2012,
sgp_g5$SGPercentiles$READING.2012,
sgp_g6$SGPercentiles$READING.2012,
sgp_g7$SGPercentiles$READING.2012,
sgp_g8$SGPercentiles$READING.2012)
# Save SGP results to .csv file
write.csv(sgp_all, file="sgp_all.csv", row.names=FALSE, quote=FALSE, na="")
## NOTE: studentGrowthPercentiles ADDs results to the current SGP object.
## This allows one to "recycle" the object for multiple grades and subjects as desired.
# Loop to calculate all SGPs for all grades without percentile cuts
# but with growth levels
my.grade.sequences <- list(3:4, 3:5, 3:6, 3:7, 4:8)
my.sgpData <- list(Panel_Data=sgpData) ### Put sgpData into Panel_Data slot
for (i in seq_along(my.grade.sequences)) {
my.sgpData <- studentGrowthPercentiles(panel.data=my.sgpData,
sgp.labels=list(my.year=2012, my.subject="Reading"),
growth.levels="DEMO",
grade.progression=my.grade.sequences[[i]])
}
# Save Student Growth Percentiles results to a .csv file:
write.csv(my.sgpData$SGPercentiles$READING.2012,
file="2012_Reading_SGPercentiles.csv", row.names=FALSE, quote=FALSE, na="")
# Create pdfs of all Goodness of Fit results:
for (i in names(my.sgpData$Goodness_of_Fit$READING.2012)) {
pdf(file=paste(i, "_Reading_2012_GOF.pdf", sep=""), width=8.5, height=4.5)
grid.draw(my.sgpData[["Goodness_of_Fit"]][["READING.2012"]][[i]])
dev.off()
}
## Loop to calculate all SGPs for all grades using 2006 to 2009 data
my.grade.sequences <- list(3:4, 3:5, 3:6, 3:7, 4:8)
for (i in seq_along(my.grade.sequences)) {
my.sgpData_2009 <- studentGrowthPercentiles(panel.data=my.sgpData,
panel.data.vnames=c("ID", "GRADE_2007",
"GRADE_2008", "GRADE_2009", "GRADE_2010",
"SS_2007", "SS_2008", "SS_2009", "SS_2010"),
sgp.labels=list(my.year=2010, my.subject="Reading"),
grade.progression=my.grade.sequences[[i]])
}
## Loop to calculate all SGPs for all grades WITH 80
my.grade.sequences <- list(3:4, 3:5, 3:6, 3:7, 4:8)
for (i in seq_along(my.grade.sequences)) {
my.sgpData <- studentGrowthPercentiles(panel.data=my.sgpData,
sgp.labels=list(my.year=2012, my.subject="Reading"),
calculate.confidence.intervals=list(state="DEMO",
confidence.quantiles=c(0.1, 0.9), simulation.iterations=100,
distribution="Normal", round=1),
grade.progression=my.grade.sequences[[i]])
}
### Example showing how to use pre-calcualted coefficient
### matrices to calculate student growth percentiles
my.grade.sequences <- list(3:4, 3:5, 3:6, 3:7, 4:8)
my.sgpData <- list(Panel_Data=sgpData) ### Put sgpData into Panel_Data slot
for (i in seq_along(my.grade.sequences)) {
my.sgpData <- studentGrowthPercentiles(panel.data=my.sgpData,
sgp.labels=list(my.year=2012, my.subject="Reading"),
growth.levels="DEMO",
grade.progression=my.grade.sequences[[i]])
}
percentiles.1st.run <- my.sgpData$SGPercentiles$READING.2012
### my.sgpData has as full set of coefficient matrices for Reading, 2012. To view these
names(my.sgpData$Coefficient_Matrices$READING.2012)
## Let's NULL out the SGPercentiles slot and recreate the percentiles
## using the embedded coefficient matrices
my.sgpData$SGPercentiles$READING.2012 <- NULL
for (i in seq_along(my.grade.sequences)) {
my.sgpData <- studentGrowthPercentiles(panel.data=my.sgpData,
sgp.labels=list(my.year=2012, my.subject="Reading"),
use.my.knots.boundaries=list(my.year=2012, my.subject="Reading"),
use.my.coefficient.matrices=list(my.year=2012, my.subject="Reading"),
growth.levels="DEMO",
grade.progression=my.grade.sequences[[i]])
}
percentiles.2nd.run <- my.sgpData$SGPercentiles$READING.2012
identical(percentiles.1st.run, percentiles.2nd.run)
Run the code above in your browser using DataLab