Last active
October 19, 2022 20:47
-
-
Save jmbarbone/aeb6c2f2b9bf65121d356c736969df6c to your computer and use it in GitHub Desktop.
example of `{equate}` with SAT ACT data from `{psych}`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x <- psych::sat.act$ACT | |
y <- psych::sat.act$SATQ + psych::sat.act$SATV | |
ft <- equate::freqtab(data.frame(x, y)) | |
eq0 <- equate::equate( | |
x = ft, | |
type = "equipercentile", | |
method = "none", # single group | |
smooth = "loglinear", | |
degrees = list(4, 2, 2) # default list(4, 2, 2); maybe list(4, 2) | |
) | |
eq <- equate::equate( | |
x = ft, | |
type = "equipercentile", | |
method = "none", # single group | |
smooth = "loglinear", | |
degrees = list(4, 2, 2), # default list(4, 2, 2); maybe list(4, 2) | |
choose = TRUE, | |
choosemethod = "aic", | |
crit = eq0$concordance$yx, | |
boot = TRUE, | |
reps = 50 | |
) | |
withr::with_par(list(mfrow = c(1, 3)), { | |
# boring | |
# plot(eq, addident = FALSE, out = "eqs", col = "blue") | |
# combine everything | |
con <- eq$concordance | |
boots <- eq$bootstraps | |
plot(eq, xpoints = x, ypoints = y, addident = FALSE, col = "blue", addlegend = FALSE) | |
# add estimate without bias | |
lines(con$scale, con$yx - boots$bias, col = "red", lty = 1) | |
# add se ranged | |
lines(con$scale, con$yx + con$se.b, col = "green", lty = 2) | |
lines(con$scale, con$yx - con$se.b, col = "green", lty = 2) | |
# add rmse ranges | |
lines(con$scale, con$yx + boots$rmse, col = "purple", lty = 3) | |
lines(con$scale, con$yx - boots$rmse, col = "purple", lty = 3) | |
# just bias | |
plot(eq, addident = FALSE, out = "bias", col = "red", addlegend = FALSE) | |
abline(0, 0, lty = 2, col = "grey60") | |
# se and rmse | |
plot(eq, addident = FALSE, out = "se", col = "green", ylab = "SE | RMSE", addlegend = FALSE) | |
plot(eq, addident = FALSE, out = "rmse", add = TRUE, col = "purple", lty = 2) | |
}) |
Author
jmbarbone
commented
Oct 19, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment