if (FALSE) {
library("brms")
library("rstan")
coef_bayesianMixedEffectsGRM_gam <- coef(bayesianMixedEffectsGRM_gam)
str(coef_bayesianMixedEffectsGRM_gam)
itempars <- coef_bayesianMixedEffectsGRM_gam$item[,1,1:4]
# define a grid of thetas for the computations:
theta_seq <- seq(-4, 4, length.out = 201)
# item information for all items
# The resulting matrix has length(theta_seq) columns and a row per item.
# We use a loop for the calculations
item_info <- matrix(NA, nrow = nrow(itempars), ncol = length(theta_seq))
for(i in 1:nrow(itempars)){
item_info[i, ] <- item_info_NB_zero_analytical(
theta = theta_seq,
alpha = itempars[i, "alpha_Intercept"],
beta = itempars[i, "beta_Intercept"],
phi = exp(itempars[i, "shape_Intercept"]),
varpi = plogis(itempars[i, "zi_Intercept"]))
}
test_info <- data.frame(
theta = theta_seq,
testInformation = colSums(item_info)
)
# Or, alternatively:
test_info_NB(
theta = compareTestInfo$theta,
alpha = itempars[,"alpha_Intercept"],
beta = itempars[,"beta_Intercept"],
phi = exp(itempars[,"shape_Intercept"]),
varpi = plogis(itempars[,"zi_Intercept"]),
zero = TRUE)
# Test Standard Error of Measurement in Different Theta Ranges
error_variance_NB(
lower = -4,
upper = 4,
alpha = itempars[,"alpha_Intercept"],
beta = itempars[,"beta_Intercept"],
phi = exp(itempars[,"shape_Intercept"]),
varpi = plogis(itempars[,"zi_Intercept"]),
zero = TRUE
)
error_variance_NB(
lower = -4,
upper = 0,
alpha = itempars[,"alpha_Intercept"],
beta = itempars[,"beta_Intercept"],
phi = exp(itempars[,"shape_Intercept"]),
varpi = plogis(itempars[,"zi_Intercept"]),
zero = TRUE
)
error_variance_NB(
lower = 0,
upper = 1.5,
alpha = itempars[,"alpha_Intercept"],
beta = itempars[,"beta_Intercept"],
phi = exp(itempars[,"shape_Intercept"]),
varpi = plogis(itempars[,"zi_Intercept"]),
zero = TRUE
)
error_variance_NB(
lower = 1.5,
upper = 4,
alpha = itempars[,"alpha_Intercept"],
beta = itempars[,"beta_Intercept"],
phi = exp(itempars[,"shape_Intercept"]),
varpi = plogis(itempars[,"zi_Intercept"]),
zero = TRUE
)
# One-Number Summary of Test Reliability
reliability_NB(
alpha = itempars[,"alpha_Intercept"],
beta = itempars[,"beta_Intercept"],
phi = exp(itempars[,"shape_Intercept"]),
varpi = plogis(itempars[,"zi_Intercept"]),
zero = TRUE)
}
Run the code above in your browser using DataLab