-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionality-for-rjd3modelling.Rmd
More file actions
204 lines (155 loc) · 6.7 KB
/
functionality-for-rjd3modelling.Rmd
File metadata and controls
204 lines (155 loc) · 6.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
---
title: "Extra functionality for `rjd3modelling`"
author: "Mārtiņš Liberts (Central Statistical Bureau of Latvia)"
date: "`r Sys.time()`"
output:
pdf_document:
toc: yes
number_sections: yes
toc_depth: 4
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Holidays in Latvia
There are specific holidays in Latvia which are not possible to describe with `rjd3modelling` functions currently. The following extra functionality would be necessary.
## Holidays with compensation
There are holidays with a so called compensation mechanism. If a holiday in question is on Saturday or Sunday, then the next working day is also a holiday.
### May 4
May 4 (Restoration of Independence) is a public holiday since 2002. The compensation mechanism for the May 4 was introduced since 2008. If May 4 is on a Saturday or Sunday than the next working day is also a holiday. The next working day is always Monday as there is no clash with other holiday currently.
- If May 4 is on a weekday from Monday to Friday, only May 4 is a holiday.
- If May 4 is on Saturday, than May 4 is a holiday and also May 6 (the next Monday) is a holiday.
- If May 4 is on Sunday, than May 4 is a holiday and also May 5 (the next Monday) is a holiday.
Alternative description of the compensation mechanism:
- May 4 is always a holiday.
- May 5 is a holiday if May 5 is on Monday.
- May 6 is a holiday if May 6 is on Monday.
There have been four cases so far when May 4 has been compensated with an extra holiday. The extra holidays were:
- 2008-05-05
- 2013-05-06
- 2014-05-05
- 2019-05-06
### November 18
November 18 (Proclamation Day of the Republic of Latvia) is a public holiday since 1990. The compensation mechanism for the November 18 was introduced since 2007. If November 18 is on a Saturday or Sunday than the next working day is also a holiday. The next working day is always Monday as there is no clash with other holiday currently.
- If November 18 is on a weekday from Monday to Friday, only November 18 is a holiday.
- If November 18 is on Saturday, than November 18 is a holiday and also November 20 (the next Monday) is a holiday.
- If November 18 is on Sunday, than November 18 is a holiday and also November 19 (the next Monday) is a holiday.
Alternative description of the compensation mechanism:
- November 18 is always a holiday.
- November 19 is a holiday if November 19 is on Monday.
- November 20 is a holiday if November 20 is on Monday.
There have been four cases so far when November 18 has been compensated with an extra holiday. The extra holidays were:
- 2007-11-19
- 2012-11-19
- 2017-11-20
- 2018-11-19
### Implementation in `rjd3modelling`
Extra arguments for the function `calendar.fixedday` would be necessary to implement the compensation mechanism from the user interface. Two extra arguments for the function `calendar.fixedday` similar to arguments from the function `holidays` would be necessary:
- `nonworking = c(6, 7)`: Indexes of non working days (Monday=1, Sunday=7).
- `compensation = c("None", "NextWorkingDay", "PreviousWorkingDay")`
So, the description of the `calendar.fixedday` would be:
```
calendar.fixedday(
calendar,
month,
day,
weight = 1,
start = NULL,
end = NULL,
nonworking = c(6, 7),
compensation = c("None", "NextWorkingDay", "PreviousWorkingDay")
)
```
The May 4 would be defined as:
```
calendar.fixedday(
calendar = cal_lv,
month = 5,
day = 4,
weight = 1,
start = "2002-01-01",
end = "2007-12-31",
nonworking = c(6, 7),
compensation = "None"
)
calendar.fixedday(
calendar = cal_lv,
month = 5,
day = 4,
weight = 1,
start = "2008-01-01",
end = NULL,
nonworking = c(6, 7),
compensation = "NextWorkingDay"
)
```
The November 18 would be defined as:
```
calendar.fixedday(
calendar = cal_lv,
month = 11,
day = 18,
weight = 1,
start = NULL,
end = "2006-12-31",
nonworking = c(6, 7),
compensation = "None"
)
calendar.fixedday(
calendar = cal_lv,
month = 11,
day = 18,
weight = 1,
start = "2007-01-01",
end = NULL,
nonworking = c(6, 7),
compensation = "NextWorkingDay"
)
```
## A holiday once in five years
We have a very recent holiday which will take place only once in a five years. General Latvian Song and Dance Celebration happens **once in 5 years**. The closing day of the celebration is a holiday since 2018. Traditionally the the closing day of the celebration is on Sunday of the first week of July. To make it more complicated - this is another holiday with a compensation. The next working day is also a holiday. So there are two holidays - Sunday of the 1st week of July and Monday of the 2nd week of July.
It has been a holiday only once so far. The July 8 (Sunday) and 9 (Monday) in 2018 were holidays for the first time because of the General Latvian Song and Dance Celebration. The next celebration will be in 2023. So, July 9 and 10 on 2023 should be holidays.
The 5 years cycle of the General Latvian Song and Dance Celebration is defined by the law. The date of the closing day is not defined by the law. So, it can happen that other date of the closing day is chosen. It has been almost always on Sunday of the 1st week of July since 1993. However, there was one exception. The closing day of the celebration in 2008 was on Saturday of the 2nd week of July (it was 2008-07-12). We will not be able to model it as a continuous holiday if the tradition will be broken once again.
The list closing days of the General Latvian Song and Dance Celebration since 1993:
- 1993-07-04
- 1998-07-05
- 2003-07-06
- 2008-07-12 (the exception - it was on Saturday of the 2nd week of July)
- 2013-07-07
- 2018-07-08
- _2023-07-09_ (this is assumption, it has not been defined yet)
### Implementation in `rjd3modelling`
Extra arguments for the function `calendar.fixedweekday` would be necessary to implement this holiday with a compensation mechanism from the user interface. Three extra arguments for the function `calendar.fixedweekday` would be necessary:
- `cycle = 1`: Cycle in years (by default one year).
- `nonworking = c(6, 7)`: Indexes of non working days (Monday=1, Sunday=7).
- `compensation = c("None", "NextWorkingDay", "PreviousWorkingDay")`
So, the description of the `calendar.fixedweekday` would be:
```
calendar.fixedweekday(
calendar,
month,
week,
dayofweek,
cycle = 1,
weight = 1,
start = NULL,
end = NULL,
nonworking = c(6, 7),
compensation = c("None", "NextWorkingDay", "PreviousWorkingDay")
)
```
The closing day of the General Latvian Song and Dance Celebration would be defined as:
```
calendar.fixedweekday(
calendar = cal_lv,
month = 7,
week = 1,
dayofweek = 7,
cycle = 5,
weight = 1,
start = "2018-01-01",
end = NULL,
nonworking = c(6, 7),
compensation = "NextWorkingDay"
)
```