Scaling data using cohens d

2 views (last 30 days)
Jorge Young
Jorge Young on 21 Mar 2025
Answered: Ishaan on 24 Apr 2025
I have 2 data sets. Data1, Data2. Data1 has a cohens d effect size of approximately 0.5141. How can I scale Data2 using this effect size? Any help would be great, I am very novice at coding. Thank you.
  3 Comments
Jorge Young
Jorge Young on 21 Mar 2025
I appreciate the response and I understand it is very vague. Cohens d in this instance is the effect some variable had on data set 1. If that same variable was introduced to data set 2 the assumption is that the shift would be the same. I do not know how to shift the distribution of data set 2 to the same effect as data set 1. hopefully this is enough background. thanks.
dpb
dpb on 21 Mar 2025
Without a lot more information to go on, I'd say just add the difference in means if the assumption is the effect is the same.

Sign in to comment.

Answers (1)

Ishaan
Ishaan on 24 Apr 2025
I notice that you intend to scale the 2nd dataset in a way that a variable has the same effect on it as the 1st dataset.
To achieve this, you need to translate that standardized difference into a raw shift in 2nd dataset’s values. There are 2 ways you can go about it.
NOTE: These strategies assume that the conditions for underlying the use of Cohen's d are met, such as normality and homogeneity of variances, especially when applying these methods to real-world data.
1. Using 2nd dataset’s own standard deviation
s2 = std(Data2); % Compute standard deviation of Data2
delta = cohens_d * s2; % Compute the shift
Data2_shifted = Data2 + delta; % Shift Data2
This will shift the 2nd dataset by Cohen’s D times the original standard deviation. Hence making the standardized shift relative to the original spread equal to the Cohen’s d value.
Use this method if you believe the intervention has the same relative strength (i.e. same standardized effect) in each dataset.
2. Using the absolute shift observed in 1st dataset.
If you have access to the absolute shift observed in the 1stdataset, then you can just add that to the 2nd dataset. This approach treats the intervention as having the same number of “units” of change irrespective of the measurement you’re using. For clarity, the absolute shift is the same as the Cohen’s d times the pooled standard deviation.
Use this method if both datasets have identical measurement scales and variances.
Here is a sample code snippet for both the options.
% Example data
rng(0); % For reproducibility
Data1_control = 50 + 10 * randn(100,1);
Data1_treatment = 55 + 10 * randn(100,1);
Data2 = 30 + 5 * randn(100,1);
% Compute Cohen's d for the 1st dataset
s1_control = std(Data1_control,0);
s1_treatment = std(Data1_treatment,0);
n1 = numel(Data1_control);
n2 = numel(Data1_treatment);
pooled_sd = sqrt(((n1-1)*s1_control^2 + (n2-1)*s1_treatment^2)/(n1+n2-2));
cohens_d_est = (mean(Data1_treatment) - mean(Data1_control)) / pooled_sd; % 0.5141
% Option 1: Scale based on 2nd dataset’s own spread
s2 = std(Data2, 0);
delta1 = cohens_d_est * s2;
Data2_shifted1 = Data2 + delta1;
% Option 2: Scale based on raw effect from the 1stdataset
delta2 = cohens_d_est * pooled_sd;
Data2_shifted2 = Data2 + delta2;
Hope this helped!

Categories

Find more on MATLAB Report Generator in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!