Project 1- Test a Perceptual Phenomenon

Project summary - Congruent vs Incongruent

1) What is our independent variable? What is our dependent variable?

1)Independent variable:It can be be congruent or incongruent. 2)Dependent variable:It is time that takes for complete the task by the participant

2) What is an appropriate set of hypotheses for this task? What kind of statistical test do you expect to perform? Justify your choices.

The two-tailed t-test is the appropriate methods for this sample of data: The dataset does not include population μ and σ. Therefore, we cannot conduct a z-test. We can compare two means from 2 samples and calculate the standard deviation and confidence level 1)The null hypotheses is: The average time it takes to complete the incongruent test is less than or equal to the average time needed to complete the congruent test.

2)The alternative hypotheses is: The average time it takes to complete the incongruent test is more than the average time needed to complete the congruent test.

=>µx = incongruent condition population mean =>µy = congruent condition population =>µD = µx - µY =>H0: µD = 0 =>HA: µD ≠ 0 (two-tailed test)

In [9]:
import pandas as pd
import matplotlib.pyplot as plt
import math
df = pd.read_csv(r'stroopdata.csv')
df["p-id"]= df.index +1
df
Out[9]:
Congruent Incongruent p-id
0 12.079 19.278 1
1 16.791 18.741 2
2 9.564 21.214 3
3 8.630 15.687 4
4 14.669 22.803 5
5 12.238 20.878 6
6 14.692 24.572 7
7 8.987 17.394 8
8 9.401 20.762 9
9 14.480 26.282 10
10 22.328 24.524 11
11 15.298 18.644 12
12 15.073 17.510 13
13 16.929 20.330 14
14 18.200 35.255 15
15 12.130 22.158 16
16 18.495 25.139 17
17 10.639 20.429 18
18 11.344 17.425 19
19 12.369 34.288 20
20 12.944 23.894 21
21 14.233 17.960 22
22 19.710 22.058 23
23 16.004 21.157 24

The two-tailed t-test is the appropriate methods for this type of sample:

 a)We cannot conduct a z-test since the sample doesnot include population μ and σ. 
 b)Since we can calculate the means of congruent and uncongruent we can apply T test.

3)descriptive statistics regarding this dataset.

The below code will give stats like mean,std of Congruent and Incongruent timings

In [22]:
thereult = df.describe()
thereult[1:3]
Out[22]:
Congruent Incongruent p-id time-diff
mean 14.051125 22.015917 12.500000 7.964792
std 3.559358 4.797057 7.071068 4.864827

The below code will give median value of Congurent

In [23]:
median_of_Congruent = df['Congruent'].median()
median_of_Congruent
Out[23]:
14.3565

The below code will give median value of Incongruent

In [24]:
median_of_Incongruent = df['Incongruent'].median()
median_of_Incongruent
Out[24]:
21.0175
  1. 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.
In [54]:
plt.hist(df['time-diff'].values,bins=10)
plt.xlabel("Time-diff")
plt.ylabel("Frequency")
plt.title("Histogram of time difference ")
plt.xticks(range(0, 25, 2))
plt.show()

From the above graph we came to know that the time-difference is between 2 to 12 seconds and average time difference is around 7.5 to 8.3There are two outliers in this data in between 16-18 and 20-22

5) Statistical test & result

Confidence Interval=90% α=0.1 T−critical=+1.714,−1.714

In [4]:
y=df['Incongruent']
x=df['Congruent']
d=y-x
d
Out[4]:
0      7.199
1      1.950
2     11.650
3      7.057
4      8.134
5      8.640
6      9.880
7      8.407
8     11.361
9     11.802
10     2.196
11     3.346
12     2.437
13     3.401
14    17.055
15    10.028
16     6.644
17     9.790
18     6.081
19    21.919
20    10.950
21     3.727
22     2.348
23     5.153
dtype: float64
In [6]:
mean_d=d.mean()
mean_d
Out[6]:
7.9647916666666658
In [10]:
#standard error of the mean difference
sdd = d.std()/math.sqrt(24)
sdd
Out[10]:
0.99302863477834058
In [11]:
t_statistic=mean_d/sdd
t_statistic
Out[11]:
8.020706944109957

Result: We can regect null hypothesis since there is no much difference in responce time (t-statistic = 8.027 > t-critical = 1.714). The avg time that takes by the person to complete the test in an incongruent setting is longer than congruent setting test.

In [1]:
 
In [ ]: