test(growth): add sample data to be used in tests
This commit is contained in:
parent
f3846cad24
commit
7670dce630
115
test/support/growth_data.ex
Normal file
115
test/support/growth_data.ex
Normal file
@ -0,0 +1,115 @@
|
||||
defmodule Growth.Data do
|
||||
@moduledoc """
|
||||
Sample data for growth tests based on WHO csv files containing:
|
||||
|
||||
* source measure
|
||||
* gender
|
||||
* age_unit
|
||||
* box-cox fitted params:
|
||||
* l
|
||||
* m
|
||||
* s
|
||||
* expeceted measure values at given z-scores:
|
||||
* -3
|
||||
* -2
|
||||
* -1
|
||||
* 0
|
||||
* 1
|
||||
* 2
|
||||
* 3
|
||||
"""
|
||||
|
||||
NimbleCSV.define(Growth.DataCase, separator: ",", escape: "\"")
|
||||
|
||||
# NOTE: (jpd) this combined table will be used on zscore and centile test to cross-validate the results using
|
||||
# different genders, ages units, and measures.
|
||||
@sample_combined_csv """
|
||||
source,gender,age_unit,age,l,m,s,sd3neg,sd2neg,sd1neg,sd0,sd1,sd2,sd3
|
||||
arm-circumference-for-age,female,month,3,-0.17330000000000001,13.0284,0.082629999999999995,10.199999999999999,11.1,12,13,14.2,15.4,16.8
|
||||
arm-circumference-for-age,female,day,91,-0.17330000000000001,13.0245,0.082619999999999999,10.218,11.066000000000001,11.999000000000001,13.023999999999999,14.154999999999999,15.401999999999999,16.78
|
||||
arm-circumference-for-age,male,month,3,0.39279999999999998,13.4817,0.074749999999999997,10.7,11.6,12.5,13.5,14.5,15.6,16.7
|
||||
arm-circumference-for-age,male,day,91,0.39329999999999998,13.4779,0.074740000000000001,10.657999999999999,11.554,12.493,13.478,14.507999999999999,15.585000000000001,16.709
|
||||
body-mass-index-for-age,female,day,28,0.36370000000000002,14.4208,0.095769999999999994,10.646000000000001,11.824,13.081,14.420999999999999,15.843999999999999,17.353999999999999,18.952999999999999
|
||||
body-mass-index-for-age,female,week,4,0.36370000000000002,14.4208,0.095769999999999994,10.6,11.8,13.1,14.4,15.8,17.399999999999999,19
|
||||
body-mass-index-for-age,female,month,1,0.3448,14.5679,0.095560000000000006,10.8,12,13.2,14.6,16,17.5,19.100000000000001
|
||||
body-mass-index-for-age,male,day,28,0.28810000000000002,14.7714,0.090719999999999995,11.125999999999999,12.26,13.474,14.771000000000001,16.155000000000001,17.629000000000001,19.196000000000002
|
||||
body-mass-index-for-age,male,week,4,0.28810000000000002,14.7714,0.090719999999999995,11.1,12.3,13.5,14.8,16.2,17.600000000000001,19.2
|
||||
body-mass-index-for-age,male,month,1,0.27079999999999999,14.944100000000001,0.090270000000000003,11.3,12.4,13.6,14.9,16.3,17.8,19.399999999999999
|
||||
head-circumference-for-age,female,day,28,1,36.376100000000001,0.032149999999999998,32.868000000000002,34.036999999999999,35.207000000000001,36.375999999999998,37.545999999999999,38.715000000000003,39.884999999999998
|
||||
head-circumference-for-age,female,week,4,1,36.376100000000001,0.032149999999999998,32.9,34,35.200000000000003,36.4,37.5,38.700000000000003,39.9
|
||||
head-circumference-for-age,female,month,1,1,36.546300000000002,0.032099999999999997,33,34.200000000000003,35.4,36.5,37.700000000000003,38.9,40.1
|
||||
head-circumference-for-age,male,day,28,1,37.092599999999997,0.031480000000000001,33.590000000000003,34.756999999999998,35.924999999999997,37.093000000000004,38.26,39.427999999999997,40.595999999999997
|
||||
head-circumference-for-age,male,week,4,1,37.092599999999997,0.031480000000000001,33.6,34.799999999999997,35.9,37.1,38.299999999999997,39.4,40.6
|
||||
head-circumference-for-age,male,month,1,1,37.2759,0.031329999999999997,33.799999999999997,34.9,36.1,37.299999999999997,38.4,39.6,40.799999999999997
|
||||
length-height-for-age,female,day,28,1,53.380899999999997,0.036470000000000002,47.54,49.487000000000002,51.433999999999997,53.381,55.328000000000003,57.274999999999999,59.220999999999997
|
||||
length-height-for-age,female,week,4,1,53.380899999999997,0.036470000000000002,47.5,49.5,51.4,53.4,55.3,57.3,59.2
|
||||
length-height-for-age,female,month,1,1,53.687199999999997,0.036400000000000002,47.8,49.8,51.7,53.7,55.6,57.6,59.5
|
||||
length-height-for-age,male,day,28,1,54.388100000000001,0.035700000000000003,48.563000000000002,50.505000000000003,52.445999999999998,54.387999999999998,56.33,58.271000000000001,60.213000000000001
|
||||
length-height-for-age,male,week,4,1,54.388100000000001,0.035700000000000003,48.6,50.5,52.4,54.4,56.3,58.3,60.2
|
||||
length-height-for-age,male,month,1,1,54.724400000000003,0.035569999999999997,48.9,50.8,52.8,54.7,56.7,58.6,60.6
|
||||
subscapular-skinfold-for-age,female,day,91,-0.2019,7.7873999999999999,0.18428,4.6109999999999998,5.4580000000000002,6.4989999999999997,7.7869999999999999,9.3960000000000008,11.422000000000001,13.994999999999999
|
||||
subscapular-skinfold-for-age,female,month,3,-0.2026,7.7846000000000002,0.18428,4.5999999999999996,5.5,6.5,7.8,9.4,11.4,14
|
||||
subscapular-skinfold-for-age,male,day,91,-0.30299999999999999,7.6920000000000002,0.17019000000000001,4.7850000000000001,5.5640000000000001,6.516,7.6920000000000002,9.1609999999999996,11.016999999999999,13.395
|
||||
subscapular-skinfold-for-age,male,month,3,-0.30330000000000001,7.6898999999999997,0.17019999999999999,4.8,5.6,6.5,7.7,9.1999999999999993,11,13.4
|
||||
triceps-skinfold-for-age,female,day,91,0.18820000000000001,9.7532999999999994,0.17524999999999999,5.6070000000000002,6.7869999999999999,8.1609999999999996,9.7530000000000001,11.589,13.695,16.102
|
||||
triceps-skinfold-for-age,female,month,3,0.1875,9.7515999999999998,0.17535000000000001,5.6,6.8,8.1999999999999993,9.8000000000000007,11.6,13.7,16.100000000000001
|
||||
triceps-skinfold-for-age,male,day,91,0.0030000000000000001,9.7658000000000005,0.16611000000000001,5.931,7.0039999999999996,8.2710000000000008,9.766,11.53,13.612,16.068000000000001
|
||||
triceps-skinfold-for-age,male,month,3,0.0027000000000000001,9.7638999999999996,0.16617999999999999,5.9,7,8.3000000000000007,9.8000000000000007,11.5,13.6,16.100000000000001
|
||||
weight-for-age,female,day,28,0.1789,4.0987,0.13805000000000001,2.665,3.0880000000000001,3.5640000000000001,4.0990000000000002,4.6980000000000004,5.3659999999999997,6.1120000000000001
|
||||
weight-for-age,female,week,4,0.1789,4.0987,0.13805000000000001,2.7,3.1,3.6,4.0999999999999996,4.7,5.4,6.1
|
||||
weight-for-age,female,month,1,0.1714,4.1872999999999996,0.13724,2.7,3.2,3.6,4.2,4.8,5.5,6.2
|
||||
weight-for-age,male,day,28,0.2331,4.3670999999999998,0.13497000000000001,2.8540000000000001,3.3050000000000002,3.8069999999999999,4.367,4.9880000000000004,5.6740000000000004,6.43
|
||||
weight-for-age,male,week,4,0.2331,4.3670999999999998,0.13497000000000001,2.9,3.3,3.8,4.4000000000000004,5,5.7,6.4
|
||||
weight-for-age,male,month,1,0.22969999999999999,4.4709000000000003,0.13395000000000001,2.9,3.4,3.9,4.5,5.0999999999999996,5.8,6.6
|
||||
"""
|
||||
|
||||
@doc """
|
||||
Sample data to validate calculation made to convert measure into z-score and vice-versa.
|
||||
|
||||
This data is based on values extracted from WHO csv files.
|
||||
"""
|
||||
@spec sample :: [
|
||||
%{
|
||||
key: String.t(),
|
||||
zscore: number(),
|
||||
measure: number(),
|
||||
l: number(),
|
||||
m: number(),
|
||||
s: number()
|
||||
}
|
||||
]
|
||||
def sample do
|
||||
@sample_combined_csv
|
||||
|> Growth.DataCase.parse_string()
|
||||
|> Enum.flat_map(fn [
|
||||
source,
|
||||
gender,
|
||||
age_unit,
|
||||
age,
|
||||
l,
|
||||
m,
|
||||
s,
|
||||
sd3n,
|
||||
sd2n,
|
||||
sd1n,
|
||||
sd0,
|
||||
sd1,
|
||||
sd2,
|
||||
sd3
|
||||
] ->
|
||||
key = "#{source}:#{gender}:#{age_unit}:#{age}"
|
||||
|
||||
[l, m, s, sd3n, sd2n, sd1n, sd0, sd1, sd2, sd3] =
|
||||
Enum.map(
|
||||
[l, m, s, sd3n, sd2n, sd1n, sd0, sd1, sd2, sd3],
|
||||
&(&1 |> Float.parse() |> elem(0))
|
||||
)
|
||||
|
||||
[-3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0]
|
||||
|> Enum.zip([sd3n, sd2n, sd1n, sd0, sd1, sd2, sd3])
|
||||
|> Enum.map(fn {zscore, measure} ->
|
||||
%{key: "#{key}:#{zscore}", zscore: zscore, measure: measure, l: l, m: m, s: s}
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user