Psych 45: N-back stats


In [41]:
%matplotlib inline

import pandas as pd
import seaborn as sns
sns.set(style='ticks', context='poster', font_scale=1.5)

Import data file


In [52]:
data = pd.read_csv('http://web.stanford.edu/class/psych45/demos/Psych45-nback_stats.csv')

# filter RT column so just a number (ms and comma not included)
data.avg_rt = data.avg_rt.str.strip(' ms').str.replace(',', '').astype(float)

task_list = ['2-back', '3-back', '4-back']

In [53]:
data.head()


Out[53]:
task percent_correct avg_rt combined when date_downloaded
0 3-back 40.00 962.18 2,405.45 16 hours ago 12:15 PM, Sunday
1 3-back 46.67 880.35 1,886.46 16 hours ago 12:15 PM, Sunday
2 3-back 86.67 894.30 1,031.88 16 hours ago 12:15 PM, Sunday
3 3-back 60.00 1069.83 1,783.04 16 hours ago 12:15 PM, Sunday
4 3-back 26.67 1258.98 4,721.18 16 hours ago 12:15 PM, Sunday

Analyses

Number of data points:


In [59]:
data.groupby(['task']).count().when


Out[59]:
task
2-back    25
3-back    25
4-back     4
Name: when, dtype: int64

Mean accuracy and response time:


In [63]:
data.groupby(['task']).mean().reset_index()


Out[63]:
task percent_correct avg_rt
0 2-back 77.622 889.6416
1 3-back 50.866 925.0708
2 4-back 54.285 781.2725

How does task affect percent of trials correct?


In [54]:
g = sns.factorplot(x='task', y='percent_correct', 
                   x_order=task_list,
                   data=data, 
                   palette='Set1', ci=68, 
                   aspect=1.5)
g.set_ylabels('% correct')
sns.despine(trim=True)


How does task affect average response time?


In [56]:
g = sns.factorplot(x='task', y='avg_rt', 
                   x_order=task_list,
                   data=data, 
                   palette='Set1', ci=68, 
                   aspect=1.5)
g.set_ylabels('avg RT')
sns.despine(trim=True)



In [ ]: