twopl_jml

def twopl_jml(dataset, options=None)

Estimates parameters in a 2PL IRT model.

Args

dataset
[items x participants] matrix of True/False Values
options
dictionary with updates to default options

Returns

discrimination
(1d array) estimates of item discrimination
difficulty
(1d array) estimates of item difficulties

Options

  • max_iteration: int
Expand source code
def twopl_jml(dataset, options=None):
    """ Estimates parameters in a 2PL IRT model.

    Args:
        dataset: [items x participants] matrix of True/False Values
        options: dictionary with updates to default options

    Returns:
        discrimination: (1d array) estimates of item discrimination
        difficulty: (1d array) estimates of item difficulties

    Options:
        * max_iteration: int
    """
    options = validate_estimation_options(options)

    # Defines item parameter update function
    def _item_min_func(n_items, alphas, thetas,
                       betas, the_sign, counts):
        # pylint: disable=cell-var-from-loop
        for ndx in range(n_items):
            def _alpha_beta_min(estimates):
                otpt = 1.0 / (1.0 + np.exp((thetas - estimates[1]) *
                                           the_sign[ndx, :] * estimates[0]))
                return -np.log(otpt).dot(counts)

            # Solves jointly for parameters using numerical derivatives
            otpt = fmin_slsqp(_alpha_beta_min, (alphas[ndx], betas[ndx]),
                              bounds=[(0.25, 4), (-6, 6)], disp=False)
            alphas[ndx], betas[ndx] = otpt

        return alphas, betas

    return _jml_abstract(dataset, _item_min_func, discrimination=1,
                         max_iter=options['max_iteration'])
Last modified April 7, 2020: Updating documentation. (3da0254)