Up

Drawing Information Functions in IRT

A simple script in Python

 

This program (script) draws a graph of item information functions and the test information function in Item Response Theory (IRT). Item information functions are drawn in green, and the test information function in black (Figure 1).

Figure 1

 

The maximum value of the test information function is displayed above the graph with the value at which the function takes the maximum value.

This program uses Model (1)

The script, which calculates eq. (1), is this.

 

def P(t, a, b, c):

    v = exp(-1.7 * a * (t - b))

    return c + ((1.0 - c) / (1.0 + v))

 

The item information function for item  is given by this.

where

and the derivative of  is denoted by , and calculated by this script

 

def d_P(t, a, b, c):

    v = exp(-1.7 * a * (t - b))

    return (1.0 - c) * 1.7 * a * v / ((1.0 + v) ** 2.0)

 

Hence,  can be calculated by this

 

def I_item(t, i):

    v = (d_P(t, a[i], b[i], c[i]) ** 2.0) / (P(t, a[i], b[i], c[i]) * Q(t, a[i], b[i], c[i]))

    return v;

 

The test information function is calculated by this

The graph in Figure 1 is drawn by this script.

 

import matplotlib.pyplot as plt

import numpy as np

from math import *

 

a = [0.865, 0.618, 0.765, 1.2, 0.841]

b = [-1.272, -0.4, 0.3, -0.765, -0.657]

c = [0.0, 0.0, 0.0, 0.0, 0.0]

M = len(a)

print('M = ', M)

 

def P(t, a, b, c):

    v = exp(-1.7 * a * (t - b))

    return c + ((1.0 - c) / (1.0 + v))

 

def Q(t, a, b, c):

    return 1.0 - P(t, a, b, c)

 

def d_P(t, a, b, c):

    v = exp(-1.7 * a * (t - b))

    return (1.0 - c) * 1.7 * a * v / ((1.0 + v) ** 2.0)

 

def I_item(t, i):

    v = (d_P(t, a[i], b[i], c[i]) ** 2.0) / (P(t, a[i], b[i], c[i]) * Q(t, a[i], b[i], c[i]))

    return v;

 

x = np.arange(-3.0, 3.0, 0.01)

y  = []

yi = []

for i in range(M):

    yi.append([])

for v in x:

    sum = 0.0

    for i in range(M):

        u = I_item(v, i)

        yi[i].append(u)

        sum += u

    y.append(sum)

 

for i in range(M):

    plt.plot(x, yi[i], 'g')

plt.plot(x, y, 'k')

 

temp_v = x[0]

temp_Max = y[0]

N = len(x)

for i in range(1, N):

    if temp_Max < y[i]:

        temp_Max = y[i]

        temp_v = x[i]

 

plt.title('Maximum Info. = {0:.3f}    at {1:.2f}'.format(temp_Max, temp_v))

 

plt.show()

 

In this script, parameter values, , , , are set in the lists, and the number of items M is calculated by this code

M = len(a)

Since the number of items is calculated in the program, information functions can be calculated by simply setting any number of items in the corresponding lists.

In the above script, all s are set to be 0. In this case, the model (1) represents a two-parameter model.

The file of the script is archived in Prg.zip.

 

 

 

Up