ability_map

def ability_map(dataset, difficulty, discrimination, options=None)

Estimates the abilities for dichotomous models.

Estimates the ability parameters (theta) for dichotomous models via maximum a posterior likelihood estimation.

Args

dataset
[n_items, n_participants] (2d Array) of measured responses
difficulty
(1d Array) of difficulty parameters for each item
discrimination
(1d Array) of disrimination parameters for each item
options
dictionary with updates to default options

Returns

abilities
(1d array) estimated abilities

Options

distribution
 

Notes

If distribution is uniform, please use ability_mle instead. A large set of probability distributions can be found in scipy.stats https://docs.scipy.org/doc/scipy/reference/stats.html

Expand source code
def ability_map(dataset, difficulty, discrimination, options=None):
    """Estimates the abilities for dichotomous models.

    Estimates the ability parameters (theta) for dichotomous models via
    maximum a posterior likelihood estimation.

    Args:
        dataset: [n_items, n_participants] (2d Array) of measured responses
        difficulty: (1d Array) of difficulty parameters for each item
        discrimination: (1d Array) of disrimination parameters for each item
        options: dictionary with updates to default options

    Returns:
        abilities: (1d array) estimated abilities

    Options:
        distribution: 

    Notes:
        If distribution is uniform, please use ability_mle instead. A large set 
        of probability distributions can be found in scipy.stats
        https://docs.scipy.org/doc/scipy/reference/stats.html
    """
    options = validate_estimation_options(options)
    distribution = options['distribution']

    if np.atleast_1d(discrimination).size == 1:
        discrimination = np.full(dataset.shape[0], discrimination,
                                 dtype="float")

    n_takers = dataset.shape[1]
    the_sign = convert_responses_to_kernel_sign(dataset)
    thetas = np.zeros((n_takers,))

    for ndx in range(n_takers):
        # pylint: disable=cell-var-from-loop
        scalar = the_sign[:, ndx] * discrimination

        def _theta_min(theta):
            otpt = 1.0 / (1.0 + np.exp(scalar * (theta - difficulty)))

            return -(np.log(otpt).sum() + np.log(distribution(theta)))

        # Solves for the ability for each person
        thetas[ndx] = fminbound(_theta_min, -6, 6)

    return thetas
Last modified April 7, 2020: Updating documentation. (3da0254)