Treat the responses to each item as a different observation variable. Is this a proper way to solve the problem
IRT w/ PyMC3, unusual number of parameters modeled?
I changed part of the code, just like this:
import numpy as np
import pymc3 as pm
k = np.array([1,1,1,1,1,1,
1,1,1,1,0,1,
1,1,1,0,0,1,
1,1,0,0,0,1,
1,0,0,0,0,1]).reshape(5,6)
students = 5
questions = 6
with pm.Model() as model:
# student multilevel prior
sigma_student = pm.HalfNormal('sigma_student',sigma=1,shape=1)
mu_student = pm.Normal('mu_student',mu=0,sigma=1,shape=1)
z_student = pm.Normal("z_student", mu=mu_student, sigma=sigma_student, shape=students)
# question single-level prior
sigma_question = pm.HalfNormal('sigma_question',sigma=1,shape=1)
z_question = pm.Normal("z_question",mu=0, sigma=sigma_question, shape=questions)
# Likelihood
for question in range(questions):
p = pm.Deterministic("p{}".format(question),pm.math.sigmoid(z_student-z_question[question]))
kij = pm.Bernoulli("kij{}".format(question), p=p, observed=k[:,question])
trace = pm.sample(chains=4)
By the way, I would like to ask if there is any container that can be sliced in pymc3.