# Short-Term Power Forecasting Framework for Microgrids Using Combined Baseline and Regression Models
## 3 Methodology
### Rule-Based Baseline Prediction  
A baseline consists of a forecast of a power variable based on previous measurements of that variable. This method can be applied by following different rules depending on what the objective is and the type of days and events that could be identified during the period of interest. In this sense, a common approach is to distinguish only between weekdays and weekends, but in this work, this technique is extended by the definition and specification of different rules that can be chosen depending on the type of variable to forecast. Specifically, these proposed models perform multistep day-ahead predictions for a whole day using only the historical data obtained on some previous days. The number of days to be used is defined by the integer \(n\), which is the parameter that establishes the model configuration (therefore, it will hereinafter be referred to as a hyperparameter) depending on the rule to be applied. Once the days to be used are selected, the mean power value is calculated for each of the time intervals of those days, with these values being the forecasts for these days. This process is depicted in Figure 1.  
The four types of proposed baseline rules are as follows:  
1. Baseline \"simple \(n\)\" (abbreviated as _baseline_sn_): This rule takes the \(n\) days prior to the target day and calculates the mean for each time interval. There are no day-type distinctions with this rule. The proposed values for \(n\) are 1, 2, 3, 4, 5, 6, 7, 14, 21, 28, and 35. 2. Baseline \"basic_weekend \(n\)\" (abbreviated as _baseline_bwn_): In this rule, \(n\) days before the objective day are considered, but not all of them are used in the baseline calculation. If the objective day is a weekend day, the weekend days within the previous \(n\) days are averaged for each interval of each day. The same situation occurs if the objective is a nonweekend day, where all nonweekend days within \(n\) days are taken. The proposed values for \(n\) are 7, 14, 21, 28, and 35. 3. Baseline \"const_num_back \(n\)\" (abbreviated as _baseline_cnbn_): This rule takes \(n\) days before the objective day, which are of the same type; i.e., if the objective is a weekend day, \(n\) previous weekend days are taken. The proposed values for \(n\) are 1, 2, 3, and 4. 4. Third item. Baseline \"same_weekday \(n\)\" (abbreviated as _baseline_sun_): In this rule, from \(n\) days before the objective day, only those that are the same day of the week are used in the baseline calculation. For example, if the objective day is a Tuesday, the Tuesdays included in the set of \(n\) days are averaged for each time interval. The proposed values for \(n\) are 7, 14, 21, 28, and 35. Thus, the proposed values for the hyperparameter \(n\) are not the same for all rules. The selection of those values is due to the nature of each rule and the set of days that can be obtained. In the case of the \"basic_weekend\" and \"same_weekday\" rules, only multiples of seven are taken to ensure the availability of days of the needed type inside the set of \(n\) days (seven days contains two weekend days and five nonweekend days). Taking another value for \(n\) would result in an irregular distribution of days, so this is avoided by taking only multiples of seven. In the case of the rule \"const_num_back\", the maximum value of \(n\) is four to avoid mixing data from different numbers of days back with respect to weekends (two weeks ago for \(n=4\)) and non-weekends (one week ago for \(n=4\)). If \(n\) is higher than four, a minimum of three weeks will be needed to calculate the baseline of a weekend day, which would be undesirable. The _baseline_s1_ method (the simple \(n\) rule, where \(n=1\)) could be considered the simplest rule, so can be used as the reference method for comparison with the other rules. This idea is, for example, exposed in [55], where it is mentioned that one of the most commonly used base methods is the naive method [55]. This method consists of using the last observation as the next prediction.