{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "linearcombinationprocedure.json",
    "title": "LinearCombinationProcedure",
    "type": "object",
    "description": "Multivariable linear combination procedure - one linear combination for each forecast horizon. Being x [, y, ...] the boundary series, for each forecast time step t it returns intercept[t] + [ x[-l] * coefficients[t]boundaries['x'][l] for l in 1..lookback_steps ] and so on for additional boundaries and lookback steps.",
    "allOf": [
        {
            "$ref": "procedure.json"
        }
    ],
    "properties": {
        "type": {
            "type": "string",
            "enum": [
                "LinearCombination",
                "LinearCombination2B",
                "LinearCombination3B",
                "LinearCombination4B",
                "LinearCombinationProcedure",
                "LinearCombination2BProcedure",
                "LinearCombination3BProcedure",
                "LinearCombination4BProcedure"
            ]
        },
        "parameters": {
            "type": "object",
            "description": "Model parameters",
            "properties": {
                "forecast_steps": {
                    "type": "integer",
                    "description": "Number of time steps of the forecast horizon"
                },
                "lookback_steps": {
                    "type": "integer",
                    "description": "Number of time steps of the lookback period"
                },
                "coefficients": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "intercept": {
                                "type": "number",
                                "description": "Intercept of the linear regression for this forecast timestep"
                            },
                            "boundaries": {
                                "type": "array",
                                "description": "Each item of boundaries contains a name <string> and values <array> which are the coefficients starting from the one corresponding to the value at the forecast_date, the second corresponding to the value at the forecast_date minus one time step, and so on",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "name": {
                                            "type": "string",
                                            "description": "Boundary identifier. Examples: input_1, input_2"
                                        },
                                        "values": {
                                            "type": "array",
                                            "description": "The coefficients starting from the one corresponding to the value at the forecast_date, the second corresponding to the value at the forecast_date minus one time step, and so on",
                                            "items": {
                                                "type": "number"
                                            }
                                        }
                                    },
                                    "required": ["name", "values"]
                                }
                            },
                            "step" : {
                                "type": "integer"
                            }
                        },
                        "required": ["intercept", "boundaries"],
                        "additionalProperties": false
                    },
                    "description": "List of objects where each item represents a forecast time step (index 0 is first step). Each object has 'intercept' <number> and 'boundaries' <array>. Each item of boundaries contains a name <string> and values <array> which are the coefficients starting from the one corresponding to the value at the forecast_date, the second corresponding to the value at the forecast_date minus one time step, and so on",
                    "minItems": 1
                }        
            },
            "required": [
                "coefficients",
                "forecast_steps",
                "lookback_steps"
            ]        
        },
        "extra_pars": {
            "type": "object",
            "propeties": {
                "Z": {
                    "type": "number",
                    "description": "Confidence level multiplier (e.g., Z = 1.96 for 95% confidence)"
                }
            }
        },
        "boundaries": {
            "oneOf": [
                {
                    "type": "array",
                    "items": {
                        "allOf": [
                            { "$ref": "procedureboundary.json"},
                            {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "enum": ["input_1","input_2","input_3","input_4","input_5","input_6","input_7","input_8","input_9","input_10","input_11","input_12","input_13","input_14","input_15","input_16"]
                                    }
                                }
                            }
                        ]
                    },
                    "minItems": 1,
                    "maxItems": 16
                },
                {
                    "type": "array",
                    "description": "list of lists of observations",
                    "items": {
                        "$ref": "observationlist.json"
                    },
                    "minItems": 1,
                    "maxItems": 16
                },
                {
                    "type": "string",
                    "description": "Path to CSV file. First column must be the datetime index. Headers (first row) must indicate input names"
                }  
            ]
        },
        "outputs": {
            "oneOf": [
                {
                    "type": "array",
                    "items": {
                        "allOf": [
                            { "$ref": "procedureboundary.json"},
                            {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "enum": ["output"]
                                    }
                                }
                            }
                        ]
                    },
                    "minItems": 1,
                    "maxItems": 1
                },
                {
                    "type": "array",
                    "description": "list of lists of observations",
                    "items": {
                        "$ref": "observationlist.json"
                    },
                    "minItems": 1,
                    "maxItems": 1
                },
                {
                    "type": "string",
                    "description": "Path to CSV file. First column must be the datetime index. Headers (first row) must indicate output names"
                }  
            ]
        }
    },
    "required": [
        "type",
        "parameters"
    ]
}