predict.blim.RdPredict knowledge state or state probabilities based on a fitted blim
object given a response pattern.
an object of class blim, typically the result of a
call to blim.
a character vector of response patterns with which to predict.
for each pattern, predict a knowledge state or the state probabilities.
how to compute the posterior state probabilities. (See Details.)
silence message when estimation and prediction methods differ.
how to deal with a posteriori equally probable states.
optional indicator matrix of states at minimum distance from response patterns.
see blim.
return a character vector via as.pattern or
an indicator matrix.
further arguments passed to as.pattern.
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\).
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.
data(DoignonFalmagne7)
m <- blim(DoignonFalmagne7$K, DoignonFalmagne7$N.R)
predict(m)
#> estimation method is MD, prediction method is ML
#> [1] "00000" "10000" "01000" "00000" "00000" "00000" "11000" "11100" "11010"
#> [10] "10000" "11100" "11010" "01000" "11110" "11101" "00000" "11100" "11010"
#> [19] "11101" "11110" "11101" "11010" "11110" "11101" "11010" "11111" "11110"
#> [28] "11101" "11010" "11111" "11111" "11111"
predict(m, newdata = c("00100", "10100", "01111"), as.pattern = FALSE)
#> estimation method is MD, prediction method is ML
#> a b c d e
#> 00000 0 0 0 0 0
#> 11100 1 1 1 0 0
#> 11111 1 1 1 1 1
m <- slm(DoignonFalmagne7$K, DoignonFalmagne7$N.R)
predict(m, newdata = "00100")
#> estimation method is MD, prediction method is ML
#> [1] "00000"
data(endm)
m <- blim(endm$K, endm$N.R)
predict(m, type = "probs", method = "MD")
#> 0000 0110 0101 1110 1101 1011 1111
#> 1 1.0000000 0.0000000 0.0000000 0.0 0.0 0.0 0.0000000
#> 2 1.0000000 0.0000000 0.0000000 0.0 0.0 0.0 0.0000000
#> 3 0.3333333 0.3333333 0.3333333 0.0 0.0 0.0 0.0000000
#> 4 0.5000000 0.5000000 0.0000000 0.0 0.0 0.0 0.0000000
#> 5 0.5000000 0.0000000 0.5000000 0.0 0.0 0.0 0.0000000
#> 6 0.0000000 0.0000000 0.0000000 0.5 0.5 0.0 0.0000000
#> 7 0.0000000 0.0000000 0.0000000 0.5 0.0 0.5 0.0000000
#> 8 0.0000000 0.0000000 0.0000000 0.0 0.5 0.5 0.0000000
#> 9 0.0000000 1.0000000 0.0000000 0.0 0.0 0.0 0.0000000
#> 10 0.0000000 0.0000000 1.0000000 0.0 0.0 0.0 0.0000000
#> 11 0.0000000 0.0000000 0.0000000 0.0 0.0 1.0 0.0000000
#> 12 0.0000000 0.0000000 0.0000000 1.0 0.0 0.0 0.0000000
#> 13 0.0000000 0.0000000 0.0000000 0.0 1.0 0.0 0.0000000
#> 14 0.0000000 0.0000000 0.0000000 0.0 0.0 1.0 0.0000000
#> 15 0.0000000 0.3333333 0.3333333 0.0 0.0 0.0 0.3333333
#> 16 0.0000000 0.0000000 0.0000000 0.0 0.0 0.0 1.0000000
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)
#> observed min max rnd
#> [1,] 0000 0000 0000 0000
#> [2,] 1000 0000 0000 0000
#> [3,] 0100 0000 0110 0101
#> [4,] 0010 0000 0110 0000
#> [5,] 0001 0000 0101 0101
#> [6,] 1100 1110 1110 1110
#> [7,] 1010 1110 1110 1011
#> [8,] 1001 1101 1101 1101
#> [9,] 0110 0110 0110 0110
#> [10,] 0101 0101 0101 0101
#> [11,] 0011 1011 1011 1011
#> [12,] 1110 1110 1110 1110
#> [13,] 1101 1101 1101 1101
#> [14,] 1011 1011 1011 1011
#> [15,] 0111 0110 1111 1111
#> [16,] 1111 1111 1111 1111