psifr.fr.distance_rank#

psifr.fr.distance_rank(df, index_key, distances, item_query=None, test_key=None, test=None)#

Calculate rank of transition distances in free recall lists.

Parameters:
  • df (pandas.DataFrame) – Merged study and recall data. See merge_lists. List length is assumed to be the same for all lists within each subject. Must have fields: subject, list, input, output, recalled. Input position must be defined such that the first serial position is 1, not 0.

  • index_key (str) – Name of column containing the index of each item in the distances matrix.

  • distances (numpy.array) – Items x items matrix of pairwise distances or similarities.

  • item_query (str, optional) – Query string to select items to include in the pool of possible recalls to be examined. See pandas.DataFrame.query for allowed format.

  • test_key (str, optional) – Name of column with labels to use when testing transitions for inclusion.

  • test (callable, optional) – Callable that takes in previous and current item values and returns True for transitions that should be included.

Returns:

stat – Has fields ‘subject’ and ‘rank’.

Return type:

pandas.DataFrame

See also

pool_index

Given a list of presented items and an item pool, look up the pool index of each item.

distance_crp

Conditional response probability by distance bin.

Examples

>>> from scipy.spatial.distance import squareform
>>> from psifr import fr
>>> raw = fr.sample_data('Morton2013')
>>> data = fr.merge_free_recall(raw)
>>> items, distances = fr.sample_distances('Morton2013')
>>> data['item_index'] = fr.pool_index(data['item'], items)
>>> dist_rank = fr.distance_rank(data, 'item_index', distances)
>>> dist_rank.head()
   subject      rank
0        1  0.635571
1        2  0.571457
2        3  0.627282
3        4  0.637596
4        5  0.646181