library("kequate") data("simeq") #Section 4.1: Various equivalent groups equatings FXEGglm <- simeq$FXEGglm FYEGglm <- simeq$FYEGglm #Summary of the log-linear model for test X summary(FXEGglm) #Freeman-Tukey residuals of the log-linear model Xres <- FTres(FXEGglm$y, FXEGglm$fitted.values) #Figure 1 plot(0:20, Xres, ylab = "Freeman-Tukey residuals", xlab = "Score values", ylim = c(-2.5, 2.5)) #Equating in an equivalent groups design keEG <- kequate("EG", 0:20, 0:20, FXEGglm, FYEGglm) summary(keEG) #Equating using observed proportions rEGobs <- getScores(keEG)$X$r sEGobs <- getScores(keEG)$Y$s NEG <- getScores(keEG)$N MEG <- getScores(keEG)$M keEGobs <- kequate("EG", 0:20, 0:20, rEGobs, sEGobs, N = NEG, M = MEG, smoothed = FALSE) #Equating using IRT models irt1 <- simeq$irtNEATx irt2 <- simeq$irtNEATy keEGirt <- kequate("EG", 0:20, 0:20, FXEGglm, FYEGglm, irtx = irt2, irty = irt1) #Section 4.2: Various non-equivalent groups with anchor test equatings bivar1 <- simeq$bivar1 bivar2 <- simeq$bivar2 #Calculating the bivariate frequencies freq1 <- kefreq(bivar1$X, 0:20, bivar1$A, 0:10) freq2 <- kefreq(bivar2$Y, 0:20, bivar2$A, 0:10) #Specifying the log-linear models glmsim1 <- glm(frequency ~ I(X) + I(X^2) + I(X^3) + I(X^4) + I(X^5) + I(A) + I(A^2) + I(A^3) + I(A^4) + I(A):I(X) + I(A):I(X^2) + I(A^2):I(X) + I(A^2):I(X^2), family = "poisson", data = freq1, x = TRUE) glmsim2 <- glm(frequency ~ I(X) + I(X^2) + I(A) + I(A^2) + I(A^3) + I(A^4) + I(A):I(X) + I(A):I(X^2) + I(A^2):I(X) + I(A^2):I(X^2), family = "poisson", data = freq2, x = TRUE) summary(glmsim1) #Evaluating the conditional moments from the log-linear models EGPest <- matrix(glmsim1$fitted.values, nrow = 21) EGPobs <- matrix(glmsim1$y, nrow = 21) NEATdistP <- cdist(EGPest, EGPobs, 0:20, 0:10) #Figure 2 plot(NEATdistP) #Equating in the NEAT design, post-stratification equating (PSE) eqNEATPSE <- kequate("NEAT_PSE", 0:20, 0:20, glmsim1, glmsim2) summary(eqNEATPSE) #Figure 3 plot(eqNEATPSE) #Equating in the NEAT design, chain equating (CE) eqNEATCE <- kequate("NEAT_CE", 0:20, 0:20, 0:10, glmsim1, glmsim2) #Calculate the SEED between PSE and CE seedPSECE <- genseed(eqNEATPSE, eqNEATCE) #Figure 4 par(mfrow=c(1,1)) plot(seedPSECE) #Specifying the bandwidth parameters manually eqNEATPSEh1 <- kequate("NEAT_PSE", 0:20, 0:20, glmsim1, glmsim2, hx = 1, hy = 1, hxlin = 1000, hylin = 1000) #Section 4.3: Non-equivalent groups with covariates equating #Specifying the log-linear models NECXglm <- glm(frequency ~ I(testX) + I(testX^2) + I(testX^3) + I(mattea1) + I(mattea1^2) + factor(utb1) + I(testX):I(mattea1) + I(testX):factor(utb1) + I(mattea1):factor(utb1), data = simeq$testdata1, family = "poisson", x = TRUE) NECYglm <- glm(frequency ~ I(testY) + I(testY^2) + I(testY^3) + I(mattea1) + I(mattea1^2) + factor(utb1) + I(testY):I(mattea1) + I(testY):factor(utb1) + I(mattea1):factor(utb1), data = simeq$testdata2, family = "poisson", x = TRUE) summary(NECYglm) #Equating with covariates using the default Gaussian kernel NECeq <- kequate("NEC", 0:22, 0:22, NECYglm, NECXglm) summary(NECeq) #Equating with covariates using the logistic kernel NECeqL <- kequate("NEC", 0:22, 0:22, NECYglm, NECXglm, kernel = "logistic") #Equating with covariates using the uniform kernel NECeqU <- kequate("NEC", 0:22, 0:22, NECYglm, NECXglm, kernel = "uniform") #Figure 5 plot(0:22, getEquating(NECeq)$SEEYx, ylim = c(0, 0.20), pch = 1, xlab = "Score values", ylab = "SEE") points(0:22, getEquating(NECeqL)$SEEYx, ylim = c(0, 0.20), pch = 2) points(0:22, getEquating(NECeqU)$SEEYx, ylim = c(0, 0.20), pch = 3) legend("topright", inset = .05, title = "Kernel utilized", c("Gaussian", "Logistic", "Uniform"), pch = c(1, 2, 3))