Attribute VB_Name = "eff_size_cohen_d_os" 'Created by Peter Stikker 'Companion website: https://PeterStatistics.com 'YouTube channel: https://www.youtube.com/stikpet 'Donations welcome at Patreon: https://www.patreon.com/bePatron?u=19398076 Public Sub es_cohen_d_os_addHelp() Application.MacroOptions _ Macro:="es_cohen_d_os", _ Description:="Calculate Cohen d'", _ category:=14, _ ArgumentDescriptions:=Array( _ "specific range with the numeric scores", _ "optional parameter to set the hypothesized mean. If not used the midrange is used", _ "optional parameter for rule of thumb for qualification. See th_cohen_d for details", _ "output to show, either value (default) or qual") Application.MacroOptions _ Macro:="es_cohen_d_os_arr", _ Description:="Calculate Cohen d'" & vbNewLine & "array function, requires 2 rows and 2 columns as output", _ category:=14, _ ArgumentDescriptions:=Array( _ "specific range with the numeric scores", _ "optional parameter to set the hypothesized mean. If not used the midrange is used", _ "optional parameter for rule of thumb for qualification. See th_cohen_d for details") End Sub Function es_cohen_d_os(data As Range, Optional hypMean = "none", Optional qual = "sawilowsky", Optional out = "value") 'Function to calculate Cohen's d for a one-sample t-test 'Parameters: data as a list of numbers and hypMean as the hypothesized mean Dim m, dif, s, d As Double If hypMean = "none" Then hypMean = (WorksheetFunction.Min(data) + WorksheetFunction.Max(data)) / 2 End If 'Calculate mean, difference with hyp. mean and standard deviation m = WorksheetFunction.Average(data) dif = m - hypMean s = WorksheetFunction.StDev(data) 'Determine Cohen's d d = dif / s 'Results If out = "value" Then res = d Else 'Qualification 'Adjust to regular Cohen d (for two-sample) abs_d_adj = Abs(d) * 2 ^ 0.5 Dim qualification As String qualification = th_cohen_d(abs_d_adj, qual) res = qualification End If es_cohen_d_os = res End Function Function es_cohen_d_os_arr(data As Range, Optional hypMean = "none", Optional qual = "sawilowsky") 'Function to calculate Cohen's d for a one-sample t-test 'Parameters: data as a list of numbers and hypMean as the hypothesized mean Dim m, dif, s, d As Double If hypMean = "none" Then hypMean = (WorksheetFunction.Min(data) + WorksheetFunction.Max(data)) / 2 End If 'Calculate mean, difference with hyp. mean and standard deviation m = WorksheetFunction.Average(data) dif = m - hypMean s = WorksheetFunction.StDev(data) 'Determine Cohen's d d = dif / s 'Qualification 'Adjust to regular Cohen d (for two-sample) abs_d_adj = Abs(d) * 2 ^ 0.5 'Use Cohen (1988, p. 40). Dim qualification As String qualification = th_cohen_d(abs_d_adj, qual) 'Results Dim res(1 To 2, 1 To 2) res(1, 1) = "Cohen d'" res(1, 2) = "Qualification" res(2, 1) = d res(2, 2) = qualification es_cohen_d_os_arr = res End Function