by Deadpool
21st of November, 2018
This app can calculate the absolute value of Cohen's d (effect size) from the data you used to calculate your t-test (MEAN of the FIRST sample, MEAN of the SECOND sample, STANDARD DEVIATION of the FIRST sample, STANDARD DEVIATION of the SECOND sample).
The output of calculation, along with brief interpretation, is displayed both as graph and text below it. Notice that d values above 3 will not be presented in the graph and that app throws an error as long as all 4 fields are not filled with relevant information.
library(shiny)
shinyUI(fluidPage(
titlePanel("Calculation of Cohen's d for t-test"),
sidebarLayout(
sidebarPanel(
helpText("Please input relevant information you collected from your data. The outcome will show you the absolute value of Cohen's d."),
numericInput("numericM1", "What was the MEAN of the FIRST sample?", value = 0),
numericInput("numericM2", "What was the MEAN of the SECOND sample?", value = 0),
numericInput("numericSD1", "What was the STANDARD DEVIATION of the FIRST sample?", value = 0),
numericInput("numericSD2", "What was the STANDARD DEVIATION of the SECOND sample?", value = 0),
helpText("For more information on Cohen's d, please visit: rpsychologist.com/d3/cohend/")
),
mainPanel(
h2("Cohen's d"),
helpText("Nowadays, it is usual to report the effect size along p-values. Cohen's d is one of such measures, and you can easily calculate it by providing the relevant statistics (Ms and SDs) obtained from your data. The error messages below will vanish once relevant data are provided."),
plotOutput("plotAjnc"),
textOutput("cohD"),
textOutput("comment")
)
)
))
library(shiny)
shinyServer(function(input, output){
output$plotAjnc <- renderPlot({
SDpool <- sqrt(((input$numericSD1^2)+(input$numericSD2^2))/2)
height <- (input$numericM1-input$numericM2)/SDpool
plot(abs(height), ylab = "Cohen's d", ylim = c(0, 3), col = "steelblue", pch = 20, cex = 3, xlab = "", xaxt = "n")
abline(h = 0)
abline(h = 0.3, col = "red", lty = 2)
abline(h = 0.6, col = "green", lty = 2)
axis(1, xaxt = "n")
})
output$cohD <- renderText({
cohenD <- (input$numericM1-input$numericM2)/sqrt(((input$numericSD1^2)+(input$numericSD2^2))/2)
paste("The value of Cohen's d is", abs(round(cohenD, 3)), ".")
})
output$comment <- renderText({
cohenD <- (input$numericM1-input$numericM2)/sqrt(((input$numericSD1^2)+(input$numericSD2^2))/2)
if(cohenD<0.3) {print("Size of the effect is small.")}
else if(c(cohenD>0.3 & cohenD<0.6)) {print("Size of the effect is medium.")}
else {print("Size of the effect is large.")}
})
})
Link to the app: https://deadpool.shinyapps.io/Cohens_d_calculator/