(1) What is the independent variable? What is the dependent variable?
In this dataset, we have taken control of the word/color congruency condition. The independent variable is whether the words shown are congruent with the ink colors or if they are incongruent with the ink colors. The dependent variable is 'Response Time'.
(2) What is an appropriate set of hypotheses for this task? Specify your null and alternative hypotheses, and clearly define any notation used. Justify your choices.
Even though there are a small number of rows in this dataset, we are treating this dataset as the entire population. As a result we are using μ as the population mean.
Symbol | Explanation |
---|---|
$$H_0:$$ | Null Hypothesis |
$${μ}_{congruent}$$ | The mean of the Congruent population's response times. |
$${μ}_{incongruent}$$ | The mean of the Incongruent population's response times. |
$$H_1$$ | Alternate Hypothesis |
$$H_0: {μ}_{congruent} - {μ}_{incongruent} = 0$$
We do not expect the Null Hypothesis to be true. This is the "negative" result. We do expect the mean of the response times for the incongruent columns to be higher. In keeping with standard statistical norms we will make the Null Hypothesis that the means are equal ("negative result"). This will be a two tailed test since the means will be tested diverging from each other in either direction (positive or negative).
The assumptions for these hypothesis are as follows:
(3) Report some descriptive statistics regarding this dataset. Include at least one measure of central tendency and at least one measure of variability. The name of the data file is 'stroopdata.csv'.
# Import packages
import pandas as pd
import scipy.stats as stats
stats.chisqprob = lambda chisq, df: stats.chi2.sf(chisq, df)
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
sns.set_style('darkgrid')
df = pd.read_csv('stroopdata.csv')
df.head()
The pandas dataframe .describe method (below) produces the required descriptive statistics. We have the means, standard deviations, and the 5 number summaries (min, max, and quartiles). For central tendency we have the two means (14.0511 and 22.0159). For variability we have the standard deviations (3.5593 and 4.7971). As well for variability we also have the minimum and maximum for both columns.
df.describe()
# Observed difference between means
obs_diff = 22.0159 - 14.0511
obs_diff
(4) Provide one or two visualizations that show the distribution of the sample data. Write one or two sentences noting what you observe about the plot or plots.
# Build the visualizations here
# Histograms for Congruent and Incongruent features
plt.figure(figsize=(8, 5))
plt.xlabel('Response Time')
plt.ylabel('Bin Height')
plt.hist(df['Congruent'], alpha=.5, label='Congruent')
plt.hist(df['Incongruent'], alpha=.5, label='Incongruent')
plt.title('Histogram of Congruent and Incongruent Features')
plt.legend();
From the overlaid histograms you can clearly see that that the entire data set is shifted to the right for the Incogruent Feature. This means that on average the Incongruent Feature's response times are much larger than the Congruent Feature's response times. The histogram's apparent means are also consistent with the df.describe() method that we used above.
df.plot(figsize=(8, 5), title='Paired Test With Response Times on Y Axis', kind='bar');
This bar chart is even more instructive. For every test, it shows that the Incongruent Feature's response time is higher. There are NO exceptions.
df.plot(figsize=(8, 5), title='Paired Test With Response Times on Y Axis', kind='box');
The boxplot is also quite instructive. As you can see Incongruent's data range is consistently higher than all of the similiar values on Congruent (e.g. median, quartiles, min, max). There are two outliers on Incongruent, that are considerably larger than anything else in either Feature.
df.sort_values('Incongruent')
(5) Now, perform the statistical test and report your results. What is your confidence level or Type I error associated with your test? What is your conclusion regarding the hypotheses you set up? Did the results match up with your expectations? Hint: Think about what is being measured on each individual, and what statistic best captures how an individual reacts in each environment.
# Perform the statistical test here
t, p = stats.ttest_rel(df.Congruent,df.Incongruent)
print('t-statistic =', t, 'p-value =', p)
(6) Optional: What do you think is responsible for the effects observed? Can you think of an alternative or similar task that would result in a similar effect? Some research about the problem will be helpful for thinking about these two questions!