Reliability

Row

SAIDI (Year)

SAIFI (Year)

CAIDI (Year)

Interruptions (Year)

1528

Row

Unplanned SAIDI (Year)

Unplanned SAIFI (Year)

Unplanned CAIDI (Year)

Unplanned Interruptions (Year)

598

Row

Planned SAIDI (Year)

Planned SAIFI (Year)

Planned CAIDI (Year)

Planned Interruptions (Year)

929

Network

Row

Network Length

6682.91

Vegetation Management

3281.86

Consumer

88569

Row

Overhead Lines

4398.7

Street Lighting

710.06

Energy Delivered

Row

Underground Cables

2284 km

Coastile/Geothermal within 10 km

2287 km

Losses

Row

Regulatory

Row

Reliability

Row

Global SAIDI

Unplanned SAIDI

Planned SAIDI

Less 3h

More 3h

Fault Rate

Row

Global SAIFI

Unplanned SAIFI

Planned SAIFI

Interruptions

Unplanned Interruptions

Planned Interruptions

Global CAIDI

Regulatory

Row

Opening RAB

Profit Before Tax

Regulatory Profit

Tax Deduction

Row

Closing RAB

Depreciation

Revaluation

Asset Commissioned

Regulatory Allowance

Tax Addition

Network

Row

Total Length

Overhead Lines

Underground Cables

Rural Length

Urban Length

LV Street Length

Tree Management Length

Low Voltage Length

Costline or Geotherm

Row

Urban Length

Rural Length

Underground Cables

Overhead Lines

Total Length

Revenue

Row

Energy Delivered

Line Charge

Row

Consumers

Unplanned SAIDI

Row

Unplunned SAIDI Equipment Involved

Row

Unplunned SAIDI Causes

Cluster

1. Breafly explanation about clusterization and the variables employed to perform this study. Each dot in this graphic is a company and the color means the cluster.


The clusterization was based on the K-means (MacQueen, J. B. (1967)) methodology, which use the euclidian distance between data and a centroids. The variables used in the clusterization were:

  • a_li: Total Length
  • a_li_ur: Urban Length
  • a_li_oh: Overhead Length
  • rg_rab_closed_tot: Closing Year RAB
  • rg_ope_surp: Operational Surplus
  • rg_depr: Depreciation
  • rg_pf: Regulatory Profit After Tax, Incentivies, and Whas-ups
  • rg_rev_line_char: Regulatory Line Charge
  • s_loss: Energy Losses
  • rg_tax_income: Regulatory Taxable Income
  • r_saidi: Global SAIDI
  • r_saifi: Global SAIFI
  • rg_opex_tot: OPEX
  • rg_capex_total: CAPEX

As result of it, the EDB was divived into 5 groups:

Cluster
Cluster Quantity
1 12
2 11
3 1
4 1
5 4

Although, there are 5 clusters as outcome, 2 of them has only 1 company, and, for this reason, only 3 cluster has will be used in further comparison.

2. Despite of the NZ is spread into several island, with 2 main island (North and South), this graphic aims to compare the clusterization outcome and geographical distribution of the lines companies.


The new cluster Map divided into islands and excluding Vector and Powerco, shows a non uniform distribution, which I can concluded:

  • The island do not determine the overall caracteristic of the company, and;
  • Bigger Companies were located in North Island.

Table bellow sum-up all the information.

EDB, COD, Island, and Cluster
EDB COD Island Cluster
Cluster 1
Alpine Energy AL South 1
Aurora Energy AE South 1
Counties Power CO North 1
EA Networks EA South 1
Electra EL North 1
MainPower NZ MA South 1
Marlborough Lines MR South 1
Northpower NO North 1
OtagoNet ON South 1
The Lines Company LN North 1
The Power Company PC South 1
Top Energy TP North 1
Cluster 2
Buller Electricity BU South 2
Centralines CL North 2
Eastland Network EN North 2
Electricity Invercargill EI South 2
Horizon Energy HO North 2
Nelson Electricity NE South 2
Network Tasman NT South 2
Network Waitaki NW South 2
Scanpower SC North 2
Waipa Networks WA North 2
Westpower WP South 2
Cluster 3
Vector Lines VE North 3
Cluster 4
Powerco PO North 4
Cluster 5
Orion NZ OR South 5
Unison Networks UN North 5
WEL Networks WL North 5
Wellington Electricity WE North 5

This straighforward clusterization study will be used in further stydies, however, it is incipient and need a PCA study to ensure the variables employed.

3. This is Graphic shows each cluster separately, note there are two cluster (3 and 4) with only one company. Due to the lack of representative, I will exclude these clusters.

Quality Breach

1. In accordance with the Aurora Energy One Page Summary from NZCC, Aurora Energy has breached the quality in 2012, 2016 and 2017.


In this Graphic I have converted all companies SAIDI to a stardarized SAIDI, based on the total consumers of New Zealand.

Table QB1 shows the total number of ICPs is New Zealand.

Table QB1 - NZ ICPs
Year No. ICPs
2,018 2,108,843
2,017 2,087,289
2,016 2,065,542
2,015 2,047,076
2,014 2,032,051
2,013 2,020,919

The Equation (QB1) shows the variable used to convert SAIDI.

\[\small SAIDI_{global} = SAIDI_{edb}\cdot\frac{ICP_{edb}}{ICP_{NZ}}\tag{QB1}\]

After these convertion, It is possible to add and/or subtract SAIDI values because all are in the same basis.

Note the discrepance of Average Planned SAIDI between Cluster 5 and others two clusters, it also happen in Unplanned SAIDI. This behaivour could be a effect of the company size, Table QB2 shows the Average of ICPs in each company in 2018.

Table QB2 - Average ICPs by Cluster
Cluster Avg. ICPs
1 37,974
2 17,169
3 557,461
4 336,762
5 142,516

Founded on Table above, probably companies with biger grids could transfer loads to nearby feeders in order to mitigate the outage area, whereas small companies do not have this alternatives. Therefore, I will employ to the financial number the standarization by the RAB.


Conclusions:

  • Cluster 1 has been decreasing the SAIDI cause by Unplanned Interruptions;
  • The Average SAIDI of Planned Interruption of Cluster 5 has been increasing (slight) since 2013.

2. The realibity indexes are consequence of Network OPEX and CAPEX. So, the Graphic bellow shows the Network OPEX from 2013 to 2018.


For this reason, this study aims to find out a better understanding about the drivers to these breaches. My first analysis is about OPEX because I want to see the expenditure on Network Maintenance, such as:

  • Routine and corrective maintenance and inspection (rou_correc);
  • Vegetation Management (veg_mang);
  • Asset replacement and renewal (rep_ren);
  • Service interruptions and emergencies (serv_int).

The graphic aside, has a comparison among Clusters, the subject of comparison are the operational expenditures components.


Conclusions:

  • Although companies from Cluster 2 are smaller, proportionally they have been investing more in Asset replacement and renewal then other clusters, reaching in average about 0.62% of the RAB in 2018, this number in 2013 was 0.83%. Whilst Cluster 5 have invested up to 0.27% of the RAB;
  • In respect of the Routine and corrective maintenance and inspection the proportion of investment are almost the same, which is almost 0.9% of the RAB;
  • Cluster 1 and 2 has been spending 0.5% of the RAB, while Cluster 5 a bit more than 0.25%.
EDB, COD, Island, and Cluster
EDB COD Island Cluster
Cluster 1
Alpine Energy AL South 1
Aurora Energy AE South 1
Counties Power CO North 1
EA Networks EA South 1
Electra EL North 1
MainPower NZ MA South 1
Marlborough Lines MR South 1
Northpower NO North 1
OtagoNet ON South 1
The Lines Company LN North 1
The Power Company PC South 1
Top Energy TP North 1
Cluster 2
Buller Electricity BU South 2
Centralines CL North 2
Eastland Network EN North 2
Electricity Invercargill EI South 2
Horizon Energy HO North 2
Nelson Electricity NE South 2
Network Tasman NT South 2
Network Waitaki NW South 2
Scanpower SC North 2
Waipa Networks WA North 2
Westpower WP South 2
Cluster 3
Vector Lines VE North 3
Cluster 4
Powerco PO North 4
Cluster 5
Orion NZ OR South 5
Unison Networks UN North 5
WEL Networks WL North 5
Wellington Electricity WE North 5

3. Expenditure in CAPEX means acquisition of new assets, generally, these assets improves the quality service, which is beneficty to the reiliability indexes, but usually investing in CAPEX are expensive.



Conclusions:

  • Cluster 1 has increased from 2.37% in 2013 to 3.9% in 2018

4. Taking a look of the causes of the unplanned interruptions, Aurora Energy has a good perform comparing with the Cluster.

5. The equipments involved in Unplanned Interruptions in Aurora Energy network are concetrated at Distribution Level. Aurora Energy usually has a better perform then the Cluster Average.

6. Observing the number of interruptions restored in more than 3 hours, Aurora Energy has been decreasing this rate since 2016. Regarding of the Cluster, has better performance.


For all cluster, most of the outages restored in less than 3 hours are about 70%, seems the Big companies (Cluster 5) has more dificult to restore quickly. Companies in CLuster 1 and 2 has better performance in regard to restore promprtly. In the last two year, Aurora Energy performs is better the the average of the Cluster 1.


Conclusions:

  • Aurora has a god performance in this item as well.

7. The Total Fault Rate observed in Cluster 1 and 5 has been increasing over the year, and the Cluster 1 is the one with higher fault rate per 100 km, reached 16.9 faults/100km.

8. OPEX/km vs Network Length

9. (Network OPEX)/km vs Network Length



Conclusions:

8. Final:



Conclusions:

based on the graphics shown in itens 1,2,3,4,5 and 6, Aurora Energy does not have a bad service as expected reading the One Page Summary. The only weakness is the lack in Replacement and Renewal (an OPEX), since 2015 Aurora have been investing less then the average of the Cluster, in a long run it could lead a deterioration of the assets and rise the outages with causes in equipment.

Loss Breach

1. How is the losses in each cluster?

2. What is the losses’ behavior in regarding og Network length?


As expected, the graphic shows a tendence of the losses increasing accordling with the network length.


Conclusions:

  • It is possible to trace a line trend to calculate the coeficients.

3. Linear Regression to each cluster

4. Polynomial model - y ~ x^2

5. Calculating losses in percentage of the total energy entering

6.


Analysing by Regional, Dunedin has been performing losses under 6% (except 2015)


Conclusions:

Poles

1.

2.

Interactive Dashboard

Column

Chart 1

---
title: "Aurora Energy Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    source_code: embed 
---

```{r setup,include=FALSE}
library(flexdashboard)
library(kableExtra)
library(dplyr)
library(ggplot2)
library(ggrepel)
library(plotly)
library(shiny)
library(tidyr)
library(dygraphs)

setwd("~/Workplace")
db_neat <- readRDS(file = "~/Workplace/db_neat.rds")
```

```{r cluster,echo=FALSE}
# Clusterization
db_cluster <- db_neat %>%
       select(EDB,
              Year,
              Network,
              a_li,
              a_li_ur,
              a_li_oh,
              rg_rab_closed_tot,
              rg_ope_surp,
              rg_depr,
              rg_pf,
              rg_rev_line_char,
              s_loss,
              rg_tax_income,
              r_saidi,
              r_saifi,
              rg_opex_tot,
              rg_capex_total) %>%
       
              filter(Network %in% "All",
                     Year %in% 2018)

# Set seed - Ensure same results all the time
set.seed(2018)

# Running the Function K-means
cluster <- kmeans(x = db_cluster[,-c(1,3)],centers = 5,iter.max = 200)

# Aggregating the Column cluster
db_cluster <- mutate(db_cluster,cluster = cluster[[1]])

# Aggregating in db_neat
db_neat <- left_join(db_neat,db_cluster %>% select(EDB,Network,cluster),by = NULL) 

db_neat <- mutate(db_neat,cluster = as.factor(cluster))


# Plotting
db_neat %>% 
       filter(Network %in% "All",
              Year %in% 2018) %>%

              ggplot(aes( x = rg_rab_open ,
                          y = rg_pf ,
                          color = cluster)) +
                     
              geom_point(size = 2) +
       
              labs( x = "Opening Year RAB [000$]",
                    y = "Profit after Tax, incentive, and whas-up [000$]") -> cluster_p

```

```{r graphic,echo=FALSE}
# 1. Reliability ####

## SAIDI Global
r_p1 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = r_saidi, fill = EDB )) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Global SAIDI")

## SAIDI Unplanned
r_p2 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = r_un_saidi , fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Unplanned SAIDI")

## SAIDI Planned
r_p3 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = r_pl_saidi , fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Planned SAIDI")

## SAIFI
r_p4 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = r_saifi, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Global SAIFI")

## SAIFI Unplanned
r_p5 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = r_un_saifi, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Unplanned SAIFI")

## SAIFI Planeed
r_p6 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = r_pl_saifi, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Planned SAIFI")

## Total Interruptions
r_p7 <-  db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year ,
                         y = r_i_tot ,
                         fill = EDB)) + 
              
                     geom_bar(stat = "identity" ,
                              position = position_dodge()) +
       
                     labs( x = "Year",
                           y = "Total Interruptions")

## Unplaneed Interruptions
r_p8 <-  db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year ,
                         y = r_i_un ,
                         fill = EDB)) + 
              
                     geom_bar(stat = "identity" ,
                              position = position_dodge()) +
       
                     labs( x = "Year",
                           y = "Unplanned Interruptions")

## Planned Interruptions
r_p9 <-  db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year ,
                         y = r_i_pl ,
                         fill = EDB)) + 
              
                     geom_bar(stat = "identity" ,
                              position = position_dodge()) +
       
                     labs( x = "Year",
                           y = "Planned Interruptions")

## CAIDI
r_p10 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = r_caidi, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Global CAIDI")

## Less 3 hours
r_p11 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = r_less_3, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Interruptions restored in Less than 3 hours")

## More 3 hours
r_p12 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = r_more_3, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Interruptions restored in More than 3 hours")

## Fault Rate
r_p13 <- db_neat %>% 
              filter(Network %in% "All") %>% mutate(fault_rate = 100*r_i_tot/a_li) %>%
              
              ggplot(aes(x = Year , y = fault_rate, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Fault Rate [interruption/100km]")

# 2. Regulatory ####

## Opening RAB 
reg_p1 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = rg_rab_open, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "[000$]")

## Regulatory Profit Before Tax
reg_p2 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = rg_pf_tx, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "[000$]")

## Regulatory Profit After Tax (including financial incentives and wash-ups)
reg_p3 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = rg_pf, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "[000$]")

## Closing RAB
reg_p4 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = rg_rab_closed_tot, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "[000$]")

## Depreciation
reg_p5 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = rg_depr, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "[000$]")

## Revaluation
reg_p6 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = rg_reval, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "[000$]")

## Asset Commissioned
reg_p7 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = rg_a_com_tot, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "[000$]")

## Regulatory Allowance
reg_p8 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = rg_tx_al, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "[000$]")

## Tax Addition
reg_p9 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = rg_tax_add, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "[000$]")

## Tax Deduction
reg_p10 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = rg_tax_ded, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "[000$]")





# 3. Network ####

## Total Length
net_p1 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = a_li, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Total Length [km]")

## Overhead Length
net_p2 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = a_li_oh, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Overhead Lines Length [km]")

## Underground Length
net_p3 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = a_li_ug, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Underground Cables Length [km]")

## Rural Length
net_p4 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = a_li_ru, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Rural Length [km]")

## Urban Length
net_p5 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = a_li_ur, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Urban Length [km]")

## LV Street Length
net_p6 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = a_li_st, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Street Lighting Length [km]")

## Tree Management Length
net_p7 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = a_li_tree, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Tree Management Length [km]")

## Low Voltage Length
net_p8 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = a_lv_li, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "LV Length [km]")

## Costline or Geotherm Area within 10 km Length
net_p9 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = a_li_coge, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Coastile or Geothermal [km]")

# 4. Revenue ####

## Energy Delivered to ICPs
rev_p1 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = rev_con_tot_mwh, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Energy Delivered [MWh]")

## Line Charge Revenue
rev_p2 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = rev_actual, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Line Charge Revenue [MWh]")

## No. Consumers
rev_p3 <- db_neat %>% 
              filter(Network %in% "All") %>%
              
              ggplot(aes(x = Year , y = rev_con_tot_ave_co, fill = EDB)) + 
              
                     geom_bar(stat = "identity", position = position_dodge()) + 
                     
                     labs( x = "Year",
                           y = "Number of Consumer")
```

```{r gauge,echo=FALSE}
# Calculating all value of Gauges.

## SAIDI
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     select(r_saidi) ->  gauge_1

round(gauge_1[[1]],0) -> gauge_1

## SAIFI
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     select(r_saifi) ->  gauge_2

round(gauge_2[[1]],2) -> gauge_2

## CAIDI
gauge3 <- round(gauge_1/gauge_2,2)

## Interruptions
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     select(r_i_tot) ->  gauge_4

round(gauge_4[[1]],0) -> gauge_4

## ICPs
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     select(rev_con_tot_ave_co) ->  gauge_5

## Network Length
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     select(a_li) ->  gauge_6


## Overhead Lines Length
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     select(a_li_oh) ->  gauge_7

## Undergound Cables Length
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     select(a_li_ug) ->  gauge_8

## Vegetation Management Length
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     select(a_li_tree) ->  gauge_9

## Street Lighting Length
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     select(a_li_st) ->  gauge_10

## Coastline or Geothermal within 10 km
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     select(a_li_coge) ->  gauge_11

## Total Energy Delivered
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     select(s_tot_enr) ->  gauge_12

## Losses
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     mutate(a = s_loss/s_ent_enr) %>% select(a) -> gauge_13

## Unplanned SAIDI
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     select(r_un_saidi) ->  gauge_14

round(gauge_14[[1]],0) -> gauge_14

## Unplanned SAIFI
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     select(r_un_saifi) ->  gauge_15

round(gauge_15[[1]],2) -> gauge_15

## Unplanned CAIDI
gauge_16 = gauge_14/gauge_15

round(gauge_16[[1]],2) -> gauge_16

## Unplanned Interruptions
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     select(r_i_un) -> gauge_17

round(gauge_17[[1]],0) -> gauge_17

## Planned SAIDI
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     select(r_pl_saidi) ->  gauge_18

round(gauge_18[[1]],0) -> gauge_18

## Planned SAIFI
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     select(r_pl_saifi) ->  gauge_19

round(gauge_19[[1]],2) -> gauge_19

## Planned CAIFI
gauge_20 = gauge_18/gauge_19

round(gauge_20[[1]],0) -> gauge_20

## Planned Interruption
db_neat %>% filter(EDB %in% "Aurora Energy",
                   Network %in% "All",
                   Year %in% 2018) %>%
       
                     select(r_i_pl) ->  gauge_21

round(gauge_21[[1]],0) -> gauge_21

```


Reliability {data-navmenu="Panel" data-orientation=rows}
=================================================================================================================

Row 
-------------------------------------------------------------------------------

### SAIDI (Year)

```{r}
gauge(gauge_1, min = 0, max = 83.6, symbol = ' min', gaugeSectors(
  success = c(0, 83.6 * 1/4 - 0.0001), warning = c( 83.6 * 1/4,  83.6 * 2/4 - 0.0001), danger = c( 83.6 * 2/4,  83.6)
))
```

### SAIFI (Year)

```{r}
gauge(gauge_2, min = 0, max = 1.37, gaugeSectors(
  success = c(0, 1.37 * 1/4 - 0.0001), warning = c(1.37 * 1/4, 1.37 * 2/4 - 0.0001), danger = c(1.37 * 2/4, 1.37)
))
```

### CAIDI (Year)
```{r}
gauge(gauge3, min = 0, max = round(86.8/1.37,0), gaugeSectors(
  success = c(0, 86.8/1.37 * 1/4 -0.0001),
  warning = c(86.8/1.37 * 1/4, 86.8/1.37 * 2/4 - 0.0001),
  danger = c(86.8/1.37 * 2/4, 86.8/1.37)
))
```

### Interruptions (Year)

```{r}
Interruptions = gauge_4
valueBox(
  Interruptions,
  color = ifelse(Interruptions > (466+391)*0.8 , "warning","primary")
)
```

Row
-------------------------------------------------------------------------------

### Unplanned SAIDI (Year)

```{r}
gauge(gauge_14, min = 0, max = 200, symbol = ' min', gaugeSectors(
  success = c(0, 83.6 * 1/4 - 0.0001), warning = c( 83.6 * 1/4,  83.6 * 2/4 - 0.0001), danger = c( 83.6 * 2/4,  83.6)
))
```

### Unplanned SAIFI (Year)
```{r}
gauge(gauge_15, min = 0, max = 1.37, gaugeSectors(
  success = c(0, 1.37 * 1/4 - 0.0001), warning = c(1.37 * 1/4, 1.37 * 2/4 - 0.0001), danger = c(1.37 * 2/4, 1.37)
))
```

### Unplanned CAIDI (Year)
```{r}
gauge(gauge_16, min = 0, max = round(86.8/1.37,0), gaugeSectors(
  success = c(0, 86.8/1.37 * 1/4 -0.0001),
  warning = c(86.8/1.37 * 1/4, 86.8/1.37 * 2/4 - 0.0001),
  danger = c(86.8/1.37 * 2/4, 86.8/1.37)
))
```

### Unplanned Interruptions (Year)

```{r}
Interruptions = gauge_17
valueBox(
  Interruptions,
  color = ifelse(Interruptions > (466+391)*0.8 , "warning","primary")
)
```

Row
-------------------------------------------------------------------------------

### Planned SAIDI (Year)

```{r}
gauge(gauge_18, min = 0, max = 83.6, symbol = ' min', gaugeSectors(
  success = c(0, 83.6 * 1/4 - 0.0001), warning = c( 83.6 * 1/4,  83.6 * 2/4 - 0.0001), danger = c( 83.6 * 2/4,  83.6)
))
```

### Planned SAIFI (Year)

```{r}
gauge(gauge_19, min = 0, max = 1.37, gaugeSectors(
  success = c(0, 1.37 * 1/4 - 0.0001), warning = c(1.37 * 1/4, 1.37 * 2/4 - 0.0001), danger = c(1.37 * 2/4, 1.37)
))
```

### Planned CAIDI (Year)
```{r}
gauge(gauge_20, min = 0, max = round(86.8/1.37,0), gaugeSectors(
  success = c(0, 86.8/1.37 * 1/4 -0.0001),
  warning = c(86.8/1.37 * 1/4, 86.8/1.37 * 2/4 - 0.0001),
  danger = c(86.8/1.37 * 2/4, 86.8/1.37)
))
```

### Planned Interruptions (Year)

```{r}
Interruptions = gauge_21
valueBox(
  Interruptions,
  color = ifelse(Interruptions > (466+391)*0.8 , "warning","primary")
)
```


Network {data-navmenu="Panel" data-orientation=rows}
=================================================================================================================

Row
-------------------------------------------------------------------------------

### Network Length

```{r}
valueBox(
  value = gauge_6,
  color = "primary",
  caption = "Network Length"
)
```

### Vegetation Management

```{r}
valueBox(
  value = gauge_9,
  color = "primary",
  caption = "Vegetation Management"
)
```

### Consumer

```{r}
valueBox(
  value = round(gauge_5,0),
  color = "primary",
  caption = "Consumers"
)
```





Row
-------------------------------------------------------------------------------

### Overhead Lines

```{r}
valueBox(
  value = gauge_7,
  color = "primary",
  caption = "Overhead Lines"
)
```

### Street Lighting

```{r}
valueBox(
  value = gauge_10,
  color = "primary",
  caption = "Street Lighting"
)
```

### Energy Delivered

```{r}
gauge(value = gauge_12[[1]],
       min = gauge_12[[1]]*0.95,
       max = 1400,
       symbol = " MWh",
       gaugeSectors(
              success = c(gauge_12[[1]]*0.95,2000),
              warning = c(gauge_12[[1]]*0.95,gauge_12[[1]]*0.90),
              danger = c(gauge_12[[1]] * 0.90, 0)
))
```



Row
-------------------------------------------------------------------------------

### Underground Cables

```{r}
valueBox(
  value = paste(round(gauge_8,0)," km",sep=""),
  color = "primary",
  caption = "Underground Cables"
)
```

### Coastile/Geothermal within 10 km

```{r}
valueBox(
  value = paste(round(gauge_11,0)," km",sep=""),
  color = "primary",
  caption = "Coastile/Geothermal"
)
```


### Losses

```{r}
gauge(value = round(100*gauge_13[[1]],2),
       min = 0,
       max = 10,
       symbol = " %",
       gaugeSectors(
              success = c(0,6.0),
              warning = c(6.00001,8),
              danger = c(8,15)
))
```


Row
-------------------------------------------------------------------------------





Regulatory {data-navmenu="Panel" data-orientation=rows}
=================================================================================================================

Row
-------------------------------------------------------------------------------








Reliability {data-navmenu="Timeline" data-orientation=rows}
=================================================================================================================

Row {.tabset .tabset-fade}
-------------------------------------

### Global SAIDI

```{r echo=FALSE,out.width="100%"}
ggplotly(r_p1)
```

### Unplanned SAIDI

```{r echo=FALSE,out.width="100%"}
ggplotly(r_p2)
```

### Planned SAIDI

```{r echo=FALSE,out.width="100%"}
ggplotly(r_p3)
```

### Less 3h

```{r echo=FALSE,out.width="100%"}
ggplotly(r_p11)
```

### More 3h

```{r echo=FALSE,out.width="100%"}
ggplotly(r_p12)
```

### Fault Rate

```{r echo=FALSE,out.width="100%"}
ggplotly(r_p13)
```

Row {.tabset .tabset-fade}
-------------------------------------

### Global SAIFI

```{r}
ggplotly(r_p4)
```

### Unplanned SAIFI

```{r}
ggplotly(r_p5)
```

### Planned SAIFI

```{r}
ggplotly(r_p6)
```

###  Interruptions

```{r echo=FALSE}
ggplotly(r_p7)
```

### Unplanned Interruptions

```{r echo=FALSE}
ggplotly(r_p8)
```

### Planned Interruptions

```{r echo=FALSE}
ggplotly(r_p9)
```

### Global CAIDI

```{r echo=FALSE}
ggplotly(r_p10)
```


Regulatory {data-navmenu="Timeline" data-orientation=rows}
=================================================================================================================


Row {.tabset .tabset-fade}
-------------------------------------

### Opening RAB

```{r}
ggplotly(reg_p1)
```

### Profit Before Tax

```{r}
ggplotly(reg_p2)
```

### Regulatory Profit

```{r}
ggplotly(reg_p3)
```

### Tax Deduction

```{r}
ggplotly(reg_p10)
```





Row {.tabset .tabset-fade}
-------------------------------------

### Closing RAB

```{r}
ggplotly(reg_p4)
```

### Depreciation

```{r}
ggplotly(reg_p5)
```

### Revaluation

```{r}
ggplotly(reg_p6)
```

### Asset Commissioned

```{r}
ggplotly(reg_p7)
```


### Regulatory Allowance

```{r}
ggplotly(reg_p8)
```

### Tax Addition

```{r}
ggplotly(reg_p9)
```


Network {data-navmenu="Timeline" data-orientation=rows}
=================================================================================================================

Row {.tabset .tabset-fade}
-------------------------------------
    
### Total Length
    
```{r}
ggplotly(net_p1)
```
   
### Overhead Lines

```{r}
ggplotly(net_p2)
```   
 
### Underground Cables
    
```{r}
ggplotly(net_p3)
```

### Rural Length

```{r}
ggplotly(net_p4)
```

### Urban Length

```{r}
ggplotly(net_p5)
```

### LV Street Length

```{r}
ggplotly(net_p6)
```

### Tree Management Length

```{r}
ggplotly(net_p7)
```

### Low Voltage Length

```{r}
ggplotly(net_p8)
```

### Costline or Geotherm

```{r}
ggplotly(net_p9)
```

Row {.tabset .tabset-fade}
-------------------------------------

### Urban Length

```{r}
ggplotly(net_p5)
```


### Rural Length

```{r}
ggplotly(net_p4)
```


### Underground Cables
    
```{r}
ggplotly(net_p3)
```

### Overhead Lines

```{r}
ggplotly(net_p2)
```   

### Total Length
    
```{r}
ggplotly(net_p1)
```


Revenue {data-navmenu="Timeline" data-orientation=rows}
=================================================================================================================

Row {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Energy Delivered
    
```{r}
ggplotly(rev_p1)
```

### Line Charge
    
```{r}
ggplotly(rev_p2)
```

Row {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Consumers
    
```{r}
ggplotly(rev_p3)
```




Unplanned SAIDI {data-navmenu="AE Regionals" data-orientation=rows}
=================================================================================================================

Row
-------------------------------------
### Unplunned SAIDI Equipment Involved

```{r echo=FALSE,out.width="100%"}

db_neat %>% filter(EDB %in% "Aurora Energy") %>%
              select(EDB,Network,Year,
                     "Sub. Line" = r_i_cau_equ_sub_li,
                     "Sub. Cable" = r_i_cau_equ_sub_cb,
                     "Sub. Other" = r_i_cau_equ_sub_oth,
                     "Dis. Line" = r_i_cau_equ_dis_li_exc_lv,
                     "Dis. Cable" = r_i_cau_equ_dis_cb_exc_lv,
                     "Dis. Other" = r_i_cau_equ_dis_oth_exc_lv) %>%
       
       gather(Description, Value,4:9) %>%
       
       ggplot(aes(x = Year,
                  y = Value,
                  fill = Description)) +
              geom_bar(position = "stack",
                       stat = "identity") +
              
              facet_grid(. ~ Network) -> ana_p1

ggplotly(ana_p1)
```

Row
-------------------------------------
### Unplunned SAIDI Causes

```{r echo=FALSE,out.width="100%"}

db_neat %>% filter(EDB %in% "Aurora Energy") %>%
              select(EDB,Network,Year,
                     r_ae_saidi,
                     r_aw_saidi,
                     r_idk_saidi,
                     r_eqp_saidi,
                     r_hum_saidi,
                     r_lig_saidi,
                     r_tpi_saidi,
                     r_veg_saidi,
                     r_wlf_saidi) %>%
       
       gather(Description, Value,4:12) %>%
       
       ggplot(aes(x = Year,
                  y = Value,
                  fill = Description)) +
              geom_bar(position = "stack",
                       stat = "identity") +
              
              facet_grid(. ~ Network) -> ana_p2

ggplotly(ana_p2)
```


Cluster {.storyboard data-navmenu="Analysis"}
=================================================================================================================

### 1. Breafly explanation about clusterization and the variables employed to perform this study. Each dot in this graphic is a company and the color means the cluster.

```{r}
ggplotly(cluster_p)
```

*** 

The clusterization was based on the [K-means](https://pt.wikipedia.org/wiki/K-means) (MacQueen, J. B. (1967)) methodology, which use the euclidian distance between data and a centroids. The variables used in the clusterization were:

* a_li: Total Length 
* a_li_ur: Urban Length 
* a_li_oh: Overhead Length
* rg_rab_closed_tot: Closing Year RAB
* rg_ope_surp: Operational Surplus
* rg_depr: Depreciation
* rg_pf: Regulatory Profit After Tax, Incentivies, and Whas-ups
* rg_rev_line_char: Regulatory Line Charge
* s_loss: Energy Losses
* rg_tax_income: Regulatory Taxable Income
* r_saidi: Global SAIDI
* r_saifi: Global SAIFI
* rg_opex_tot: OPEX
* rg_capex_total: CAPEX

As result of it, the EDB was divived into 5 groups:

```{r}
# Table - Quanitty of EDB in each Cluster. 
table(cluster$cluster) %>% 
       
       # Plotting the table
       kable( align = "c",                        # Align the table and content to center
              col.names = c("Cluster",
                            "Quantity"),
              caption = "Cluster") %>%   # Title
       
       # Adding style to look nice
       kable_styling(bootstrap_options = c("striped",    # Rows alterning color
                                           "hover",      # Responsive on mouse
                                           "condensed"))
```

Although, there are 5 clusters as outcome, 2 of them has only 1 company, and, for this reason, only 3 cluster has will be used in further comparison.


### 2. Despite of the NZ is spread into several island, with 2 main island (North and South), this graphic aims to compare the clusterization outcome and geographical distribution of the lines companies.

```{r}
# North-South Facet Graphic
db_neat %>% 
       filter(Network %in% "All",
              Year %in% 2018,
              !COD %in% c("VE","PO")) %>%

              ggplot(aes( x = rg_rab_open ,
                          y = rg_pf ,
                          color = cluster)) +
                     
              geom_point(size = 2) +
       
              labs( x = "Opening Year RAB [000$]",
                    y = "[000$]",
                    title = "Profit after Tax, incentive, and whas-up ") -> cluster_p2

cluster_p2 <- cluster_p2 + facet_grid(. ~ island)

ggplotly(cluster_p2)
```

*** 
The new cluster Map divided into islands and excluding Vector and Powerco, shows a non uniform distribution, which I can concluded:

* The island do not determine the overall caracteristic of the company, and;
* Bigger Companies were located in North Island.

Table bellow sum-up all the information.

```{r}
# Table of EDB, COD, island and Cluster.
db_neat %>%
       select(EDB,
              COD,
              island,
              cluster) %>%
              distinct() %>%  # Only Unique rows.
       
                     filter(!cluster %in% NA) %>% # Removing NA                 
                            
                            arrange(cluster,EDB) %>%
       
                            # Plotting the table
                            kable( align = "c",                        # Align the table and content to center
                                   format.args = list(big.mark=","),
                                   col.names = c("EDB",
                                                 "COD",
                                                 "Island",
                                                 "Cluster"),
                                   caption = "EDB, COD, Island, and Cluster") %>%   # Title
                            
                            # Adding style to look nice
                            kable_styling(bootstrap_options = c("striped",    # Rows alterning color
                                                                "hover",      # Responsive on mouse
                                                                "condensed")) %>%

       group_rows(group_label = "Cluster 1",
                  start_row = 1,
                  end_row = 12,
                  label_row_css = "background-color: grey; color: white;") %>%
       
       group_rows(group_label = "Cluster 2",
                  start_row = 13,
                  end_row = 24,
                  label_row_css = "background-color: grey; color: white;") %>%
       
       group_rows(group_label = "Cluster 3",
                  start_row = 24,
                  end_row = 25,
                  label_row_css = "background-color: grey; color: white;") %>%
       
       group_rows(group_label = "Cluster 4",
                  start_row = 25,
                  end_row = 26,
                  label_row_css = "background-color: grey; color: white;") %>%
       
       group_rows(group_label = "Cluster 5",
                  start_row = 26,
                  end_row = 29,
                  label_row_css = "background-color: grey; color: white;") -> tb_edb_cluster
tb_edb_cluster
```

This straighforward clusterization study will be used in further stydies, however, it is incipient and need a PCA study to ensure the variables employed.

### 3. This is Graphic shows each cluster separately, note there are two cluster (3 and 4) with only one company. Due to the lack of representative, I will exclude these clusters.

```{r echo=FALSE}
db_neat %>% 
       filter(Network %in% "All",
              Year %in% 2018,
              !COD %in% c("VE","PO")) %>%

              ggplot(aes( x = rg_rab_open ,
                          y = rg_pf ,
                          color = cluster)) +
                     
              geom_point(size = 2) +
       
              labs( x = "Opening Year RAB [000$]",
                    y = "[000$]",
                    title = "Profit after Tax, incentive, and whas-up ") -> cluster_p3

cluster_p3 <- cluster_p3 + facet_grid(. ~ cluster)

ggplotly(cluster_p3)

```


Quality Breach {.storyboard data-navmenu="Analysis"}
=================================================================================================================

### 1. In accordance with the *Aurora Energy One Page Summary* from NZCC, Aurora Energy has breached the quality in 2012, 2016 and 2017. 

```{r}
db_neat %>% 
       filter(Network %in% "All",
              !COD %in% c("VE","PO")) %>%
              
              select(EDB,COD,island,Year,cluster,r_un_saidi,r_pl_saidi) -> temp
       
temp %>%
       group_by(cluster,Year) %>%
       
              summarise("Avg. Unplanned" = mean(r_un_saidi),
                        "Avg. Planned" = mean(r_pl_saidi)) %>%
                            
       ungroup() %>%
       
              gather(Description,Value,3:4) %>%
              
                     ggplot(aes(x = Year,
                                   y = Value,
                                   fill = Description)) +
              
                     geom_bar(stat = "identity") +
              
                     facet_grid(Description ~ cluster) +
                                          
                     labs(x = "Year",
                            y = "SAIDI [minutes]") +
                            
                     theme(legend.position="none") -> q_breach_p1


# Subsetting database to create Aurora Energy line in the plot
temp %>% filter(EDB %in% "Aurora Energy") %>% 
       
              select(cluster,Year,
                     "Avg. Unplanned" = r_un_saidi,
                     "Avg. Planned" = r_pl_saidi) %>%
       
                     gather(Description,Value,3:4) %>% arrange(Description) -> ae_line

# Adding the Aurora Value in the Bar Plot as a Line
q_breach_p1 + geom_line(data = ae_line,
                     inherit.aes = FALSE ,
                     aes(x = ae_line$Year,
                         y = ae_line$Value,
                         fill = Description),
                         size = .5,
                         color = "darkblue") +
       
                     facet_grid(Description ~ cluster) +
       
                     theme(legend.position="none") -> q_breach_p1


ggplotly(q_breach_p1)
```

***

In this Graphic I have converted all companies SAIDI to a stardarized SAIDI, based on the total consumers of New Zealand.

Table QB1 shows the total number of ICPs is New Zealand.

```{r}
db_neat %>%
       select(Year,pop) %>%
              distinct() %>%
                     kable(align = "c",
                           col.names = c("Year","No. ICPs"),
                           caption = "Table QB1 - NZ ICPs",
                           format.args = list(big.mark=",")) %>%
                            kable_styling(full_width = F,
                                          bootstrap_options = c("striped",    # Rows alterning color
                                                                "hover",      # Responsive on mouse
                                                                "condensed"))
```

The Equation (QB1) shows the variable used to convert SAIDI.

$$\small SAIDI_{global} = SAIDI_{edb}\cdot\frac{ICP_{edb}}{ICP_{NZ}}\tag{QB1}$$

After these convertion, It is possible to add and/or subtract SAIDI values because all are in the same basis.

Note the discrepance of Average Planned SAIDI between Cluster 5 and others two clusters, it also happen in Unplanned SAIDI. This behaivour could be a effect of the company size, Table QB2 shows the Average of ICPs in each company in 2018.

```{r}
db_neat %>% filter(Network %in% "All") %>%
                     select(EDB,Year,cluster,rev_con_tot_ave_co) %>%
                            group_by(cluster,Year) %>%
                                   summarise(pop = mean(rev_con_tot_ave_co)) %>%
                                          ungroup() %>%
                                                 filter(Year %in% "2018") %>%
                                                        select("Cluster" = cluster,"Avg. ICPs" = pop) %>%

kable( align = "c",
       caption = "Table QB2 - Average ICPs by Cluster",
       digits = 0,
       format.args = list(big.mark=",")) %>%
       kable_styling(full_width = F,
                     bootstrap_options = c("striped",    # Rows alterning color
                                          "hover",      # Responsive on mouse
                                          "condensed"))
```

Founded on Table above, probably companies with biger grids could transfer loads to nearby feeders in order to mitigate the outage area, whereas small companies do not have this alternatives. Therefore, I will employ to the financial number the standarization by the RAB.


**Conclusions:** * Cluster 1 has been decreasing the SAIDI cause by Unplanned Interruptions; * The Average SAIDI of Planned Interruption of Cluster 5 has been increasing (slight) since 2013. ### 2. The realibity indexes are consequence of Network OPEX and CAPEX. So, the Graphic bellow shows the Network OPEX from 2013 to 2018. ```{r} db_neat %>% filter(Network %in% "All", !COD %in% c("VE","PO")) %>% select(EDB, COD, cluster, Year, rg_opex_serv_int, rg_opex_veg_mang, rg_opex_rou_correc, rg_opex_a_rep_ren, rg_rab_closed_tot) %>% mutate(rg_opex_serv_int = 100 * rg_opex_serv_int/rg_rab_closed_tot, # rg_opex_veg_mang = 100 * rg_opex_veg_mang/rg_rab_closed_tot, # Normalizing rg_opex_rou_correc = 100 * rg_opex_rou_correc/rg_rab_closed_tot, # by Closing Year RAB rg_opex_a_rep_ren = 100 * rg_opex_a_rep_ren/rg_rab_closed_tot) -> temp # temp %>% group_by(cluster,Year) %>% summarise(serv_int = mean(rg_opex_serv_int), veg_mang = mean(rg_opex_veg_mang), rou_correc = mean(rg_opex_rou_correc), rep_ren = mean(rg_opex_a_rep_ren)) %>% ungroup() %>% gather(Description,Value,3:6) %>% ggplot(aes(x= Year, y = Value , fill = Description)) + geom_bar(stat = "identity") + facet_grid(Description ~ cluster) + theme(legend.position="none") + labs(x = "Year", y = "[%] of RAB") -> q_breach_p2 # Subsetting database to create Aurora Energy line in the plot temp %>% filter(EDB %in% "Aurora Energy") %>% select(cluster,Year, "serv_int" = rg_opex_serv_int, "veg_mang" = rg_opex_veg_mang, "rou_correc" = rg_opex_rou_correc, "rep_ren" = rg_opex_a_rep_ren) %>% gather(Description,Value,3:6) %>% arrange(Description) -> ae_line # Adding the Aurora Value in the Bar Plot as a Line q_breach_p2 + geom_line(data = ae_line, inherit.aes = FALSE , aes(x = ae_line$Year, y = ae_line$Value, fill = Description), size = .5, color = "darkblue") + facet_grid(Description ~ cluster) + theme(legend.position="none") -> q_breach_p2 ggplotly(q_breach_p2) ``` *** For this reason, this study aims to find out a better understanding about the drivers to these breaches. My first analysis is about OPEX because I want to see the expenditure on Network Maintenance, such as: * Routine and corrective maintenance and inspection (rou_correc); * Vegetation Management (veg_mang); * Asset replacement and renewal (rep_ren); * Service interruptions and emergencies (serv_int). The graphic aside, has a comparison among Clusters, the subject of comparison are the operational expenditures components.
**Conclusions:** * Although companies from Cluster 2 are smaller, proportionally they have been investing more in Asset replacement and renewal then other clusters, reaching in average about 0.62% of the RAB in 2018, this number in 2013 was 0.83%. Whilst Cluster 5 have invested up to 0.27% of the RAB; * In respect of the Routine and corrective maintenance and inspection the proportion of investment are almost the same, which is almost 0.9% of the RAB; * Cluster 1 and 2 has been spending 0.5% of the RAB, while Cluster 5 a bit more than 0.25%. `r tb_edb_cluster` ### 3. Expenditure in CAPEX *means* acquisition of new assets, generally, these assets improves the quality service, which is beneficty to the reiliability indexes, but usually investing in CAPEX are expensive. ```{r} db_neat %>% filter(Network %in% "All", # Removing Regionals !COD %in% c("VE","PO")) %>% # Removing Companies without representative clusters select(EDB,COD,cluster,island,Year, # rg_capex_a_rse, # rg_capex_a_cc, # Selecting variables of interesting rg_capex_a_sys, # rg_capex_a_repla, # rg_capex_a_reloc, # rg_rab_closed_tot) %>% # mutate(rg_capex_a_rse = 100 * rg_capex_a_rse/rg_rab_closed_tot, # rg_capex_a_cc = 100 * rg_capex_a_cc/rg_rab_closed_tot, # Normalizing rg_capex_a_sys = 100 * rg_capex_a_sys/rg_rab_closed_tot, # by Closing Year RAB rg_capex_a_repla = 100 * rg_capex_a_repla/rg_rab_closed_tot, # rg_capex_a_reloc = 100 * rg_capex_a_reloc/rg_rab_closed_tot) %>% # mutate(rg_capex_a_cc_sys = rg_capex_a_cc + rg_capex_a_sys, # Aggregating Variables rg_capex_a_new = rg_capex_a_repla + rg_capex_a_reloc) -> temp # temp %>% group_by(cluster,Year) %>% # <=== GROUP! summarise(avg_rse = mean(rg_capex_a_rse), # avg_cc_sys = mean(rg_capex_a_cc_sys), # Calculating the mean() avg_a_new = mean(rg_capex_a_new)) %>% # ungroup() %>% # <==== UNGROUP! gather(Description,Value,3:5) %>% # Transforming dataset # Plotting ggplot(aes(x= Year, # X axis y = Value , # Y axis fill = Description)) + # Fill the bar using Description info geom_bar(stat = "identity") -> q_breach_p3 # Standard config # Subsetting database to create Aurora Energy line in the plot temp %>% filter(EDB %in% "Aurora Energy") %>% select(cluster,Year, "avg_rse" = rg_capex_a_rse, "avg_cc_sys" = rg_capex_a_cc_sys, "avg_a_new" = rg_capex_a_new) %>% gather(Description,Value,3:5) %>% arrange(Description) -> ae_line # Adding the Aurora Value in the Bar Plot as a Line q_breach_p3 + geom_line(data = ae_line, inherit.aes = FALSE , aes(x = Year, y = Value, fill = Description), size = .5, color = "darkblue") + facet_grid(Description ~ cluster) + theme(legend.position="none") -> q_breach_p3 ggplotly(q_breach_p3) ``` ***
**Conclusions:** * Cluster 1 has increased from 2.37% in 2013 to 3.9% in 2018 ### 4. Taking a look of the causes of the unplanned interruptions, Aurora Energy has a good perform comparing with the Cluster. ```{r} db_neat %>% filter(Network %in% "All", # Removing Regionals !COD %in% c("VE","PO")) %>% # Removing Companies without representative clusters select(EDB,COD,cluster,island,Year,pop,rev_con_tot_ave_co, r_ae_saidi, # W r_aw_saidi, # W r_idk_saidi, # r_eqp_saidi, # r_hum_saidi, # r_lig_saidi, # W r_tpi_saidi, # r_veg_saidi, # V r_wlf_saidi) %>% # V mutate(r_i_cau_weath = r_ae_saidi + r_aw_saidi + r_lig_saidi, # Aggregating Variables r_i_veg_wlf = + r_wlf_saidi + r_veg_saidi)-> temp # temp %>% group_by(cluster,Year) %>% # <=== GROUP! summarise(avg_veg_wlf = mean(r_i_veg_wlf), # avg_weath = mean(r_i_cau_weath), # Calculating the mean() avg_idk = mean(r_idk_saidi), # Calculating the mean() avg_eqp = mean(r_eqp_saidi), # Calculating the mean() avg_hum_er = mean(r_hum_saidi), # Calculating the mean() avg_tpi = mean(r_tpi_saidi)) %>% # ungroup() %>% # <==== UNGROUP! gather(Description,Value,3:8) %>% # Transforming dataset # Plotting ggplot(aes(x= Year, # X axis y = Value , # Y axis fill = Description)) + # Fill the bar using Description info geom_bar(stat = "identity") -> q_breach_p4 # Standard config # Subsetting database to create Aurora Energy line in the plot temp %>% filter(EDB %in% "Aurora Energy") %>% select(cluster,Year, "avg_veg_wlf" = r_i_veg_wlf, "avg_weath" = r_i_cau_weath, "avg_idk" = r_idk_saidi, "avg_eqp" = r_eqp_saidi, "avg_hum_er" = r_hum_saidi, "avg_tpi" = r_tpi_saidi) %>% gather(Description,Value,3:8) %>% arrange(Description) -> ae_line # Adding the Aurora Value in the Bar Plot as a Line q_breach_p4 + geom_line(data = ae_line, inherit.aes = FALSE , aes(x = Year, y = Value, fill = Description), size = .5, color = "darkblue") + facet_grid(Description ~ cluster,scales = "free") + theme(legend.position="none") -> q_breach_p4 ggplotly(q_breach_p4) ``` ### 5. The equipments involved in Unplanned Interruptions in Aurora Energy network are concetrated at Distribution Level. Aurora Energy usually has a better perform then the Cluster Average. ```{r} db_neat %>% filter(Network %in% "All", # Removing Regionals !COD %in% c("VE","PO")) %>% # Removing Companies without representative clusters select(EDB,COD,cluster,island,Year, r_i_cau_equ_sub_li, r_i_cau_equ_sub_cb, r_i_cau_equ_sub_oth, r_i_cau_equ_dis_li_exc_lv, r_i_cau_equ_dis_cb_exc_lv, r_i_cau_equ_dis_oth_exc_lv) %>% # V mutate(r_i_cau_sub = r_i_cau_equ_sub_li + r_i_cau_equ_sub_cb + r_i_cau_equ_sub_oth) -> temp # temp %>% group_by(cluster,Year) %>% # <=== GROUP! summarise(avg_d_li = mean(r_i_cau_equ_dis_li_exc_lv), # avg_d_cb = mean(r_i_cau_equ_dis_cb_exc_lv), # Calculating the mean() avg_d_ot = mean(r_i_cau_equ_dis_oth_exc_lv), # Calculating the mean() avg_sub = mean(r_i_cau_sub)) %>% # ungroup() %>% # <==== UNGROUP! gather(Description,Value,3:6) %>% # Transforming dataset # Plotting ggplot(aes(x= Year, # X axis y = Value , # Y axis fill = Description)) + # Fill the bar using Description info geom_bar(stat = "identity") -> q_breach_p5 # Standard config # Subsetting database to create Aurora Energy line in the plot temp %>% filter(EDB %in% "Aurora Energy") %>% select(cluster,Year, "avg_d_li" = r_i_cau_equ_dis_li_exc_lv, "avg_d_cb" = r_i_cau_equ_dis_cb_exc_lv, "avg_d_ot" = r_i_cau_equ_dis_oth_exc_lv, "avg_sub" = r_i_cau_sub) %>% gather(Description,Value,3:6) %>% arrange(Description) -> ae_line # Adding the Aurora Value in the Bar Plot as a Line q_breach_p5 + geom_line(data = ae_line, inherit.aes = FALSE , aes(x = Year, y = Value, fill = Description), size = .5, color = "darkblue") + facet_grid(Description ~ cluster,scales = "free") + theme(legend.position="none") + labs(x = "Year", y = "SAIDI [minutes]") -> q_breach_p5 ggplotly(q_breach_p5) ``` ### 6. Observing the number of interruptions restored in more than 3 hours, Aurora Energy has been decreasing this rate since 2016. Regarding of the Cluster, has better performance. ```{r} db_neat %>% filter(Network %in% "All", # Removing Regionals !COD %in% c("VE","PO")) %>% # Removing Companies without representative clusters select(EDB,COD,cluster,island,Year, r_less_3, r_more_3,r_i_un) %>% mutate(r_less_3 = 100*r_less_3/r_i_un, r_more_3 = 100*r_more_3/r_i_un) -> temp # V temp %>% group_by(cluster,Year) %>% # <=== GROUP! summarise(avg_less_3 = mean(r_less_3), # avg_more_3 = mean(r_more_3)) %>% # ungroup() %>% # <==== UNGROUP! gather(Description,Value,3:4) %>% # Transforming dataset # Plotting ggplot(aes(x= Year, # X axis y = Value , # Y axis fill = Description)) + # Fill the bar using Description info geom_bar(stat = "identity") -> q_breach_p6 # Standard config # Subsetting database to create Aurora Energy line in the plot temp %>% filter(EDB %in% "Aurora Energy") %>% select(cluster,Year, "avg_less_3" = r_less_3, "avg_more_3" = r_more_3) %>% gather(Description,Value,3:4) %>% arrange(Description) -> ae_line # Adding the Aurora Value in the Bar Plot as a Line q_breach_p6 + geom_line(data = ae_line, inherit.aes = FALSE , aes(x = Year, y = Value, fill = Description), size = .5, color = "darkblue") + facet_grid(Description ~ cluster) + theme(legend.position="none") + labs(x = "Year", y = "[%]") + ylim(c(0,100)) -> q_breach_p6 ggplotly(q_breach_p6) ``` *** For all cluster, most of the outages restored in less than 3 hours are about 70%, seems the Big companies (Cluster 5) has more dificult to restore quickly. Companies in CLuster 1 and 2 has better performance in regard to restore promprtly. In the last two year, Aurora Energy performs is better the the average of the Cluster 1.
**Conclusions:** * Aurora has a god performance in this item as well. ### 7. The Total Fault Rate observed in Cluster 1 and 5 has been increasing over the year, and the Cluster 1 is the one with higher fault rate per 100 km, reached 16.9 faults/100km. ```{r echo=FALSE} db_neat %>% filter(Network %in% "All", !COD %in% c("VE","PO")) %>% select(EDB,cluster,Year,r_i_tot,r_i_pl,r_i_un,a_li) %>% mutate(rate_i_pl = 100 * r_i_pl/a_li, rate_i_un = 100 * r_i_un/a_li, rate_i_tot = 100 * r_i_tot/a_li) -> temp temp %>% group_by(cluster,Year) %>% # <=== GROUP! summarise(avg_rate_i_pl = mean(rate_i_pl), # avg_rate_i_un = mean(rate_i_un), # avg_rate_i_tot = mean(rate_i_tot)) %>% # ungroup() %>% # <==== UNGROUP! gather(Description,Value,3:5) %>% # Transforming dataset # Plotting ggplot(aes(x= Year, # X axis y = Value , # Y axis fill = Description)) + # Fill the bar using Description info geom_bar(stat = "identity") -> q_breach_p7 # Standard config # Subsetting database to create Aurora Energy line in the plot temp %>% filter(EDB %in% "Aurora Energy") %>% select(cluster,Year, "avg_rate_i_pl" = rate_i_pl, "avg_rate_i_un" = rate_i_un, "avg_rate_i_tot" = rate_i_tot) %>% gather(Description,Value,3:5) %>% arrange(Description) -> ae_line # Adding the Aurora Value in the Bar Plot as a Line q_breach_p7 + geom_line(data = ae_line, inherit.aes = FALSE , aes(x = Year, y = Value, fill = Description), size = .5, color = "darkblue") + facet_grid(Description ~ cluster) + theme(legend.position="none") + labs(x = "Year", y = "[interruptions/100km]") -> q_breach_p7 ggplotly(q_breach_p7) ``` ### 8. OPEX/km vs Network Length ```{r echo=FALSE} db_neat %>% filter(Network %in% "All", !COD %in% c("VE","PO")) %>% mutate(Year = factor(Year)) %>% mutate(rg_opex_km = rg_opex_tot/a_li) %>% ggplot(aes(x = rg_opex_km, y = log(r_i_un), shape = Year) ) + geom_point(aes(color = COD)) -> q_breach_p8 #q_breach_p8 + facet_grid(. ~ cluster) + theme(legend.position = "none")-> q_breach_p8 ggplotly(q_breach_p8) ``` ### 9. (Network OPEX)/km vs Network Length ```{r echo=FALSE} db_neat %>% filter(Network %in% "All") %>% mutate(Year = factor(Year)) %>% mutate(rg_opex_net_km = rg_opex_net/a_li) %>% ggplot(aes(x = rg_opex_net_km, y = (r_i_un), shape = Year) ) + geom_point(aes(color = COD)) -> q_breach_p9 #q_breach_p9 + facet_grid(. ~ cluster) + theme(legend.position = "none")-> q_breach_p8 ggplotly(q_breach_p9) ``` ***
**Conclusions:** ### **8. Final:** ```{r} db_neat %>% filter(Network %in% "All", # Removing Regionals !COD %in% c("VE","PO")) %>% # Removing Companies without representative clusters select(EDB,COD,cluster,island,Year, r_saidi, r_saifi) %>% group_by(cluster,Year) %>% # <=== GROUP! summarise(avg_saidi = mean(r_saidi), # avg_saifi = mean(r_saifi)) %>% # ungroup() %>% gather(Description,Value,3:4) %>% # Transforming dataset # Plotting ggplot(aes(x= Year, # X axis y = Value , # Y axis fill = Description)) + # Fill the bar using Description info geom_bar(stat = "identity") -> q_breach_p8 # Standard config # Subsetting database to create Aurora Energy line in the plot db_neat %>% filter(EDB %in% "Aurora Energy", Network %in% "All", # Removing Regionals !COD %in% c("VE","PO")) %>% # Removing Companies without representative clusters select(cluster, Year, avg_saidi = r_saidi, avg_saifi = r_saifi) %>% gather(Description,Value,3:4) %>% arrange(Description) -> ae_line # Adding the Aurora Value in the Bar Plot as a Line q_breach_p8 + geom_line(data = ae_line, inherit.aes = FALSE , aes(x = Year, y = Value, fill = Description), size = .5, color = "darkblue") + facet_grid(Description ~ cluster, scales = "free") + theme(legend.position="none") + labs(x = "Year", y = "[interruptions] or [minutes]") -> q_breach_p8 ggplotly(q_breach_p8) ``` ***
**Conclusions:** based on the graphics shown in itens 1,2,3,4,5 and 6, Aurora Energy does not have a bad service as expected reading the *One Page Summary*. The only weakness is the lack in Replacement and Renewal (an OPEX), since 2015 Aurora have been investing less then the average of the Cluster, in a long run it could lead a deterioration of the assets and rise the outages with causes in equipment. Loss Breach {.storyboard data-navmenu="Analysis"} ================================================================================================================= ### 1. How is the losses in each cluster? ```{r} db_neat %>% filter(Network %in% "All", !COD %in% c("VE","PO")) %>% mutate(s_loss = 100*s_loss/s_ent_enr) %>% ggplot(aes( x = factor(Year), y = s_loss)) + geom_boxplot() + facet_grid(. ~ cluster) -> lb_p1 ggplotly(lb_p1) ``` ### 2. What is the losses' behavior in regarding og Network length? ```{r} db_neat %>% filter(Network %in% "All", !COD %in% c("VE","PO")) %>% ggplot(aes(x = log(a_li), y = log(s_loss))) + geom_point(aes(color = cluster)) + geom_smooth(method = "lm") -> lb_p2 ggplotly(lb_p2) ``` *** As expected, the graphic shows a tendence of the losses increasing accordling with the network length.
**Conclusions:** * It is possible to trace a line trend to calculate the coeficients. ### 3. Linear Regression to each cluster ```{r} db_neat %>% filter(Network %in% "All", !COD %in% c("VE","PO")) %>% ggplot(aes(x = log(a_li), y = log(s_loss))) + geom_point(aes(color = cluster)) + geom_smooth(method = "lm") + facet_grid(. ~ cluster, scales = "free") -> lb_p3 ggplotly(lb_p3) ``` ### 4. Polynomial model - y ~ x^2 ```{r} db_neat %>% filter(Network %in% "All", !COD %in% c("VE","PO")) %>% ggplot(aes(x = log(a_li), y = log(s_loss))) + geom_point(aes(color = cluster)) + geom_smooth(method = "lm" , formula = y ~ poly(x,2)) -> lb_p4 ggplotly(lb_p4) ``` ### 5. Calculating losses in percentage of the total energy entering ```{r} db_neat %>% filter(Network %in% "All", !COD %in% c("VE","PO")) %>% mutate(s_loss = 100*s_loss/s_ent_enr) %>% ggplot(aes(x = a_li, y = s_loss)) + geom_point(aes(color = cluster)) + geom_smooth(method = "lm" , formula = y ~ poly(x,2)) -> lb_p5 ggplotly(lb_p5) ``` ### 6. ```{r} db_neat %>% filter(EDB %in% "Aurora Energy") %>% mutate(rate_loss = 100*s_loss/s_ent_enr) %>% ggplot(aes(x = Year, y = rate_loss)) + geom_bar(stat = "identity" ,aes(fill = factor(Year) ) ) + facet_grid(. ~ Network) + geom_hline(yintercept = 6, color = "red2") + theme(legend.position = "none") + ylim(c(0,15)) -> lb_p6 ggplotly(lb_p6) ``` *** Analysing by Regional, Dunedin has been performing losses under 6% (except 2015)
**Conclusions:** Poles {.storyboard data-navmenu="Analysis"} ================================================================================================================= ### 1. ```{r} db_neat %>% filter(Network %in% "All", !COD %in% c("VE","PO")) %>% select(cluster, Year, matches("a_wp_")) %>% gather(Description, Value,3:30) %>% filter(Value > 0) %>% group_by(cluster, Year, Description) %>% summarise(Value = mean(Value)) %>% ungroup() %>% filter(Year %in% 2018) %>% mutate(Sample = "Average") -> temp gsub(temp$Description,pattern = "a_wp_",replacement = "") -> temp$Description db_neat %>% filter(EDB %in% "Aurora Energy", Network %in% "All", Year %in% 2017) %>% select(cluster, Year, matches("a_wp_")) %>% gather(Description, Value,3:30) %>% mutate(Value = -Value,Sample = "Aurora Energy") -> temp2 gsub(temp2$Description,pattern = "a_wp_",replacement = "") -> temp2$Description bind_rows(temp,temp2) -> temp3 ggplot(temp3,aes(x = Description, y = Value, fill = Sample) ) + geom_bar(stat = "identity", position = position_dodge()) + coord_flip() -> pole_p1 pole_p1 + facet_grid(. ~ cluster) -> pole_p1 ggplotly(pole_p1) ``` ### 2. ```{r} db_neat %>% filter(Network %in% "All", !COD %in% c("VE","PO")) %>% select(cluster, Year, matches("a_cp_")) %>% gather(Description, Value,3:30) %>% filter(Value > 0) %>% group_by(cluster, Year, Description) %>% summarise(Value = mean(Value)) %>% ungroup() %>% filter(Year %in% 2018) %>% mutate(Sample = "Average") -> temp gsub(temp$Description,pattern = "a_cp_",replacement = "") -> temp$Description db_neat %>% filter(EDB %in% "Aurora Energy", Network %in% "All", Year %in% 2017) %>% select(cluster, Year, matches("a_cp_")) %>% gather(Description, Value,3:30) %>% mutate(Value = -Value,Sample = "Aurora Energy") -> temp2 gsub(temp2$Description,pattern = "a_cp_",replacement = "") -> temp2$Description bind_rows(temp,temp2) -> temp3 ggplot(temp3,aes(x = Description, y = Value, fill = Sample) ) + geom_bar(stat = "identity", position = position_dodge()) + coord_flip() -> pole_p2 pole_p2 + facet_grid(. ~ cluster) -> pole_p2 ggplotly(pole_p2) ``` Interactive Dashboard {data-navmenu="Beta"} ================================================================================================================= Inputs {.sidebar} ------------------------------------- ```{r echo=FALSE,eval = FALSE} selectInput("var_y", label = "Variable on Y axis", choices = c("Total Length [km]" = "a_li", "Total Energy Entering" = "s_ent_enr"), selected = "a_li") selectInput("var_x", label = "Variable on X axis", choices = c("Year", "Consumers" = "s_tot_enr"), selected = "Year") ``` Column ------------------------------------- ### Chart 1 ```{r echo=FALSE,eval = FALSE} renderPlotly({ pf <- ggplot(data = db_neat, aes_string(x = input$var_x, y = input$var_y, color = "EDB")) + geom_point() ggplotly(pf) }) ```