Dataset

Terminology

PTF = Market Clearing Price

SMF = System Marginal Price

PDF = Positive Unbalance Price

NDF = Negative Unbalance Price

For more detailed information, you can visit the EPİAŞ website.

Reading Data

ptfsmf <- read_excel('ptf-smf.xls')
glimpse(ptfsmf)
## Rows: 744
## Columns: 6
## $ Tarih                                 <chr> "01.07.20 00:00", "01.07.20 01:…
## $ PTF                                   <chr> "323,85", "326,95", "324,31", "…
## $ SMF                                   <chr> "211,00", "201,00", "211,00", "…
## $ `Pozitif Dengesizlik Fiyatı (TL/MWh)` <chr> "204,67", "194,97", "204,67", "…
## $ `Negatif Dengesizlik Fiyatı (TL/MWh)` <chr> "333,57", "336,76", "334,04", "…
## $ `SMF Yön`                             <chr> "↓Enerji Fazlası", "↓Enerji Faz…

Editting Data

# Arrangement of the names of the positive and negative imbalance columns
colnames(ptfsmf)[4] = "PDF"
colnames(ptfsmf)[5] = "NDF"

# Converting the date and time to POSIX format
ptfsmf <- ptfsmf %>% mutate(Tarih_Yeni = 
                              as.POSIXct(ptfsmf$Tarih,format="%d.%m.%y %H:%M", "GMT")) %>%
                     select(Tarih_Yeni, PTF, SMF, PDF, NDF) %>%
                     rename(Tarih = Tarih_Yeni)

# Converting the remaining columns to numeric class
ptfsmf[,c(2:5)] <- lapply(ptfsmf[,c(2:5)],
                          function(x) as.numeric(gsub(",", ".", gsub("\\.", "", x))))

1.Weekly Analysis

Data preparition for weekly analysis

weekly_analysis <- ptfsmf %>%
  select(Tarih,PTF,SMF,PDF,NDF) %>%
  mutate(Week=as.factor(week(Tarih)))%>%
  pivot_longer(cols = c(PTF,SMF,PDF,NDF),names_to = 'names',values_to='values')%>%
  group_by(Week,names)%>%
  summarise(sum_price=sum(values),mean_price=mean(values),max_price = max(values),min_price=min(values),.groups = 'drop')%>%
  transform(Week=as.numeric(Week))
glimpse(weekly_analysis)
## Rows: 20
## Columns: 6
## $ Week       <dbl> 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5
## $ names      <chr> "NDF", "PDF", "PTF", "SMF", "NDF", "PDF", "PTF", "SMF", "N…
## $ sum_price  <dbl> 56177.97, 45287.71, 50296.42, 50933.68, 51405.05, 40423.69…
## $ mean_price <dbl> 334.3927, 269.5697, 299.3835, 303.1767, 305.9824, 240.6172…
## $ max_price  <dbl> 473.80, 339.49, 349.99, 460.00, 379.84, 300.60, 321.35, 36…
## $ min_price  <dbl> 169.58, 110.34, 164.64, 113.75, 144.21, 120.04, 140.01, 12…

Visualiation

ggplot(weekly_analysis,aes(x=Week, y = mean_price, fill = names)) +
  geom_col(position="dodge2")+
  labs(y=" Weekly Average of Prices")+
  theme_minimal()

ggplot(weekly_analysis,aes(x=Week, y = max_price, fill = names)) +
  geom_col(position='dodge2')+
  labs(y=" Weekly Max Prices")+
  theme_minimal()

ggplot(weekly_analysis,aes(x=Week, y = min_price, fill = names)) +
  geom_col(position="dodge2")+
  labs(y=" Weekly Minimum Prices")+
  theme_minimal()

2. Daily Analysis

Data preparition for hourly analysis

daily_analysis <- ptfsmf %>%
  select(Tarih,PTF,SMF,PDF,NDF) %>%
  mutate(Day=as.factor(day(Tarih)))%>%
  pivot_longer(cols = c(PTF,SMF,PDF,NDF),names_to = 'names',values_to='values')%>%
  group_by(Day,names)%>%
  summarise(sum_price=sum(values),mean_price=mean(values),max_price = max(values),min_price=min(values),.groups = 'drop')%>%
  transform(Day=as.numeric(Day))
glimpse(daily_analysis)
## Rows: 124
## Columns: 6
## $ Day        <dbl> 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5…
## $ names      <chr> "NDF", "PDF", "PTF", "SMF", "NDF", "PDF", "PTF", "SMF", "N…
## $ sum_price  <dbl> 8173.93, 6002.58, 7683.25, 6440.82, 8822.78, 6943.67, 7158…
## $ mean_price <dbl> 340.5804, 250.1075, 320.1354, 268.3675, 367.6158, 289.3196…
## $ max_price  <dbl> 388.69, 322.40, 332.37, 377.37, 416.14, 311.86, 321.50, 40…
## $ min_price  <dbl> 216.43, 110.34, 210.13, 113.75, 236.21, 193.35, 199.33, 22…
ggplot(daily_analysis, aes( Day,mean_price)) + 
  geom_point()+
  geom_smooth() +
    labs(
        x = "Days of July", # making the axis label blank will remove it
        y = "Price(mean)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

3.Hourly Analysis

Data preparition for hourly analysis

hourly_analysis <- ptfsmf %>%
  select(Tarih,PTF,SMF,PDF,NDF) %>%
  mutate(Hour=as.factor(hour(Tarih)))%>%
  pivot_longer(cols = c(PTF,SMF,PDF,NDF),names_to = 'names',values_to='values')%>%
  group_by(Hour,names)%>%
  summarise(sum_price=sum(values),mean_price=mean(values),max_price = max(values),min_price=min(values),.groups = 'drop')%>%
  transform(Hour=as.numeric(Hour))
glimpse(hourly_analysis)
## Rows: 96
## Columns: 6
## $ Hour       <dbl> 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5…
## $ names      <chr> "NDF", "PDF", "PTF", "SMF", "NDF", "PDF", "PTF", "SMF", "N…
## $ sum_price  <dbl> 10030.16, 8346.03, 9218.01, 9124.15, 10350.75, 8696.65, 94…
## $ mean_price <dbl> 323.5535, 269.2268, 297.3552, 294.3274, 333.8952, 280.5371…
## $ max_price  <dbl> 375.95, 303.48, 323.85, 365.00, 371.46, 302.75, 326.95, 36…
## $ min_price  <dbl> 236.84, 173.63, 229.94, 179.00, 301.79, 174.60, 293.00, 18…

Visualization

ggplot(hourly_analysis, aes(x = Hour, y = mean_price)) +
    geom_point() + 
    geom_smooth() +
    labs(title = "Hourly Analysis",
        x = "Days of June", 
        y = "Price(mean)")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

PTF vs SMF

ggplot(ptfsmf,aes(x=PTF,y=SMF)) + 
  geom_point()+ 
  geom_smooth() +
  labs(
        x = "PTF",
        y = "SMF")
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'