psifr.fr.distance_rank_shifted#
- psifr.fr.distance_rank_shifted(df, index_key, distances, max_shift, item_query=None, test_key=None, test=None)#
Rank of transition distances relative to earlier items.
- 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.
max_shift (int) – Maximum number of items back for which to rank distances.
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:
See also
pool_index
Given a list of presented items and an item pool, look up the pool index of each item.
distance_rank
Rank of transition distances relative to the just-previous item.
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_shifted(data, 'item_index', distances, 3) >>> dist_rank subject shift rank 0 1 -3 0.523426 1 1 -2 0.559199 2 1 -1 0.634392 3 2 -3 0.475931 4 2 -2 0.507574 .. ... ... ... 115 46 -2 0.515332 116 46 -1 0.603304 117 47 -3 0.542951 118 47 -2 0.565001 119 47 -1 0.635415 [120 rows x 3 columns]