3.3.1. Time-Ahead Dynamic Pricing Model

The electricity price for the next hour (*Epr TADP*(*<sup>t</sup>* + 1)) is determined based on the difference between forecasted total generation output power from renewable energy sources (PV and WT) and the load demand *L*ˆ *D*(*<sup>t</sup>* + 1) using the following equation:

$$E\_{TADP}^{pr}(t+1) = E\_{std}^{pr}(t+1)\left(1 + \frac{\hat{L}\_D(t+1) - (\mathcal{W}T\_p(t+1) + P\mathcal{V}\_p(t+1))}{\hat{L}\_D(t+1)}\right) \tag{12}$$

where *PV*<sup>ˆ</sup> *p*(*<sup>t</sup>* + 1) and *WT*<sup>ˆ</sup> *p*(*<sup>t</sup>* + 1) represent the forecasted generation output power from the PV and WT, respectively. *Epr std*(*<sup>t</sup>* + 1) is the initial (standard) Kenyan electricity price initially present for hour *t* + 1 before TADP DRP implementation. *Epr TADP*(*<sup>t</sup>* + 1) is the next hour electricity price after the implementation of TADP DRP.

### 3.3.2. Time-Ahead Dynamic Pricing Demand Response Program Load Modeling

The electricity price determined one hour ahead of time for a specific period is the actual price that would be adopted for that period. Based on the electricity price relayed in advance, the end-consumers are either motivated/discouraged to shift their FDRs. The final economic load model after the TADP DRP is implemented is expressed as:

$$\begin{aligned} \, ^T\_D \boldsymbol{E}^{\text{TADP}}(\mathbf{i}) &= \boldsymbol{L}\_D(\mathbf{i}) \left\{ 1 + \boldsymbol{P} \boldsymbol{E}\_{\phi(i,i)} \frac{\left[ \boldsymbol{E}\_{\text{TADP}}^{\text{pr}}(\mathbf{i}) - \boldsymbol{E}\_{\text{std}}^{\text{pr}}(\mathbf{i}) + \boldsymbol{p}d(\mathbf{i}) + \boldsymbol{p}s(\mathbf{i}) \right]}{\boldsymbol{E}\_{\text{std}}^{\text{pr}}(\mathbf{i})} \\ &+ \sum\_{j=1, j \neq i}^{T} \boldsymbol{P} \boldsymbol{E}\_{\phi(i,j)} \frac{\left[ \boldsymbol{E}\_{\text{TADP}}^{\text{pr}}(\mathbf{j}) - \boldsymbol{E}\_{\text{std}}^{\text{pr}}(\mathbf{j}) + \boldsymbol{p}d(\mathbf{i}) + \boldsymbol{p}s(\mathbf{j}) \right]}{\boldsymbol{E}\_{\text{std}}^{\text{pr}}(\mathbf{j})} \end{aligned} \right\} \qquad \text{for all } i, j \in T \tag{13}$$

where *Epr std*(*i*) is the current (*i*th period) Kenyan electricity price before TADP DRP implementation.

3.3.3. Gradient Boosted Regression Trees (GBRT) Model for Time-Ahead Forecast of Generation

In this work, the forecasting tasks are treated as regression problems and machine learning regression algorithms on scikit-learn package in Python are adopted to build the models using the Gradient boosted regression trees (GBRT) algorithm. The GBRT algorithm has a superior advantage of not requiring complex data pre-processing of dimension transformations or reduction and does not suffer any loss of input variable interpretation [53]. The significant feature of the accurate implementation of the GBRT algorithm is the parameter *<sup>α</sup>gbr* called the learning rates. The learning rate is a scaling parameter that determines the individual contribution of each decision tree to the final ensemble model. The accuracy of the model is continuously improved by fitting the residual decision iteratively until the desired model is obtained for the best learning rate. Algorithm 1 illustrates the GBRT pseudo code algorithm.


In order ascertain the accuracy of forecasting algorithms, three performance evaluation metrics are used: Mean Absolute Error (MAE), Root mean squared error (RMSE) and Coefficient of Determination (*r*2).
