predict.blim: Predict Knowledge States from Basic Local Independence Models...

View source: R/blim_predict.R

predict.blimR Documentation

Predict Knowledge States from Basic Local Independence Models (BLIMs)

Description

Predict knowledge state or state probabilities based on a fitted blim object given a response pattern.

Usage

## S3 method for class 'blim'
predict(object, newdata = NULL, type = c("state", "probs"),
        method = c("ML", "MD", "MDML"), quiet = FALSE,
        ties.method = c("min", "max", "random"), i.RK = NULL,
        incradius = object$incradius, as.pattern = TRUE, ...)

Arguments

object

an object of class blim, typically the result of a call to blim.

newdata

a character vector of response patterns with which to predict.

type

for each pattern, predict a knowledge state or the state probabilities.

method

how to compute the posterior state probabilities. (See Details.)

quiet

silence message when estimation and prediction methods differ.

ties.method

how to deal with a posteriori equally probable states.

i.RK

optional indicator matrix of states at minimum distance from response patterns.

incradius

see blim.

as.pattern

return a character vector via as.pattern or an indicator matrix.

...

further arguments passed to as.pattern.

Details

Predicted is the modal posterior state (type = "state") or the posterior distribution (type = "probs") of knowledge states given a response pattern. Depending on the method argument, the posterior distribution is defined as:

  • Maximum likelihood (method = "ML")

    P(K | R)_{ML} = \frac{P(R | K) P(K)}{\sum_K P(R | K) P(K)} = \frac{P(R | K) P(K)}{P(R)}

  • Minimum discrepancy (method = "MD")

    P(K | R)_{MD} = \frac{i_{RK}}{\sum_K i_{RK}}

  • Minimum discrepancy ML (method = "MDML")

    P(K | R)_{MDML} = \frac{i_{RK} \cdot P(K | R)_{ML}} {\sum_K i_{RK} \cdot P(K | R)_{ML}}

where i_{RK} is a pattern-by-state indicator matrix that is one for each state K that is at minimum distance from pattern R.

Value

If type = "state", a character vector of knowledge states (if as.pattern = TRUE) or a state-by-problem indicator matrix (if as.pattern = FALSE).

If type = "probs", a matrix of posterior state probabilities.

See Also

blim, slm.

Examples

data(DoignonFalmagne7)
m <- blim(DoignonFalmagne7$K, DoignonFalmagne7$N.R)
predict(m)
predict(m, newdata = c("00100", "10100", "01111"), as.pattern = FALSE)

m <- slm(DoignonFalmagne7$K, DoignonFalmagne7$N.R)
predict(m, newdata = "00100")

data(endm)
m <- blim(endm$K, endm$N.R)
predict(m, type = "probs", method = "MD")
cbind(
  observed = names(m$N.R),
  min = predict(m, method = "MD", ties.method = "min"),
  max = predict(m, method = "MD", ties.method = "max"),
  rnd = predict(m, method = "MD", ties.method = "random")
) |> print(quote = FALSE)

pks documentation built on March 21, 2026, 1:07 a.m.