In: Statistics and Probability
R work (must be done in R)
Before opening the dataset needed for this problem, you’ll need to call the “car” package. Run the following line of code:
> library(car)
Now you can import the “ Cowles” dataset and use it to answer the question below.
Name the data frame with your EID:
> my_eid <- Cowles
Remember to include any code you use along with your answers in your submission!
3. Cowles and Davis (1987) collected data on the personality traits of individuals who volunteered (and didn’t volunteer) for psychological research. The researchers used Eysenck’s personality inventory to measure each participant’s neuroticism and extraversion score (on a scale of 0-24, with higher scores indicating more neurotic/ extraverted).
a. Create a graph to compare the distributions of extraversion scores between those who did and did not volunteer for psychological research.
b. Calculate the means and standard deviations of extraversion scores for each group of participants (split by volunteer status).
c. Carry out the appropriate test to determine if average extraversion score differs based on volunteer status. Include all steps for full credit.
Please see the R code below
library(car)
library(dplyr)
data("Cowles")
Cowles
# a
par(mfrow=c(1,2))
hist(Cowles$extraversion[Cowles$volunteer=="yes"],col="skyblue",main=
"Volunteer")
hist(Cowles$extraversion[Cowles$volunteer=="no"],col="purple",main=
"No Volunteer")
# b
Cowles %>% group_by(volunteer) %>% summarise(Average = mean(extraversion),SD = sd(extraversion))
# c) perform a t test
t.test(Cowles$extraversion[Cowles$volunteer=="yes"],Cowles$extraversion[Cowles$volunteer=="no"])
The results are
Cowles %>% group_by(volunteer) %>% summarise(Average =
mean(extraversion),SD = sd(extraversion))
# A tibble: 2 x 3
volunteer Average SD
<fct> <dbl> <dbl>
1 no 12.0 3.83
2 yes 12.9 3.91
t.test(Cowles$extraversion[Cowles$volunteer=="yes"],Cowles$extraversion[Cowles$volunteer=="no"])
Welch Two Sample t-test
data: Cowles$extraversion[Cowles$volunteer == "yes"] and Cowles$extraversion[Cowles$volunteer == "no"]
t = 4.6907, df = 1270.1, p-value = 3.018e-06 # as the p value is less than 0.05 , hence the results are statisitcally significant for the model
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
0.5685632 1.3860765
sample estimates:
mean of x mean of y
12.93970 11.96238