wesleyk079/statistic_functionalities

Library that contains two classes: Correlation & Deviation. These classes can be used to calculate standard deviation and spearman's rank correlation.

Installs: 204

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/wesleyk079/statistic_functionalities

dev-master 2019-01-24 10:36 UTC

This package is auto-updated.

Last update: 2026-01-25 10:58:50 UTC


README

This repository is made for solutions involving software from NewCompliance B.V Group

The functions included in this library will calculate deviation and correlation in from a JSON file.

The demo included will give you an example on how to make use of this library

Install the library

Require the library in your composer.json

composer require wesleyk079/statistic_functionalities "dev-master"

Make sure your framework or php-script loads the 'autoload.php' from composer's vendor directory.

#1 Deviation

Include the library:

Use 'statisticFunctionalities\functions\Deviation';

Adjust the options as wanted

//example for setting the options
$options = [
    "FileToCheck"               => json_decode(file_get_contents("../generatedFiles/generatedInformation.json")),
    "KeyToSelect"               => "Verrichting 1",
    "KeyToSearchFor"            => "Operatieduur",
    "RemoveOutliers"            => true,
    "SecondComparison"          => true,
    "SecondKeyToFindDeviation"  => "Geplande duur",
    "FirstCategoryMax"          => 20,
    "MiddleCategoryMax"         => 60,
    "FirstPercentageMeasure"    => 20,
    "MiddlePercentageMeasure"   => 12.5,
    "LastPercentageMeasure"     => 10,
    "PositiveFeedback"          => "Wel goed in te schatten",
    "NegativeFeedback"          => "Niet goed in te schatten"

];

Initialize the deviation class

$deviation = new statisticFunctions\Deviation($options);

Get the results

$deviationResults = $deviation->GetDeviationStatistics();

What does my result contain?

The following keys will be available from all results in the returned array

amount - the amount of measured cases

mean - the mean of all meaasured numbers

standardDev - standard deviation (1 time)

statisticMin - mean - (standarddeviation * 3)

statisticMax - mean + (standarddeviation * 3)

lowerThanComparison - Amount of cases where the number lower than the comparison number

higherThanComparison - Amount of cases where the number was higher than the comparison number

Advice - Advice as stated at the settings (positive or negative feedback). If (standarddeviation * 3) is smaller than (mean * percentage), it will be positive. The percentage will be taken from the percentageMeasure based on categories.

Example on how to treat the results

foreach($deviationResults as $result){
    <p>
    There were <?= $operation["amount"] ?> cases that included '<?= $caseTitle ?>' as <?= $options["KeyToSelect"] ?>.
        
    The data was divided by a standard deviation of ' ~ <?= intval($operation["standardDev"]) ?>' 
    </p>
    
    <p>
    This means in 68.26% of the cases, <?= $options["KeyToSearchFor"] ?> will be
    between <?= intval($operation["mean"] - $operation["standardDev"] * 1) 
    ?>
}

#2 Correlation

Change options to your personal wishes and settings

Include the library:

Use 'statisticFunctionalities\functions\Correlation';

Adjust the options as wanted

//example for setting the options
$options = [
    "FileToCheck"           => json_decode(file_get_contents("../generatedFiles/generatedInformation.json")),
    "KeyToSearchFor"        => "Operatieduur",
    "KeyToSelect"           => "Verrichting 1",
    "ValueForKeyToSelect"   => "Verwijderen buisjes uit oren",
    "ExcludeKeywords"       => ["Patiƫntnummer", "Casusnummer"]
];

Initialize the deviation class

$correlation = new statisticFunctions\Correlation($options);

Get the results

$results = $correlation->calculateCorrelations();

What does my result contain?

xTitle - Title of the x-axis that was being measured

yTitle - Title of the y-axis that was being measured

coefficient - the correlation coefficient between the values of xTitle and yTitle

These results can be used to get a advise if wanted

<!--Example on how to treat the data-->
<?php foreach ($all as $result): ?>
    <?= $correlation->getCorrelationAdvise($result["coefficient"], $result["xTitle"], $result["yTitle"]); ?><br/><br/>
    //Result: The variable 'Operatieduur' looks like growing when 'Wond open (min)' is higher. The correlation is stated as moderate correlation: 0.51029910576627

<?php endforeach; ?>