Skip to contents

A binary item measured repeatedly is an item response model whose latent ability moves. ctsem fits the two, three and four parameter logistic forms with manifesttype = 1, and the parameters map onto ones already in the model:

IRT ctsem notes
discrimination aa LAMBDA free loading
difficulty bb MANIFESTMEANS enters as −ab-ab
guessing cc ASYMPTOTES[, 'lower'] lower asymptote
upper asymptote dd ASYMPTOTES[, 'upper'] ceiling

So the two parameter model needs no special argument at all. ASYMPTOTES has a row per binary item and a column for each asymptote. A cell left NA is no asymptote on that side, a number between 0 and 1 fixes it, and a name estimates it. Ordinal items are in the measurement models vignette; this one is about binary items and what has to be held fixed to estimate them.

The response curves

P(y=1∣η)=c+(d−c)logit−1(a(η−b))P(y=1 \mid \eta) = c + (d-c)\,\text{logit}^{-1}(a(\eta - b)). The three forms differ only in where the curve starts and stops:

eta <- seq(-4, 4, length.out = 300)
curve3 <- function(a, b, c, d, lab) data.frame(eta = eta, lab = lab,
  p = c + (d - c) / (1 + exp(-a * (eta - b))))

ggplot(rbind(
  curve3(1.5, 0, 0,    1,    '2PL'),
  curve3(1.5, 0, 0.25, 1,    '3PL: guessing 0.25'),
  curve3(1.5, 0, 0.25, 0.9,  '4PL: and a ceiling of 0.9')),
  aes(eta, p, colour = lab)) +
  geom_hline(yintercept = c(0, 1), linewidth = .3, colour = 'grey80') +
  geom_line(linewidth = 1) +
  scale_y_continuous(limits = c(0, 1)) +
  theme_bw() + theme(legend.position = 'bottom') +
  labs(x = 'latent ability', y = 'P(correct)', colour = NULL)

The guessing parameter lifts the floor: someone far below the item’s difficulty still answers correctly a quarter of the time. The upper asymptote lowers the ceiling, for items even able people sometimes miss.

What has to be fixed

The latent process needs a scale and a location, as in any factor model, and the logistic link supplies neither. Multiply the process by kk and divide every discrimination by kk and the linear predictor is unchanged, so the likelihood cannot tell them apart.

There are two ways to pin the scale and they are the same model:

  • fix one loading at 1 and let DIFFUSION be free, or
  • fix DIFFUSION at 1 and let every loading be free.

What you cannot do is fix the latent variance, because in continuous time it is not a parameter: the stationary variance is DIFFUSION2/(2|DRIFT|)\text{DIFFUSION}^2/(2|\text{DRIFT}|), so constraining it would mean constraining a function of two things the model is estimating. Pick one of the two above instead.

For the location, leave CINT and T0MEANS at zero and let MANIFESTMEANS carry the difficulties. Freeing both ends is the same redundancy again.

MANIFESTVAR must be zero: the logistic link already supplies the randomness, and ctFit() fixes it for you if you leave it free.

Simulating and fitting

Ten items with varying discriminations, 250 people, 8 occasions, guessing at 0.20.

nitem <- 10
items <- paste0('y', seq_len(nitem))
a <- seq(0.9, 1.9, length.out = nitem)     # discriminations
b <- seq(-1.6, 1.6, length.out = nitem)    # difficulties
guess <- 0.20

gen <- ctModel(type = 'ct', n.latent = 1, n.manifest = nitem,
  manifestNames = items, latentNames = 'eta',
  manifesttype = rep(1, nitem), ASYMPTOTES = c(guess, NA),
  LAMBDA = matrix(a, nitem, 1), MANIFESTMEANS = matrix(-a * b, nitem, 1),
  DRIFT = matrix(-0.4), DIFFUSION = matrix(1.2), T0VAR = matrix(1.342),
  T0MEANS = matrix(0), CINT = matrix(0), MANIFESTVAR = diag(0, nitem),
  Tpoints = 8)

set.seed(7)
d <- data.frame(ctGenerate(gen, n = 250, Tpoints = 8, dtmean = 0.9,
  backend = 'julia'))

A length 2 vector, as here, fills every binary item’s row: the lower asymptote fixed at the guessing probability, and no upper one.

The floor is visible in the data. An item far above someone’s ability is still answered correctly about c of the time, where a 2PL would go to zero:

hardest <- d[[items[nitem]]]
ggplot(data.frame(p = c(mean(hardest), guess +
    (1 - guess) * mean(plogis(a[nitem] * (rnorm(1e5, 0, 1.342) - b[nitem]))),
  mean(plogis(a[nitem] * (rnorm(1e5, 0, 1.342) - b[nitem])))),
  lab = factor(c('observed', '3PL expected', '2PL would give'),
    levels = c('observed', '3PL expected', '2PL would give'))),
  aes(lab, p, fill = lab)) +
  geom_col(width = .6, show.legend = FALSE) +
  geom_text(aes(label = sprintf('%.2f', p)), vjust = -0.4) +
  scale_y_continuous(limits = c(0, 0.45)) +
  theme_bw() + labs(x = NULL, y = 'P(correct), hardest item')

Fitting needs one argument changed between the models — ASYMPTOTES. A name in place of a number estimates that asymptote, and the same name on every item estimates one guessing parameter for the whole test. Per item is possible (cbind(paste0('guess_', items), NA)) and much harder to estimate; sharing is the usual starting point.

irtmodel <- function(ASYMPTOTES = NA) {
  m <- ctModel(type = 'ct', n.latent = 1, n.manifest = nitem,
    manifestNames = items, latentNames = 'eta',
    manifesttype = rep(1, nitem), ASYMPTOTES = ASYMPTOTES,
    # Scale: the first loading is fixed at 1 and DIFFUSION is free.
    LAMBDA = matrix(c(1, paste0('a_', items[-1])), nitem, 1),
    # Location: the latent is centred, so MANIFESTMEANS are the difficulties.
    CINT = matrix(0), T0MEANS = matrix(0),
    MANIFESTVAR = diag(0, nitem))
  m$pars$indvarying <- FALSE
  m
}

fit2 <- ctFit(d[, c('id', 'time', items)], irtmodel(),
  backend = 'julia', cores = 1, priors = TRUE)
fit3 <- ctFit(d[, c('id', 'time', items)], irtmodel(c('guess', NA)),
  backend = 'julia', cores = 1, priors = TRUE)
data.frame(model = c('2PL', '3PL'),
  loglik = round(c(fit2$estimate$loglik, fit3$estimate$loglik), 1),
  npars = c(length(fit2$estimate$raw), length(fit3$estimate$raw)),
  guess = c(NA, round(summary(fit3)$popmeans['guess', 'mean'], 3)),
  guess_sd = c(NA, round(summary(fit3)$popmeans['guess', 'sd'], 3)))
#>   model   loglik npars guess guess_sd
#> 1   2PL -11317.6    22    NA       NA
#> 2   3PL -11243.7    23 0.201     0.01

The guessing parameter is recovered with a usable standard error, and the three parameter model fits better for the one extra parameter.

Reading the dynamics

The point of fitting these over time is the process, not the items. ctDiscretePars() gives the autoregression of ability across intervals:

ctDiscretePars(fit3, times = seq(0, 8, .1), plot = TRUE, indices = 'AR',
  cores = 1)

Four parameters, and when to stop

Naming the second column frees the ceiling as well. Both are reported as the probabilities they are, and either can be estimated without the other — a ceiling alone, c(NA, 'ceiling'), is the model for items that able people sometimes slip on but nobody guesses.

fit4 <- ctFit(d[, c('id', 'time', items)], irtmodel(c('guess', 'ceiling')),
  backend = 'julia', cores = 1, priors = TRUE)
round(summary(fit4)$popmeans[c('guess', 'ceiling'), ], 3)
#>          mean    sd  2.5%   50% 97.5%
#> guess   0.207 0.011 0.186 0.206 0.228
#> ceiling 0.986 0.007 0.969 0.987 0.995

These data were generated with no ceiling, so the four parameter model is fitting one that is not there — worth seeing, because it is the usual situation. Asymptotes are weakly informed even in cross-sectional item response modelling with large samples, and here the dynamics compete for the same information. Three practical points:

  • Share the asymptote across items unless you have a reason and the data to do otherwise.
  • Use priors = TRUE. The default prior puts the guessing probability near 0.18 and the ceiling near 0.95, which is where they belong when the data are quiet about them.
  • Check the fit converged rather than reading the estimate. A guessing parameter reported without a standard error, or alongside a warning about curvature, is a stopping point rather than an answer.

Summary

  • A free loading on a binary indicator is already a 2PL; naming cells of ASYMPTOTES adds a guessing parameter, a ceiling, or both.
  • Fix either one loading or DIFFUSION to set the latent scale. The stationary variance cannot be fixed directly, being DIFFUSION2/(2|DRIFT|)\text{DIFFUSION}^2/(2|\text{DRIFT}|).
  • Keep CINT and T0MEANS at zero so MANIFESTMEANS are the difficulties, and leave MANIFESTVAR at zero.
  • Share asymptotes across items and fit with priors; treat an asymptote without a standard error as not estimated.