[WIP] Implement growth assessment using WHO indicators #80
@ -2,9 +2,9 @@ defmodule Growth.Calc.Centile do
|
|||||||
@moduledoc """
|
@moduledoc """
|
||||||
Calculate percentile for a given measurement and the fitted values of Box-Cox by age/height:
|
Calculate percentile for a given measurement and the fitted values of Box-Cox by age/height:
|
||||||
|
|
||||||
* power
|
* **power** `t:Growth.Calc.ZScore.l/0`
|
||||||
* median
|
* **median** `t:Growth.Calc.ZScore.m/0`
|
||||||
* coefficientof variation
|
* **coefficientof variation** `t:Growth.Calc.ZScore.s/0`
|
||||||
|
|
||||||
This calculation is described in the [instructions provided by the World Health Organization](https://cdn.who.int/media/docs/default-source/child-growth/growth-reference-5-19-years/computation.pdf).
|
This calculation is described in the [instructions provided by the World Health Organization](https://cdn.who.int/media/docs/default-source/child-growth/growth-reference-5-19-years/computation.pdf).
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ defmodule Growth.Calc.Centile do
|
|||||||
|
|
||||||
alias Growth.Calc.ZScore
|
alias Growth.Calc.ZScore
|
||||||
|
|
||||||
@spec compute(number(), number(), number(), number()) :: number() | :na
|
@spec compute(number(), ZScore.l(), ZScore.m(), ZScore.s()) :: number() | :na | nil
|
||||||
@doc """
|
@doc """
|
||||||
Compute the centile for a given measurement (`y`) and the Box-Cox values: power (`l`), median (`m`), and
|
Compute the centile for a given measurement (`y`) and the Box-Cox values: power (`l`), median (`m`), and
|
||||||
coefficient of variation (`s`).
|
coefficient of variation (`s`).
|
||||||
@ -36,6 +36,10 @@ defmodule Growth.Calc.Centile do
|
|||||||
19.0
|
19.0
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
def compute(nil, _, _, _) do
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
def compute(y, l, m, s) do
|
def compute(y, l, m, s) do
|
||||||
zscore = ZScore.raw(y, l, m, s)
|
zscore = ZScore.raw(y, l, m, s)
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@ defmodule Growth.Calc.ZScore do
|
|||||||
@moduledoc """
|
@moduledoc """
|
||||||
Calculate z-score for a given measurement and the fitted values of Box-Cox by age/height:
|
Calculate z-score for a given measurement and the fitted values of Box-Cox by age/height:
|
||||||
|
|
||||||
* power
|
* **power** `t:l/0`
|
||||||
* median
|
* **median** `t:m/0`
|
||||||
* coefficientof variation
|
* **coefficientof variation** `t:s/0`
|
||||||
|
|
||||||
This calculation is described in the [instructions provided by the World Health Organization](https://cdn.who.int/media/docs/default-source/child-growth/growth-reference-5-19-years/computation.pdf).
|
This calculation is described in the [instructions provided by the World Health Organization](https://cdn.who.int/media/docs/default-source/child-growth/growth-reference-5-19-years/computation.pdf).
|
||||||
|
|
||||||
@ -21,7 +21,20 @@ defmodule Growth.Calc.ZScore do
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@spec compute(number(), number(), number(), number()) :: number()
|
@typedoc """
|
||||||
|
The **power** value in Box-Cox transformation.
|
||||||
|
"""
|
||||||
|
@type l :: number()
|
||||||
|
@typedoc """
|
||||||
|
The **median** value in Box-Cox transformation.
|
||||||
|
"""
|
||||||
|
@type m :: number()
|
||||||
|
@typedoc """
|
||||||
|
The **coefficient of variation** in Box-Cox transformation.
|
||||||
|
"""
|
||||||
|
@type s :: number()
|
||||||
|
|
||||||
|
@spec compute(number(), l(), m(), s()) :: Growth.measure()
|
||||||
@doc """
|
@doc """
|
||||||
Compute the adjusted z-score for a given measurement (`y`) and the Box-Cox values: power (`l`), median (`m`), and
|
Compute the adjusted z-score for a given measurement (`y`) and the Box-Cox values: power (`l`), median (`m`), and
|
||||||
coefficient of variation (`s`).
|
coefficient of variation (`s`).
|
||||||
@ -36,13 +49,18 @@ defmodule Growth.Calc.ZScore do
|
|||||||
1.4698319520484722
|
1.4698319520484722
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def compute(nil, _, _, _) do
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
def compute(y, l, m, s) do
|
def compute(y, l, m, s) do
|
||||||
y
|
y
|
||||||
|> raw(l, m, s)
|
|> raw(l, m, s)
|
||||||
|> adjust(y, l, m, s)
|
|> adjust(y, l, m, s)
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec raw(number(), number(), number(), number()) :: number()
|
@spec raw(number(), l(), m(), s()) :: number()
|
||||||
@doc """
|
@doc """
|
||||||
Compute the raw z-score for a given measurement (`y`) and the Box-Cox values, power (`l`), median (`m`), and
|
Compute the raw z-score for a given measurement (`y`) and the Box-Cox values, power (`l`), median (`m`), and
|
||||||
coefficient of variation (`s`).
|
coefficient of variation (`s`).
|
||||||
@ -61,7 +79,7 @@ defmodule Growth.Calc.ZScore do
|
|||||||
(:math.pow(y / m, l) - 1) / (s * l)
|
(:math.pow(y / m, l) - 1) / (s * l)
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec adjust(number(), number(), number(), number(), number()) :: number()
|
@spec adjust(number(), number(), l(), m(), s()) :: number()
|
||||||
@doc """
|
@doc """
|
||||||
Adjust the raw z-score considering that extreme values, beyond -3 and 3 standard deviation, must be handled differently.
|
Adjust the raw z-score considering that extreme values, beyond -3 and 3 standard deviation, must be handled differently.
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user