From 28d2930d3a31a8eb36196330d331656aadf0a797 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Tue, 17 Sep 2024 11:37:28 +0100 Subject: [PATCH 1/7] Fix: Allow users to omit seed --- schemas/v1/config/running.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schemas/v1/config/running.json b/schemas/v1/config/running.json index bd16d88b6..9fe61d846 100644 --- a/schemas/v1/config/running.json +++ b/schemas/v1/config/running.json @@ -5,7 +5,7 @@ "properties": { "seed": { "type": "array", - "minItems": 1, + "minItems": 0, "maxItems": 1, "items": { "type": "integer" From f9fc17141b01e79465053cd7e8b5fa3ec8af2752 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Tue, 17 Sep 2024 11:58:02 +0100 Subject: [PATCH 2/7] Add schema for dummy model --- schemas/v1/config/models/dummy.json | 37 +++++++++++++++++++++++++++ schemas/v1/config/models/dynamic.json | 9 +++++++ schemas/v1/config/models/static.json | 9 +++++++ 3 files changed, 55 insertions(+) create mode 100644 schemas/v1/config/models/dummy.json create mode 100644 schemas/v1/config/models/dynamic.json create mode 100644 schemas/v1/config/models/static.json diff --git a/schemas/v1/config/models/dummy.json b/schemas/v1/config/models/dummy.json new file mode 100644 index 000000000..47b27e406 --- /dev/null +++ b/schemas/v1/config/models/dummy.json @@ -0,0 +1,37 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/imperialCHEPI/healthgps/main/schemas/v1/config/models/dummy.json", + "type": "object", + "properties": { + "$schema": { + "type": "string" + }, + "ModelName": { + "const": "Dummy" + }, + "ModelParameters": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "Value": { + "type": "number" + }, + "Policy": { + "type": "number" + }, + "PolicyStart": { + "type": "integer", + "minimum": 0 + } + } + }, + "minItems": 1 + } + }, + "required": [ + "ModelName", + "ModelParameters" + ], + "additionalProperties": false +} diff --git a/schemas/v1/config/models/dynamic.json b/schemas/v1/config/models/dynamic.json new file mode 100644 index 000000000..8f6d52811 --- /dev/null +++ b/schemas/v1/config/models/dynamic.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/imperialCHEPI/healthgps/main/schemas/v1/config/models/dynamic.json", + "anyOf": [ + { + "$ref": "dummy.json" + } + ] +} diff --git a/schemas/v1/config/models/static.json b/schemas/v1/config/models/static.json new file mode 100644 index 000000000..aad672481 --- /dev/null +++ b/schemas/v1/config/models/static.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/imperialCHEPI/healthgps/main/schemas/v1/config/models/static.json", + "anyOf": [ + { + "$ref": "dummy.json" + } + ] +} From ed5053e690711fa6b68bb03edd3ecc07d781b428 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Tue, 17 Sep 2024 12:26:40 +0100 Subject: [PATCH 3/7] Add schema for EBHLM model --- schemas/v1/config/models/dynamic.json | 3 + schemas/v1/config/models/ebhlm.json | 119 ++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 schemas/v1/config/models/ebhlm.json diff --git a/schemas/v1/config/models/dynamic.json b/schemas/v1/config/models/dynamic.json index 8f6d52811..d07b0ed6b 100644 --- a/schemas/v1/config/models/dynamic.json +++ b/schemas/v1/config/models/dynamic.json @@ -4,6 +4,9 @@ "anyOf": [ { "$ref": "dummy.json" + }, + { + "$ref": "ebhlm.json" } ] } diff --git a/schemas/v1/config/models/ebhlm.json b/schemas/v1/config/models/ebhlm.json new file mode 100644 index 000000000..d269ae691 --- /dev/null +++ b/schemas/v1/config/models/ebhlm.json @@ -0,0 +1,119 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/imperialCHEPI/healthgps/main/schemas/v1/config/models/ebhlm.json", + "type": "object", + "properties": { + "$schema": { + "type": "string" + }, + "ModelName": { + "const": "EBHLM" + }, + "Country": { + "type": "object", + "properties": { + "Code": { + "type": "integer" + }, + "Name": { + "type": "string" + }, + "Alpha2": { + "type": "string" + }, + "Alpha3": { + "type": "string" + } + }, + "required": [ + "Code", + "Name", + "Alpha2", + "Alpha3" + ], + "additionalProperties": false + }, + "BoundaryPercentage": { + "type": "number", + "exclusiveMinimum": 0.0, + "exclusiveMaximum": 1.0 + }, + "Variables": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Name": { + "type": "string" + }, + "Factor": { + "type": "string" + } + }, + "required": [ + "Name", + "Factor" + ], + "additionalProperties": false + }, + "minItems": 1 + }, + "Equations": { + "type": "object", + "propertyNames": { + "pattern": "^[0-9]+\\-[0-9]+$" + }, + "additionalProperties": { + "type": "object", + "propertyNames": { + "enum": [ + "Male", + "Female" + ] + }, + "additionalProperties": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Name": { + "type": "string" + }, + "Coefficients": { + "type": "object", + "properties": { + "Intercept": { + "type": "number" + } + }, + "additionalProperties": { + "type": "number" + }, + "required": [ + "Intercept" + ] + }, + "ResidualsStandardDeviation": { + "type": "number" + } + }, + "required": [ + "Name", + "Coefficients", + "ResidualsStandardDeviation" + ], + "additionalProperties": false + } + } + } + } + }, + "required": [ + "ModelName", + "Country", + "BoundaryPercentage", + "Variables", + "Equations" + ], + "additionalProperties": false +} From 68818bd40552a1a9a5855181dffdbafbd6446e46 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Wed, 18 Sep 2024 09:16:36 +0100 Subject: [PATCH 4/7] Split CSV file description into subschema --- schemas/v1/config/csv_file.json | 40 +++++++++++++++++++++++++++++++++ schemas/v1/config/inputs.json | 37 +----------------------------- 2 files changed, 41 insertions(+), 36 deletions(-) create mode 100644 schemas/v1/config/csv_file.json diff --git a/schemas/v1/config/csv_file.json b/schemas/v1/config/csv_file.json new file mode 100644 index 000000000..f81b64baa --- /dev/null +++ b/schemas/v1/config/csv_file.json @@ -0,0 +1,40 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/imperialCHEPI/healthgps/main/schemas/v1/config/csv_file.json", + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "format": { + "const": "csv" + }, + "delimiter": { + "const": "," + }, + "encoding": { + "const": "ASCII" + }, + "columns": { + "type": "object", + "additionalProperties": { + "anyOf": [ + { + "const": "integer" + }, + { + "const": "double" + } + ] + } + } + }, + "required": [ + "name", + "format", + "delimiter", + "encoding", + "columns" + ], + "additionalProperties": false +} diff --git a/schemas/v1/config/inputs.json b/schemas/v1/config/inputs.json index 4970c4447..3c3d3c6c5 100644 --- a/schemas/v1/config/inputs.json +++ b/schemas/v1/config/inputs.json @@ -4,42 +4,7 @@ "type": "object", "properties": { "dataset": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "format": { - "const": "csv" - }, - "delimiter": { - "type": "string" - }, - "encoding": { - "type": "string" - }, - "columns": { - "type": "object", - "additionalProperties": { - "anyOf": [ - { - "const": "integer" - }, - { - "const": "double" - } - ] - } - } - }, - "required": [ - "name", - "format", - "delimiter", - "encoding", - "columns" - ], - "additionalProperties": false + "$ref": "csv_file.json" }, "settings": { "type": "object", From a2bcf575cf06d743dfe598d9dd92a0743f8f9feb Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Wed, 18 Sep 2024 09:22:11 +0100 Subject: [PATCH 5/7] Add schema for Kevin Hall model --- schemas/v1/config/models/dynamic.json | 3 + schemas/v1/config/models/kevinhall.json | 133 ++++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 schemas/v1/config/models/kevinhall.json diff --git a/schemas/v1/config/models/dynamic.json b/schemas/v1/config/models/dynamic.json index d07b0ed6b..1805af7cc 100644 --- a/schemas/v1/config/models/dynamic.json +++ b/schemas/v1/config/models/dynamic.json @@ -7,6 +7,9 @@ }, { "$ref": "ebhlm.json" + }, + { + "$ref": "kevinhall.json" } ] } diff --git a/schemas/v1/config/models/kevinhall.json b/schemas/v1/config/models/kevinhall.json new file mode 100644 index 000000000..698ad7da8 --- /dev/null +++ b/schemas/v1/config/models/kevinhall.json @@ -0,0 +1,133 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/imperialCHEPI/healthgps/main/schemas/v1/config/models/kevinhall.json", + "type": "object", + "properties": { + "$schema": { + "type": "string" + }, + "ModelName": { + "const": "KevinHall" + }, + "Nutrients": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Name": { + "type": "string" + }, + "Range": { + "type": "array", + "items": { + "type": "number", + "minimum": 0.0 + }, + "minItems": 2, + "maxItems": 2 + }, + "Energy": { + "type": "number", + "minimum": 0.0 + } + }, + "required": [ + "Name", + "Range", + "Energy" + ], + "additionalProperties": false + }, + "minItems": 1 + }, + "Foods": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Name": { + "type": "string" + }, + "Nutrients": { + "type": "object", + "additionalProperties": { + "type": "number" + } + }, + "Price": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "Name", + "Nutrients", + "Price" + ], + "additionalProperties": false + } + }, + "WeightQuantiles": { + "propertyNames": { + "enum": [ + "Male", + "Female" + ] + }, + "additionalProperties": { + "$ref": "../csv_file.json" + } + }, + "EnergyPhysicalActivityQuantiles": { + "$ref": "../csv_file.json" + }, + "HeightStdDev": { + "type": "object", + "properties": { + "Male": { + "type": "number" + }, + "Female": { + "type": "number" + } + }, + "required": [ + "Male", + "Female" + ], + "additionalProperties": false + }, + "HeightSlope": { + "type": "object", + "properties": { + "Male": { + "type": "number" + }, + "Female": { + "type": "number" + } + }, + "required": [ + "Male", + "Female" + ], + "additionalProperties": false + } + }, + "required": [ + "ModelName", + "Nutrients", + "Foods", + "WeightQuantiles", + "EnergyPhysicalActivityQuantiles", + "HeightStdDev", + "HeightSlope" + ], + "additionalProperties": false +} From 79e8a1fa8ef8278bc7b9eecdc0fd39b1f7a22de8 Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Wed, 18 Sep 2024 09:59:15 +0100 Subject: [PATCH 6/7] Add schema for HLM model --- schemas/v1/config/models/hlm.json | 157 +++++++++++++++++++++++++++ schemas/v1/config/models/static.json | 3 + 2 files changed, 160 insertions(+) create mode 100644 schemas/v1/config/models/hlm.json diff --git a/schemas/v1/config/models/hlm.json b/schemas/v1/config/models/hlm.json new file mode 100644 index 000000000..3dc446f52 --- /dev/null +++ b/schemas/v1/config/models/hlm.json @@ -0,0 +1,157 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/imperialCHEPI/healthgps/main/schemas/v1/config/models/hlm.json", + "type": "object", + "properties": { + "$schema": { + "type": "string" + }, + "ModelName": { + "const": "HLM" + }, + "models": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "formula": { + "type": "string" + }, + "coefficients": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "value": { + "type": "number" + }, + "stdError": { + "type": "number" + }, + "tValue": { + "type": "number" + }, + "pValue": { + "type": "number" + } + }, + "required": [ + "value", + "stdError", + "tValue", + "pValue" + ], + "additionalProperties": false + } + }, + "residuals": { + "type": "array", + "items": { + "type": "number" + } + }, + "fittedValues": { + "type": "array", + "items": { + "type": "number" + } + }, + "residualsStandardDeviation": { + "type": "number" + }, + "rSquared": { + "type": "number" + } + }, + "required": [ + "formula", + "coefficients", + "residuals", + "fittedValues", + "residualsStandardDeviation", + "rSquared" + ], + "additionalProperties": false + } + }, + "levels": { + "type": "object", + "propertyNames": { + "pattern": "^[0-9]+$" + }, + "additionalProperties": { + "type": "object", + "properties": { + "variables": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1 + }, + "m": { + "$ref": "#/$defs/variable" + }, + "w": { + "$ref": "#/$defs/variable" + }, + "s": { + "$ref": "#/$defs/variable" + }, + "correlation": { + "$ref": "#/$defs/variable" + }, + "variances": { + "type": "array", + "items": { + "type": "number" + } + } + }, + "required": [ + "variables", + "m", + "w", + "s", + "correlation", + "variances" + ], + "additionalProperties": false + } + } + }, + "required": [ + "ModelName", + "models", + "levels" + ], + "additionalProperties": false, + "$defs": { + "variable": { + "type": "object", + "properties": { + "rows": { + "type": "number", + "minimum": 1 + }, + "cols": { + "type": "number", + "minimum": 1 + }, + "data": { + "type": "array", + "items": { + "type": "number" + }, + "minItems": 1 + } + }, + "required": [ + "rows", + "cols", + "data" + ], + "additionalProperties": false + } + } +} diff --git a/schemas/v1/config/models/static.json b/schemas/v1/config/models/static.json index aad672481..3b4e45055 100644 --- a/schemas/v1/config/models/static.json +++ b/schemas/v1/config/models/static.json @@ -4,6 +4,9 @@ "anyOf": [ { "$ref": "dummy.json" + }, + { + "$ref": "hlm.json" } ] } From 17869cdd3e11b6401c9cd4154b395e26a0a9840f Mon Sep 17 00:00:00 2001 From: Alex Dewar Date: Wed, 18 Sep 2024 10:38:10 +0100 Subject: [PATCH 7/7] Add schema for static linear model --- schemas/v1/config/models/static.json | 3 + schemas/v1/config/models/staticlinear.json | 161 +++++++++++++++++++++ 2 files changed, 164 insertions(+) create mode 100644 schemas/v1/config/models/staticlinear.json diff --git a/schemas/v1/config/models/static.json b/schemas/v1/config/models/static.json index 3b4e45055..898698b93 100644 --- a/schemas/v1/config/models/static.json +++ b/schemas/v1/config/models/static.json @@ -7,6 +7,9 @@ }, { "$ref": "hlm.json" + }, + { + "$ref": "staticlinear.json" } ] } diff --git a/schemas/v1/config/models/staticlinear.json b/schemas/v1/config/models/staticlinear.json new file mode 100644 index 000000000..6f9f6cae0 --- /dev/null +++ b/schemas/v1/config/models/staticlinear.json @@ -0,0 +1,161 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://raw.githubusercontent.com/imperialCHEPI/healthgps/main/schemas/v1/config/models/staticlinear.json", + "type": "object", + "properties": { + "$schema": { + "type": "string" + }, + "ModelName": { + "const": "StaticLinear" + }, + "InformationSpeed": { + "type": "number" + }, + "PhysicalActivityStdDev": { + "type": "number" + }, + "RuralPrevalence": { + "type": "array", + "items": { + "type": "object", + "properties": { + "Name": { + "type": "string" + }, + "Female": { + "type": "number" + }, + "Male": { + "type": "number" + } + }, + "required": [ + "Name", + "Female", + "Male" + ], + "additionalProperties": false + } + }, + "IncomeModels": { + "type": "object", + "propertyNames": { + "enum": [ + "Low", + "Middle", + "High", + "Unknown" + ] + }, + "additionalProperties": { + "type": "object", + "properties": { + "Intercept": { + "type": "number" + }, + "Coefficients": { + "type": "object", + "additionalProperties": { + "type": "number" + } + } + }, + "required": [ + "Intercept", + "Coefficients" + ], + "additionalProperties": false + } + }, + "RiskFactorModels": { + "type": "object", + "additionalProperties": { + "type": "object", + "properties": { + "Lambda": { + "type": "number" + }, + "StdDev": { + "type": "number" + }, + "Intercept": { + "type": "number" + }, + "Range": { + "type": "array", + "items": { + "type": "number" + }, + "minItems": 2, + "maxItems": 2 + }, + "Coefficients": { + "additionalProperties": { + "type": "number" + } + }, + "Policy": { + "type": "object", + "properties": { + "Intercept": { + "type": "number" + }, + "Range": { + "type": "array", + "items": { + "type": "number" + }, + "minItems": 2, + "maxItems": 2 + }, + "Coefficients": { + "additionalProperties": { + "type": "number" + } + }, + "LogCoefficients": { + "additionalProperties": { + "type": "number" + } + } + }, + "required": [ + "Intercept", + "Range", + "Coefficients", + "LogCoefficients" + ], + "additionalProperties": false + } + }, + "required": [ + "Lambda", + "StdDev", + "Intercept", + "Range", + "Coefficients", + "Policy" + ], + "additionalProperties": false + } + }, + "RiskFactorCorrelationFile": { + "$ref": "../csv_file.json" + }, + "PolicyCovarianceFile": { + "$ref": "../csv_file.json" + } + }, + "required": [ + "ModelName", + "InformationSpeed", + "PhysicalActivityStdDev", + "RuralPrevalence", + "IncomeModels", + "RiskFactorModels", + "RiskFactorCorrelationFile", + "PolicyCovarianceFile" + ], + "additionalProperties": false +}