PHP syntax for calculating WWC standardized group difference (Hedges' g and Cox Index)

<?php
function compute()
{
    $Tmean = $_POST['Tmean'];
    $Cmean = $_POST['Cmean'];
    $TSD = $_POST['TSD'];
    $CSD = $_POST['CSD'];
    $TN = $_POST['TN'];
    $CN = $_POST['CN'];
$mean_dif=$Tmean-$Cmean;
$SE=sqrt(
(($TSD*$TSD) / $TN)+(($CSD*$CSD) / $CN)
);
$T=$mean_dif/$SE;
$DF=$TN+$CN-2;
$P="Under Development (Still working on this)";
/*$P=stats_dens_normal($T, 0,1);*/
/*$P=stats_dens_gamma(float $X, float $shape, float $scale);*/
/*$P= $T / 100 ;*/
/*Hedges g*/
/*g numerator*/
$g_numerator=($Tmean-$Cmean)*(1-3/((4*($TN+$CN))-9));
/*g demnominator*/
$g_denominator=SQRT(((($TN-1)* ($TSD**2) )+(($CN-1)* ($CSD**2) ))/($TN+$CN-2));
$hedges_d=$g_numerator/$g_denominator;
$hedges_d_abs=abs($hedges_d);
/*if binary variabels*/
$T_Odds=$Tmean/(1-$Tmean);
$C_Odds=$Cmean/(1-$Cmean);
$Odds_ratio=$T_Odds/$C_Odds;
$Tstep1=log($T_Odds);
$Cstep1=log($C_Odds);
$step2=$Tstep1-$Cstep1;
$WWC_binary_effect=$step2/1.65;
/*Use omega factor to adjust for data size*/
$total_num=$TN + $CN;
$omega=(1-3/( 4*$total_num -9));
$WWC_binary_effect_omega=($omega*$step2)/1.65;
/*
if ($hedges_d >= 0.2) echo "Small Effect (Cohen)";
if ($hedges_d >= 0.5) echo "Medium Effect (Cohen)";
if ($hedges_d >= 0.8) echo "Large Effect (Cohen)";
*/
echo "<br>";
echo "WWC group comparison of continuous variables";
echo "<br>";
echo "<br>";
echo "Values you entered:";
echo "<br>";
echo "<br>";
echo "Treatment N:" .$TN;
echo "<br>";
echo "Treatment mean:" .$Tmean;
echo "<br>";
echo "Treatment SD:" .$TSD;
echo "<br>";
echo "Comparison N:" .$CN;
echo "<br>";
echo "Comparison mean:" .$Cmean;
echo "<br>";
echo "Comparison SD:" .$CSD;
echo "<br>";
echo "The group mean difference:".round($mean_dif,2);
echo "<br>";
echo "without rounding:".round($mean_dif,5);
echo "<br><br>";
/*echo "Probability " .round($P,2);*/
echo "Probability: " .$P;
echo "<br>";
$abs_T=abs($T);
echo "T-score is: " .round($T,2);
echo "<br>";
echo "without rounding: " .round($T,5);
echo "<br>";
if($abs_T < 1.96 ) {
    echo "Not significant at alpha 0.05 (two tail test;I used a z-test and ignored degree of freedom; threshold 1.96)";
}elseif($abs_T >=1.96){
echo "Significant at alpha 0.05 (two tail test;I used a z-test and ignored degree freedom; threshold 1.96)";
}
echo "<br>";
echo "<br>";
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";echo "<br>";
echo "If a variable is an interval scale:";
echo "<br>";
echo "Hedges g " .round($hedges_d,2);
echo "<br>";
echo "without rounding: " .round($hedges_d,5);
echo "<br>";
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";echo "<br>";
echo "<br>";
echo "<br>";
echo "Hedges g description";
echo "<br>";
echo "Page 16 of https://ies.ed.gov/ncee/wwc/Docs/referenceresources/WWC_Procedures_Handbook_V4_1_Draft.pdf";
echo "<br>";
echo "<br>";
echo "For continuous outcomes, the WWC has adopted the most commonly used effect size";
echo "<br>";
echo "index, the standardized mean difference known as Hedges’ g, with an adjustment for small";
echo "<br>";
echo "sample bias. For group design studies, this effect size is defined as the difference between the";
echo "<br>";
echo "mean outcome for the intervention group and the mean outcome for the comparison group, ";
echo "<br>";
echo "divided by the pooled within-group standard deviation of the outcome measure. Defining yi and ";
echo "<br>";
echo "yc as the means of the outcome for students in the intervention and comparison groups, ni and nc";
echo "<br>";
echo "as the student sample sizes, si and sc as the student-level standard deviations, given by ....";
echo "<br>";
echo "In addition, we define as the small sample size correction the effect size (Hedges 1981), which is given by ";
echo "<br>";
echo "<br>";
echo "<br>";
/*cohen's rule of thumb*/
echo "Cohen's rule of thumb";echo "<br>";
echo "if d >= 0.2 small effect -- if d >= 0.5 medium effect if --- d >= 0.8 large effect";echo "<br>";
if($hedges_d_abs < 0.2) {
    echo "Close to zero and Not even small Effect (Cohen)";
}elseif($hedges_d_abs>=0.2 and $hedges_d_abs < 0.5){
echo "Small effect (Cohen)";
}elseif($hedges_d_abs>=0.5 and $hedges_d_abs < 0.8){
echo "Medium effect (Cohen)";
}elseif($hedges_d_abs>=0.8){
echo "Large effect (Cohen)";
}else {
    echo "others";
}
echo "<br>";
echo "<br>";
echo "If a variable is obviously a continuous variable (e.g., MAX is greater than 1), ignore the result below (It says NAN)";
echo "<br>";
echo "<br>";
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";echo "<br>";
echo "If the variable is a binary variable (0 or 1), the Cox index value is " .round($WWC_binary_effect,2);
echo "<br>";
echo "with a lot of digits without rounding " .round($WWC_binary_effect,5);echo "<br>";
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";echo "<br>";
echo "<br>";
echo "<br>";
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";echo "<br>";
echo "Omega adjusted (data size taken into consideration) " .round($WWC_binary_effect_omega,2);
echo "<br>";
echo "with a lot of digits without rounding " .round($WWC_binary_effect_omega,5);
echo "<br>";
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";echo "<br>";
echo "<br>";
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";echo "<br>";
echo "Odds ratio:" .round($Odds_ratio,2);
echo "<br>";
echo "without rounding " .round($Odds_ratio,5);
echo "<br>";
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";echo "<br>";
echo "<br>";
echo "Cox Index description";
echo "<br>";
echo "Page 16 of https://ies.ed.gov/ncee/wwc/Docs/referenceresources/WWC_Procedures_Handbook_V4_1_Draft.pdf";
echo "<br>";
echo "<br>";
echo "For dichotomous outcomes, the difference in group means is calculated as the difference in";
echo "<br>";
echo "the probability of the occurrence of an event. The effect size measure of choice for dichotomous ";
echo "<br>";
echo "outcomes is the Cox index, which yields effect size values similar to the values of Hedges’ g that";
echo "<br>";
echo "one would obtain if group means, standard deviations, and sample sizes were available, assuming";
echo "<br>";
echo "the dichotomous outcome measure is based on an underlying logistic similar to a normal";
echo "<br>";
echo "distribution. Defining pi and pc as the probability of an outcome for students in the intervention";
echo "<br>";
echo "and comparison groups, the effect size is given by";
echo "<br>";
echo "";
echo "<br>";
}
/*echo "The result is: " . compute();*/
compute();
?>
<br>
REFERENCE
<br>
Cohen's rule of thumb about effect sizes:
<br>
<li>If greater than 02, Small Effect
<br>
<li>If greater than 0.5, Medium Effect
<br>
<li>If greater 0.8 then Large Effect
<br>
Cohen, J. Statistical power for the behavioral sciences (2nd ed.). Hillsdale, NJ: Erlbaum (1988).
<br>
<ahref="https://wmich.edu/sites/default/files/attachments/u58/2015/Effect_Size_Substantive_Interpretation_Guidelines.pdf">
Effect Size Substantive Interpretation Guidelines: Issues in the Interpretation of Effect Sizes Jeff Valentine and Harris Cooper, Duke University(see page. 5)</a>
<br>
<br>
WWC related info:
<br>
<a href="https://ies.ed.gov/ncee/wwc/Docs/ReferenceResources/wwc_procedures_handbook_v4_draft.pdf">WWC procedures handbook (see page. 14)</a>
<br>
<a href="https://ies.ed.gov/ncee/wwc/Docs/OnlineTraining/wwc_training_m3.pdf">WWC standards slides (Definition of small sample size correction, slide 14)</a>
<br>
WWC considers the effect size greater than .25 substnatively important.
<a href="https://ies.ed.gov/ncee/wwc/Docs/referenceresources/wwc_procedures_handbook_v4.pdf">P.22 of WWC standards</a>
<br>
<br>
<a href="calc_t_test1.php">Back to the calculcator </a>
<br>
<a href="https://www.estat.us">My website</a>
<br>
Look at calc process t..1
<br>

Leave a Reply