Comparing to a Reference Population
Another metric that can be calculated using the engine is "How an individual compares to a reference population". For example, if we take the SPoRT algorithm (whose outcome is the risk of a stroke) and a reference population like Canada, and pass in your individual data (your age, sex, diet etc.) the engine can tell you your age in the reference population.
If you haven't read the tutorial on how to build a model (available here) please do so.
Building the reference population methods requires 2 arguments, a model object and a reference population object. The tutorial mentioned above shows you how to build a model object.
We provide several reference population files for each model, which are present within the folder for each model in the pbl-calculator-engine-assets node module (instructions on how to install the module available here)
You can also build your own reference population file by evaluating the model on individuals and using the outputted risk to populate the risk field in the file.
The following example goes through initializing the reference population function and calculating the metric
/* The builder object for reference population calculations */
import { RefPopFunctionsBuilder } from '@ottawamhealth/pbl-calculator-engine';
/* Assume this has been instantiated*/
const sportModel;
/* Parse the reference population json object. Look within the ref-pops folder
within each model folder for the ref-pop files */
const referencePopulation = require(
'@ottawamhealth/pbl-calculator-engine-assets/SPoRT/ref-pops/healthy.json'
);
/* Initialize the reference population functions using the sportModel object and
reference population objects parsed above */
const RefPopFunctions = RefPopFunctionsBuilder
.withModel(sportModel)
.withRefPop(referencePopulation);
/* Data of the individual we will use. For more information look at the
Building Your Data section */
const sportData = [
{ name: 'age', coefficent: 21 },
{ name: 'sex', coefficent: 'male' }
]
/* Get the age of the above indivudual in the above population. We call this
health age */
const healthAge = RefPopFunctions
.getHealthAge(sportData);
Things to note:
- The data we are passing into the getHealthAge function is the data we would pass into the methods for evaluating the model we build the functions with
- Look at the Building Your Data section with regards to the data arg
For the list of all the RefPopFunctions available go here