# Introduction.

Another of the electoral dimensions that acquires special relevance in the electoral studies is the one known as volatility. Basically, what it tries to measure is how the electoral behavior of the voters changes from one electoral process to another and, in short, the level of fidelity of the voters in relation to their democratically elected representatives. Once the concept is defined, the difficulty comes in the way of measuring it, given the wide field that we want to cover with this dimension.

In 1979 it was Pederson who proposed the formula that allows its calculation and whose mathematical expression is the following:

$VT=\frac{1}{2}\sum_{i=1}^{n}\left|\triangle p_{i}\right|$ Where $$\triangle p_{i}$$ denotes the increase or decrease of electoral support between two elections expressed as a percentage of the vote.

Although there are other different approaches that seek to measure that magnitude as well. In this sense, the individual measurement of the change in the vote of each voter can also be done [^1](In this case, a totally disaggregated volatility would be calculated where the changes in the tendency of the electorate would be clearly manifested. The difficulty in this case would come from the impossibility of obtaining this information at this level of detail, since to achieve this objective it would be necessary to carry out a complete census, requiring a disproportionate effort to achieve the set objective). To get closer to this ideal situation, it would be possible to perform surveys that would give us an approximation of the problem. One of the statistical studies that could provide us with this information can be found in the opinion barometers that the Spanish Sociological Research Centre (CIS) periodically publishes (Spanish Sociological Research Centre ), which usually include a question about the informant’s voting intention and which political party he/she voted for in previous elections. With sufficient caution, and even if it is only to obtain an estimated value of the reality to be measured, it would be possible to cross these two variables and in this way obtain an approximation of the volatility of the electorate at individual level.

As explained by Oñate and Ocaña (1999), aggregate volatility (VT) has subsequently been broken down into two other components, which clarify and complement the possible conclusions that can be drawn from aggregate volatility. On the one hand, there is the volatility between blocks (VB), which tries to measure how the vote has changed between two ideological blocks (such as right-left, or even center-periphery). The measurement of this magnitude is performed by means of the following formula:

$VB=\frac{\left|\triangle p_{i}+...+\triangle p_{k}\right|}{2}+\frac{\left|\triangle p_{x}+...\triangle p_{z}\right|}{2}$ Indicating with i…k the parties classified within a block and with x…z those corresponding to the other block.

The other component of the total or aggregate volatility is called Intrablock Volatility (VIB), which attempts to measure the changes in electoral or parliamentary support within each ideological block considered. The way to calculate its value is through the expression: $VIB = VT -VB$

# Volatility calculation.

The computation of these indicators is not easy to obtain and, since it involves the comparison of two electoral processes, it is necessary to have data that allows the comparison between the two processes considered. In order to establish this relationship between the two processes, the following aspects must be taken into account:

• The parties or groupings of parties must be linked between the two time periods.
• There may be parties that are only present in one period, either because they disappear or are newly created.
• A party or coalition may disaggregate into other groups between the two time periods.

In the Relectoral package the function called volatilidad() has been implemented, which has a parameter called enlace and it is the one that refers to a data.frame that contains the data that will allow to make comparisons between the two different electoral processes, whose structure is going to be described later.

The parameters to be provided to the volatilidad() function are the following:

1.- A data.frame made up of two columns. The first contains the names of the parties and the second the votes/seats. This information refers to the first comparison period. If votes are provided, the electoral volatility will be obtained, and if seats are provided, the parliamentary volatility will be obtained.

2.- A second data.frame made up of two columns. The first contains the names of the parties and the second the votes/seats. The data will correspond to the results obtained in the second election under comparison.

3.- A third data.frame that will serve as a link between the two previous ones. Its generic name is enlace, and since its structure is more complex, we will now proceed to give a more detailed description of it.

To try to explain better how the structure of the data.frame referenced in the enlace parameter should be, the following figure has been created, which aims to clarify completely how it should look like.