5.7 E-step
In the E-step, one needs to calculate the posterior probability of observing a response vector for student :
Recall that is a matrix called Li.given.alpha.c.
Code
Li.given.alpha.c
## 00 10 01 11
## student 1 0.00081 0.00144 0.00144 0.0205
## student 2 0.00729 0.01296 0.01296 0.0051
## student 3 0.00081 0.00004 0.05184 0.0205
## student 4 0.00081 0.05184 0.00144 0.0205
## student 5 0.00729 0.01296 0.00036 0.0051
## student 6 0.00729 0.00036 0.01296 0.0051
## student 7 0.00729 0.01296 0.01296 0.0051
## student 8 0.00009 0.00016 0.00576 0.0819
## student 9 0.00081 0.05184 0.00144 0.0205
## student 10 0.00081 0.00144 0.00144 0.0205
Let us assume and again and calculate :
Code
<- matrix(NA, nrow = 10, ncol = 4)
P.alphac.given.yi <- c(1/6, 1/6, 1/3, 1/3)
p.alphac for (i in 1:10) {
<- sum(Li.given.alpha.c[i, ] * p.alphac)
p.yi <- Li.given.alpha.c[i, ] * p.alphac/p.yi
P.alphac.given.yi[i, ]
}
colnames(P.alphac.given.yi) <- c("00", "10", "01", "11")
rownames(P.alphac.given.yi) <- paste("student", 1:10)
P.alphac.given.yi
## 00 10 01 11
## student 1 0.01757 0.03124 0.062 0.89
## student 2 0.12923 0.22975 0.459 0.18
## student 3 0.00557 0.00027 0.713 0.28
## student 4 0.00839 0.53726 0.030 0.42
## student 5 0.23358 0.41525 0.023 0.33
## student 6 0.16640 0.00822 0.592 0.23
## student 7 0.12923 0.22975 0.459 0.18
## student 8 0.00051 0.00091 0.066 0.93
## student 9 0.00839 0.53726 0.030 0.42
## student 10 0.01757 0.03124 0.062 0.89
Recall that the DINA model groups students into two groups:
for students lacking at least one of the required attributes for item and
for students having all the required attributes for item .
For item
Based on provisional item parameter estimates, the E-step calculates
the expected number of students in group
the expected number of students in group
the expected number of students in group who answer item correctly
the expected number of students in group who answer item correctly
Code
P.alphac.given.yi
## 00 10 01 11
## student 1 0.01757 0.03124 0.062 0.89
## student 2 0.12923 0.22975 0.459 0.18
## student 3 0.00557 0.00027 0.713 0.28
## student 4 0.00839 0.53726 0.030 0.42
## student 5 0.23358 0.41525 0.023 0.33
## student 6 0.16640 0.00822 0.592 0.23
## student 7 0.12923 0.22975 0.459 0.18
## student 8 0.00051 0.00091 0.066 0.93
## student 9 0.00839 0.53726 0.030 0.42
## student 10 0.01757 0.03124 0.062 0.89
Code
y
## [,1] [,2] [,3] [,4] [,5]
## [1,] 1 0 1 0 1
## [2,] 0 1 1 0 0
## [3,] 0 0 1 1 1
## [4,] 1 1 0 1 0
## [5,] 1 0 0 0 1
## [6,] 0 0 1 0 1
## [7,] 0 1 1 0 0
## [8,] 0 1 1 1 1
## [9,] 1 1 0 1 0
## [10,] 1 0 1 0 1
For item 5, so are all in group and is in group.
Code
<- sum(P.alphac.given.yi[, 1:3])
Nj0 <- sum(P.alphac.given.yi[, 4])
Nj1 <- sum(y[, 5] * rowSums(P.alphac.given.yi[, 1:3]))
Rj0 <- sum(y[, 5] * P.alphac.given.yi[, 4]) Rj1
## Nj0 = 5.2
## Nj1 = 4.8
## Rj0 = 2.4
## Rj1 = 3.6
Exercise 5.3 Find these quantities for item 1.
Click for Answer
Code
<- sum(P.alphac.given.yi[, 1:3])
Nj0 <- sum(P.alphac.given.yi[, 4])
Nj1 <- sum(y[, 1] * rowSums(P.alphac.given.yi[, 1:3]))
Rj0 <- sum(y[, 1] * P.alphac.given.yi[, 4])
Rj1
cat("Nj0 =", Nj0, "\nNj1 =", Nj1, "\nRj0 =", Rj0, "\nRj1 =", Rj1)
## Nj0 = 5.2
## Nj1 = 4.8
## Rj0 = 2
## Rj1 = 3