Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Team 36
- ##########
- ### STEP 0
- ##########
- load("AllData.Rdata")
- ##########
- ### STEP 1
- ##########
- ### 1. Difficulty of the task. The levels are
- ### "Easy scrabble" and "Hard scrabble".
- ### 2. Number of correctly generated words that are unique.
- ### 3. H0: The number of correctly generated words doesn't depend on the difficulty of the task.
- ### H1: The number of correctly generated words depends on the difficulty of the task.
- ##########
- ### STEP 2
- ##########
- ### creating the subset we will use
- participants2018 <- allData[allData$SubjectNr >= 301 & allData$SubjectNr <= 348,]
- dualTaskSet <- participants2018[participants2018$partOfExperiment == "dualTask",]
- dualTaskSet <- droplevels(dualTaskSet)
- levels(dualTaskSet$partOfExperiment)
- ### end of trials
- library(plyr)
- allDataEndOfTrialsDualTaskOnly <-
- ddply(dualTaskSet, .(SubjectNr, TrialNumber, scrabbleCondition), summarize,
- nrCorrectScrabbleWords = max(nrCorrectScrabbleWords)
- )
- ### avg number of scrabble words
- withoutNeutral <-
- allDataEndOfTrialsDualTaskOnly[
- allDataEndOfTrialsDualTaskOnly$scrabbleCondition != "neutral",
- ]
- averageNrScrabbleWords <-
- with(withoutNeutral,
- aggregate(nrCorrectScrabbleWords,
- list(SubjectNr=SubjectNr,scrabbleCondition=scrabbleCondition),
- mean))
- colnames(averageNrScrabbleWords)[3] <- "averageScrabbleWords"
- ##########
- ### STEP 3
- ##########
- levels(averageNrScrabbleWords$scrabbleCondition)
- averageNrScrabbleWords2 <- droplevels(averageNrScrabbleWords)
- library(ggplot2)
- my_plot <- ggplot(averageNrScrabbleWords2, aes(x=scrabbleCondition, y=averageScrabbleWords)) +
- geom_boxplot(stat = "boxplot")
- my_plot
- scrabbleConditionMeans <- with(averageNrScrabbleWords2, tapply(averageScrabbleWords, list(scrabbleCondition),mean))
- barplot(height=scrabbleConditionMeans, main="Average Number of Scrabble Words Generated", ylim=c(0,12))
- ###
- ### So far, the pattern we observe in our plots is in line with our hypothesis.
- ### We expected the easy condition to be larger than the hard condition and this
- ### is indeed the case.
- ###
- ### A within-subjects design has been used.
- ###
- source("usefulFunctions.R")
- summaryScrabble <- summarySEwithin(averageNrScrabbleWords2,
- measurevar="averageScrabbleWords", withinvars=c("scrabbleCondition"))
- print(summaryScrabble)
- library(ggplot2)
- g1 <- ggplot(summaryScrabble, aes(x=scrabbleCondition, y=averageScrabbleWords)) +
- geom_bar(stat="identity") +
- geom_errorbar(aes(ymin=averageScrabbleWords-sd, ymax=averageScrabbleWords+sd), width=.2) +
- ylab("Average Number of Words") +
- xlab("Task Difficulty") +
- ggtitle("Standard Deviation") +
- scale_y_continuous(limits = c(0, 20))
- g2 <- ggplot(summaryScrabble, aes(x=scrabbleCondition, y=averageScrabbleWords)) +
- geom_bar(stat="identity") +
- geom_errorbar(aes(ymin=averageScrabbleWords-se, ymax=averageScrabbleWords+se), width=.2) +
- ylab("Average Number of Words") +
- xlab("Task Difficulty") +
- ggtitle("Standard Errors") +
- scale_y_continuous(limits = c(0, 20))
- g3 <- ggplot(summaryScrabble, aes(x=scrabbleCondition, y=averageScrabbleWords)) +
- geom_bar(stat="identity") +
- geom_errorbar(aes(ymin=averageScrabbleWords-ci, ymax=averageScrabbleWords+ci), width=.2) +
- ylab("Average Number of Words") +
- xlab("Task Difficulty") +
- ggtitle("Confidence interval") +
- scale_y_continuous(limits = c(0, 20))
- library(cowplot)
- print(plot_grid(g1,g2,g3, ncol = 3))
- ###
- ### Since the 95% CI bars do not overlap, we expect that in the experiment
- ### the two conditions will differ in line with our hypothesis H1.
- ###
- ##########
- ### STEP 4
- ##########
- summaryScrabble$lower <- summaryScrabble$averageScrabbleWords - summaryScrabble$ci
- summaryScrabble$upper <- summaryScrabble$averageScrabbleWords + summaryScrabble$ci
- ##########
- ### STEP 5
- ##########
- with(averageNrScrabbleWords2,t.test(averageScrabbleWords~ scrabbleCondition,paired=TRUE))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement