Skip to content

Instantly share code, notes, and snippets.

@Lakens
Created October 29, 2015 11:15
Show Gist options
  • Save Lakens/2e782d347ce8c11d178c to your computer and use it in GitHub Desktop.
Save Lakens/2e782d347ce8c11d178c to your computer and use it in GitHub Desktop.
#Additional Analyses of Nuijten et al: https://mbnuijten.files.wordpress.com/2013/01/nuijtenetal_2015_reportingerrorspsychology1.pdf
#First run the original script to read in the data: https://osf.io/e9qbp/
#Select only errors.
subdata<-subset(data, data$Error == TRUE)
subdata$pdif<-subdata$Reported.P.Value-subdata$Computed #Compute difference in p-values.
#Plot differences in reported and computed p-values for all errors
ggplot(as.data.frame(subdata$pdif), aes(subdata$pdif)) +
geom_histogram(colour="black", fill="grey", binwidth = 0.01) + ggtitle("All Errors") + xlab("Reported P-value minus Computed P-value") + ylab("Frequency") + theme_bw(base_size=20)
subdatanull<-subset(subdata, subdata$Reported.P.Value == 0) #Select only p= 0 - 1279 cases
#Select cases computed p <= 0.06, reported p < 0.05 - 933 cases
subdataErrorRound<-subset(subdata, subdata$Reported.P.Value == 0.05 & subdata$Computed <= 0.06 & subdata$Reported.Comparison == "<")
#Select cases computed p < 0.055, reported p < 0.05 - 692
subdataErrorRound<-subset(subdata, subdata$Reported.P.Value == 0.05 & subdata$Computed < 0.055 & subdata$Reported.Comparison == "<")
#Select cases computed p > 0.055 & < 0.06, reported p < 0.05 - 241
subdataErrorRound<-subset(subdata, subdata$Reported.P.Value == 0.05 & subdata$Computed < 0.06 & subdata$Computed >= 0.055 & subdata$Reported.Comparison == "<")
#Select cases computed p < 0.055, reported p = 0.05 - 128
subdataErrorRound<-subset(subdata, subdata$Reported.P.Value == 0.05 & subdata$Computed <= 0.06 & subdata$Computed >= 0.055 & subdata$Reported.Comparison == "=")
#Select only decision errors.
subdataDecError<-subset(data, data$DecisionError == TRUE,na.rm=TRUE)
#Plot the differences in p-values
ggplot(as.data.frame(subdataDecError$pdif), aes(subdataDecError$pdif)) +
geom_histogram(colour="black", fill="grey", binwidth = 0.01) + ggtitle("Decision Errors") + xlab("Reported P-value minus Computed P-value") + ylab("Frequency") + theme_bw(base_size=20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment