IndexNumber: An R Package for measuring the evolution of magnitudes

Index numbers are descriptive statistical measures useful in economic settings for comparing simple and complex magnitudes registered, usually, in two time periods. Although this theory has a large history, it still plays an important role in modern today’s societies where big amounts of economic data are available and need to be analysed. After a detailed revision on classical index numbers in literature, this paper is focused on the description of the R package IndexNumber with strong capabilities for calculating them. Two of the four real data sets contained in this library are used for illustrating the determination of the index numbers in this work. Graphical tools are also implemented in order to show the time evolution of considered magnitudes simplifying the interpretation of the results.


Introduction
The problem of reducing a large amount of available microeconomic data is common in dynamic and modern economies. Individuals of today's societies consume services of hundred of commodities over a year, and most producers use and produce hundreds of individual products and services. This overwhelming abundance of data is usually summarized through index numbers theory. Index numbers are descriptive statistical measures useful in order to compare or measure changes in simple and complex magnitudes over time. The goal is usually to determine possible increases or decreases and, more generally, trend changes. The situations to be compared are in no way restricted; they may be two time periods (hours, days, months, or years); two places (two cities or countries); or two groups of people (economically active and inactive population). For simplicity in the exposition, we refer to temporal index numbers in this paper. The rest of the situations mentioned could be considered modifying the notation slightly.
prices and in real consumption. Some more recent contributions in index numbers theory are exposed next. Barnett (1980) focused on economic monetary aggregates from this approach. Changes in food prices were analyzed in Lamm (1980). Index numbers in chain, or more commonly chain indices, are considered in Forsyth and Fowler (1981). Boyle (1988) analyzed the volume of Irish agricultural output from 1960 to 1982. Scanner data on coffee sales are studied in de Haan and Opperdoes (1997). Hill (1999) shows how a comparison of price levels across a group of countries can be made by chaining Fisher index numbers across a spanning tree. Inequality and poverty in several regions of Thailand are studied through the construction of urban and rural cost of living and welfare indices in Kakwani and Hill (2002). Dumagan (2002) showed that the Fisher index could be numerically approximated by other superlative index numbers. In Reinsdorf et al. (2002), additive decompositions of the Fisher index are derived in order to know how much each item contributes to its overall change. From data from United States, Canada, France, Germany, Italy, Japan, and the United Kingdom, drug price and quantity index numbers are considered in Danzon and Chao (2000). Ang et al. (2004) used a generalized version of the Fisher index to analyze CO 2 emission. In Boyd and Roop (2004), the structural change in energy intensity is studied. Exploring the duality between a return to dollar definition of profit and the generalized distance function, the relationship between the Laspeyres, Paasche and Fisher productivity index numbers is established in Zofío and Prieto (2006). Hill (2006) showed an illustration on index numbers also using scanner data. An application to major crops in Manitoba is presented in Coyle (2007). According to Diewert and Nakamura (2007), Paasche, Laspeyres, or Fisher index number formula is useful in order to manage the total factor productivity growth. The importance of the hedonic imputation method in price index numbers is analyzed in Hill and Melser (2008) from a data set containing house prices for three regions in Sydney over a three years period. The impact of time aggregation on price change estimates for several supermarket item categories is considered in Ivancic et al. (2011). Białek (2012) proposed a general price index formula with the Fisher, Laspeyres, and Paasche indices as its particular cases. Białek (2014) presented an original price index, and its performance is analyzed through a simulation study where it is compared to several classical price index numbers. A generalized version of the Fisher index is considered in Su and Ang (2014) in order to analyze changes in the carbon emissions embodied in China's exports. O'Donnell (2018) analyzed the productivity change defined as measures of output quantity change divided by measures of input quantity change. Zhen et al. (2019) constructed panel price index numbers using retail scanner data in order to compare consumption costs across space and time.
This paper is focused on the description of the R package IndexNumber (Saavedra-Nieves and Saavedra-Nieves, 2021), available from the Comprehensive R Archive Network at https://CRAN.Rproject.org/package=IndexNumber, and its capabilities for calculating classical index numbers. It is organized as follows. Index numbers are formally defined in Section 2.2. Section 2.2.1 introduces simple index numbers. Concretely, simple index numbers in series and in chain are distinguished. In Section 2.2.2, non-weighted and weighted complex index numbers are presented. Details on the usage of IndexNumber package are considered from Section 2.3. The four real data sets contained in the library are also described briefly. Note that two of them are used in this paper in order to illustrate the calculation of index numbers. They are available on the website of the Spanish Statistical Office (INE), http://www.ine.es.

Preliminaries on index numbers
Index numbers are statistical measures that are useful to compare single and multiple magnitudes for the same interval of time. In both cases, this comparison is made with respect to an element of the mentioned series that is called base period or reference. Some examples of simple magnitudes are prices of a good, sold amounts of a product, or other general individual values. However, most of the time, comparing these simple quantities has not practical interest. If the goal is to analyze some real phenomena where many variables are involved, complex indices must be considered. Using these ideas, index numbers are usually classified into the following two groups: • An index number is said to be simple if it corresponds to the ratio of two values of the same variable, measured in two different instants. Therefore, a simple index number provides the variation that the single magnitude has suffered between two different time periods. For instance, a simple index number of the price will give the relative variation of the price between the current period and the period taken as reference.
• Most of the time, comparing prices, amounts, or values of a single product individually is not of interest in practice. If the goal is to analyze some real situations where different variables have influence, a complex number index has to be considered. It globally summarizes the information of the different magnitudes involved in the problem. For instance, the evolution cost of life in a country is a common case where it is necessary to select a set of goods or variables that give information about it. The relative importance of each of the goods considered must be measured and taken into account.
A wider overview of both classes of index numbers is included in the next sections. In particular, we distinguish the different subclasses belonging to each of them and their possible relationships.

Simple index numbers
A simple index number is a statistical indicator of the percentage of variation of a single magnitude in two different instants. Simple index numbers are usually classified according to the element that we take as reference. In particular, we distinguish two types of simple index numbers. First, we describe simple index numbers in series, when the first value of the series is taken as the reference value, and simple index numbers in chain (or chain indices), when the reference is the immediately previous value in the serie.
In what follows, we assume that X = {x 0 , x 1 , . . . , x T } denotes the observations of the magnitude X for the T + 1 time instants considered. Besides, x 0 is usually taken as the base period. Most common simple index numbers are individually referred to variables in real-world situations as the followings: • the price of a good, denoted by p; • the amount of produced or sold product, denoted by q; or • the value of a good, denoted by v. This value is usually obtained as the product of the price and the amount variables.
In this section, we illustrate the usage of simple index numbers on a real example.

Simple index numbers in series
Let x 0 and x t be the values of the variable X where x 0 corresponds to the base period and t ∈ {0, 1, . . . , T}, respectively. Thus, the value of the simple index number in series for X in t is defined as follows: For each t ∈ {0, 1, . . . , T}, this measure has a natural interpretation. Fixed a certain variable of interest X, the index number in series in t shows the percentage of variation of the magnitude in this instant of time with respect to the reference value (in this case, the initial one).
Using this type of index number, some usual magnitudes can be formally defined as it is indicated next: • When prices are considered, the relative price of a product i, also called simple price index, can be determined as where p it denotes the price at instant t and p i0 , the price in the base period.
• The relative amount of a product i can be written as where q it denotes the produced or sold amount at instant t and q i0 , the amount for the base period.
• Finally, the relative value of a product i has the next expression: where v t denotes the value of the good at instant t and v 0 , the value of the base period.
Below, we illustrate the usage of simple index numbers on the two series included in Table 1. Thus, the simple index numbers in series for the economically active women and men in Spain from the first trimester of 2002 is given in  Comparing the evolution of the index numbers in series for the population of women and men shown in Table 2 has an interest, for instance, to analyze the effect of variable sex in the Spanish labor market. Note that the number of economically active women and men in the second trimester of 2003 is 7.2% and 4.2% larger than in the reference time, respectively. Therefore, women increasing is slightly larger than men.

Simple index numbers in chain
Below, we introduce another approach of simple index numbers. Contrary to our previous assumptions, this new setting arises when the reference value is not the initial one; rather we take the value immediately preceding. Let x t and x t−1 be two values of a variable X observed in two consecutive instants t and t − 1, being t ∈ {1, 2, . . . , T}. Thus, the value of the index number in chain or chain index (cf. Forsyth and Fowler, 1981) that corresponds to an instant t, with t ∈ {1, 2, . . . , T}, is defined as follows: Again, this index number can be naturally interpreted. It is worth mentioning that these measures the variation of the characteristic under study with respect to the previous value in a fixed instant t. For instance, these index numbers reflect the percentage variation that the variable experiments between two consecutive values in time series settings.
To illustrate this definition, we take again the example considered in the previous section. For this subset of values, we obtain again the evolution of the amount of economically active people (per sex) in Spain under this new approach.   Table 3 shows the evolution in time of the number (thousands) of economically active women and men in Spain from the trimester of 2002 (see Table 1). According to the obtained results, we emphasize as relevant that the number of economically active women and men in the second trimester of 2003 increases 1.4% and 0.9%, respectively, with respect to the previous trimester.

Relationship between simple index numbers in series and in chain
This section briefly introduces some comments on the relations between simple index numbers in series and in chain. In this way, one can be obtained from another (and vice versa) without having to use the exact values of the magnitude under study. Take x t the value of the variable X in instant t, with t ∈ {1, 2, . . . , T}. Thus, a simple index in chain can be obtained from a simple index in series due to the relation For example, from simple index numbers in series for women shown in Table 2, it is possible to obtain the corresponding simple index number in chain for women also for the first trimester of 2003 (contained in Table 3). That is, Besides, simple indices in series can be equivalently obtained for each t ∈ {1, . . . , T} from indices in chain: For instance, if we consider the simple index numbers in chain shown in Table 3, it is possible to obtain the simple index number in series for the first trimester of 2003 contained in

Variation Rate
In this section, we formally introduce another measure of the evolution of a magnitude. Furthermore, we relate it to the simple index numbers previously defined.
The variation rate of the observations in the instants t and t − 1, with t ∈ {1, . . . , T}, is denoted by Rate t (X) for each t ∈ {1, . . . , T}. It can be calculated from the simple index in chain as follows: This definition can be extended to any pair of instants in {0, 1, 2, . . . , T}. Take t 1 , t 2 ∈ {0, 1, 2, . . . , T} such that t 1 < t 2 . Let x t 1 be the value of a variable measure in instant t 1 and let x t 2 be the value of a variable measure in a later instant t 2 . Formally, the variation rate of X in t 2 with respect to t 1 is . In particular, if the consecutive observations correspond to two different years, months, or trimesters the variation rate is called interanual variation rate, monthly variation rate, and quarterly variation rate, respectively. From the data shown in Table 2, the quarterly variation rates have been calculated in Table 4

Average Variation Rate
Finally, we introduce a third method to measure the evolution of a given magnitude X between the instants t and t + k, with t ∈ {0, . . . , T − k} and k > 0. If x t+k denotes the observation at instant t + k and x t the corresponding to instant t, the average variation rate of the variable X between instants t and t + k is defined as the constant rate T k that allows obtaining the observation x t+k at time t + k from observation x t at time t.
Then, it is possible to write: . .
The R Journal Vol. 13/1, June 2021 ISSN 2073-4859 Therefore, x t+k = 100+T k 100 k · x t and, as consequence, x t+k x t = 100+T k 100 k . Then, According to the results obtained, the average variation rate for women is considerably bigger than the corresponding for men in this period.

Complex index numbers
Most of the time, comparing variables marginally does not provide real information. There are many phenomena in the real world that involve several variables. Of course, simple index numbers described in the previous section could be naturally applied for each of these variables separately. However, comparing these magnitudes can be not realistic and, for this reason, complex index numbers have to be introduced. A complex index number summarizes the information of the different marginal index numbers related to the set of variables of interest.
One of the most relevant examples that illustrates the use of complex index numbers is briefly described next. The evolution of living cost in a country is a common case where it is necessary to select a set of goods or variables that give information about it. The relative importance of each of the goods considered may be taken into account. This is the case of the Consumer Price Index (CPI) in Spain. The sets of good considered for calculating it follows the International Classification of Consumption according to Purpose (COICOP) prepared by the Statistical Division of the United Nations. This classification is also used by other countries. In this way, comparisons between different geographical areas make sense.
When all variables are not of equal relevance, it is possible to add complementary information for weighting each magnitude corresponding to its degree of importance. Depending on the use of this additional information, two classes of complex index numbers are distinguished in literature: • In several practical cases, the relative weight of each involved variable has no interest. Fixed a magnitude, the class of required index numbers to be used in this setting are named non-weighted complex index numbers.
• The use of weighted index numbers allow greater importance to be attached to some items. For instance, real information other than simply the change in price over time can be used. Factors as quantity sold or quantity consumed for each item can also be considered.
In what follows, we assume that X = (X 1 , . . . , X n ) denotes the collection of n magnitudes registered for n different products. For each j = 1, . . . , n, X j = {x j0 , x j1 , . . . , x jT } denotes the observations of the magnitude X j for the T + 1 instants of time considered. Analogously to the simple case, we refer x j0 as the base period.
In practice, the available information can be summarized in a table such as Table 5. Table 5: Evolution of a set of magnitudes X from time 0 to T.
The most common complex indices jointly involve (some of) the variables in real-world situations that we enumerate below: • the price of a collection of n goods, denoted by p = (p 1 , . . . , p n ), where p j = {p j0 , p j1 , . . . , p jT } denotes the prices for T + 1 instants and for each product j = 1, . . . , n; • the amount of produced or sold products, denoted by q, where q j = {q j0 , q j1 , . . . , q jT } denotes the amounts of product for T + 1 instants and for each product j = 1, . . . , n; or • the value of n goods is given by v = (v 1 , . . . , v n ). In this case, v j = {v j0 , v j1 , . . . , v jT } denotes the values of product j, with j ∈ {1, . . . , n} for T + 1 instants.
To illustrate the usage of complex index numbers, we take the example described in    Next, we formally describe non-weighted and weighted index numbers.

Non-weighted complex index numbers
Complex index numbers analyze several magnitudes that measure the evolution of a set of goods or services. The goal here is to find a statistical measure in order to summarize the information shown, for instance, in Table 5. In particular, knowing the variation of a magnitude in time t with respect to the base period has an interest. In this sense, it is worth mentioning that non-weighted complex index numbers can be easily obtained as the arithmetic, geometric and harmonic means of the simple index numbers in series for the considered magnitudes. Anyway, their mathematical expressions are described below: • The Sauerbeck index (cf. Sauerbeck, 1895) at time t for X, S t (X), is calculated as the arithmetic mean of the simple index in series for the n involved magnitudes at t: x it x i0 · 100, for each t ∈ {0, · · · , T}.
• The Geometric mean index at time t, G t (X), is calculated as follows: x it x i0 · 100, for each t ∈ {0, · · · , T}.
Given a collection of n magnitudes, the geometric mean index at t is obtained as n th -root of the product of simple index numbers for X at time t. See more details in Jevons (1863).
• The Harmonic mean index at time t, H t (X), is determined by x i0 x it · 100, for each t ∈ {0, · · · , T}.
• The Bradstreet-Dûtot index at time t, BD t (X), is introduced in Walsh (1901). Its value is obtained as the ratio between the means of the magnitude in time t and the magnitude in the base period as follows: · 100, for each t ∈ {0, · · · , T}.
If X denotes the matrix p of prices of a set of goods or services along a period of time, these index numbers are specifically considered non-weighted complex index numbers for prices. Thus, it arises the Sauerbeck index at time t for prices, S t (p); the Geometric mean index at time t for prices, G t (p); the Harmonic mean index at time t for prices, H t (p); and the Bradstreet-Dûtot index at time t for prices, BD t (p). Their usage will be illustrated on the set prices of combustibles and other energy resources for the main home in Spain from 2005 to 2015. From the information in Table 6, the four index numbers previously described are numerically shown in Table 8, and their evolution is depicted in Figure 1.   However, the variation of a given magnitude in time t with respect to the previous period may also be of interest. Below, we alternatively enumerate the mathematical expressions of the previous indices based on index numbers in chain for the magnitudes.
• The Carli index (cf. Carli, 1804) at time t for X, C t (X), is calculated as the arithmetic mean of the simple index in chain for the n involved magnitudes at t: x it x i t−1 · 100, for each t ∈ {1, · · · , T}.
Given a collection of n magnitudes, the geometric mean index at t is obtained as n th -root of the product of simple index numbers for X in chain at time t.
• The Dûtot index at time t, D t (X), is introduced in Dûtot (1754). Its value is obtained as the ratio between the means of the magnitude in time t and the magnitude in time t − 1 as follows: Again, if X denotes the matrix of prices of a set of goods or services along a period of time (p), these index numbers are named as the Carli index at time t for prices, C t (p); the Jevons index at time t for prices, J t (p); and the Dûtot index at time t for prices, D t (p). To conclude this section, we obtain them for the set prices of combustibles and other energy resources for the main home in Spain from 2005 to 2015, detailed in Table 6. These index numbers are numerically detailed in Table 9.  Table 9: Non-weighted complex price indexes in chain for the unitary value of combustibles and energy resources for the main home in Spain from 2006 to 2015.
All of the index numbers described are easy to be computed. However, they present an important disadvantage: they do not take into account the relative importance of each product.

Weighted complex index numbers
For analyzing the evolution of a given magnitude X, it is very common to use an alternative magnitude Y through the value of Y in the reference or the actual period to weight complex index numbers. The information relative to this alternative variable can be summarized in a table such as Table 10. For instance, the use of the amount of production of different products or the use of prices may result of interest, depending on the setting under study.  Next, the main weighted complex price index numbers for a given magnitude X, taking Y as weight, are formally described: • The Laspeyres index (Laspeyres, 1871) analyzes the variations of X using Y as weight. In this sense, the weights considered for product i are x i0 · y i0 (note that both values are referred to the base period). Then, this complex index is defined as the weighted arithmetic means of the simple index numbers: · 100, for each t ∈ {0, · · · , T}.
The main disadvantage of the Laspeyres index is that it assumes that the weights do not vary in time. This hypothesis is not always realistic in some practical settings.
• The Paasche index is an alternative index to the Laspeyres index introduced in Paasche (1874), when the weighted criteria is x i0 · y it . Therefore, it can be formally written as: • The Marshall-Edgeworth index (cf. Marshall, 1887, Edgeworth, 1887 is an agregative weighted measure where weights are y i0 + y it . Therefore, it can be calculated as: · 100, for each t ∈ {0, · · · , T}.
• The Fisher index is equal to the geometric mean of the index numbers under the approaches of Laspeyres and Paasche: For instance, see more details in Fisher (1922).
Note that other values can be defined (as we will see below). The choice of using a specific index formula often relies on the availability of data. According to the previous comments, the Laspeyres index does not require information on the products of the current period. Then, the Laspeyres formula is usually preferred for the calculation of complex indices, which are typically released rapidly before information for the current period could have been collected.
In what follows, p denotes the matrix of prices of a set of goods or services along a period of time and q is the matrix of the total amounts of goods in the same period. Thus, the weighted complex price index numbers analyze the time evolution of prices by introducing the variation of the physical production or the consumption of a set of goods or services. The weights are obtained by multiplying the price of a product in an instant of time t by the consumption in the base period or the actual period. Hence, the Laspeyres price index, L t (p, q), the Paasche price index, P t (p, q), the Marshall-Edgeworth price index, E t (p, q), and the Fisher price index, F t (p, q), are naturally defined in prices settings.
Under this approach, a new complex index for v can be naturally introduced under the approach of the Bradstreet-Dûtot index. It is based on the notion of the value of good indicated by v. It can be calculated as follows: , for each t ∈ {0, · · · , T}.
It satisfies that IV t 0 (p, q) = L t (p 0 , q) · P t (p 0 , q) = L t (p, q 0 ) · P t (p, q 0 ) = F t (p 0 , q) · F t (p, q 0 ). From data contained in Tables 6 and 7, these five index numbers were determined. They are in Table 11 (from tenth to twelfth column), and they are graphically depicted in Figure 2.   Otherwise, the weighted complex production index numbers analyze the time evolution of the amount of product by introducing the variation of the price of the goods or services as weight. Their obtaining is analogous to the previous one. The weights are obtained by multiplying the amount of a product in an instant of time t by the prince in the base period or the actual period. Thus, we dealt with the Laspeyres production index, L t (q, p); the Paasche production index, P t (q, p); or the Fisher production index F t (q, p).

IndexNumber in practice
This section presents an overview of the structure of the package. IndexNumber is a tool that R users can use in order to determine several classical index numbers that describe the evolution of a single magnitude or a set of magnitudes. This software helps the user to calculate faster these statistical measures. Functions in this library automatize the required operations for the computation of index numbers. First, we will describe the real data sets included in the package. Then, the functions implemented are detailed. Of course, other libraries exist in R dealing with index numbers theory. In particular, micEconIndex (Henningsen, 2017), IndexNumR (White, 2021), and PriceIndices (Bialek, 2021) packages also allow to compute complex index numbers but only when the considered magnitudes are prices and quantities. It is worth mentioning that IndexNumber library was designed under a more general perspective by extending to any type of magnitude. Moreover, none of the above-referenced packages implement simple index numbers, and they do not offer graphical tools to facilitate the analysis of time evolution series either. Additionally, IndexNumber can be seen as an additional basic library that can also be exploited by non-experts R users. For instance, inputs of functions are numeric vectors or matrices containing the magnitude values, much more flexible than data structures that other packages consider. As for computational complexity, it is also relatively simple because, unlike IndexNumR that implements multilateral methods, the number of required elementary operations is smaller. Finally, it is convenient to note that IndexNumber package also provides four new recent real data sets.

Data sets in IndexNumber
Index numbers have been theoretically introduced in previous sections using two real data sets included in the package IndexNumber. However, we decide to include them in the package because they could be used directly by the users, avoiding search and download. Besides, two additional data sets were also included. All of them are available in the website of the Spanish Statistical Office (INE), http://www.ine.es. These four data sets are briefly described below: • Firstly, the data set ActivePeople was considered as an example in order to illustrate the simple index numbers. It contains information separately on the number (thousands) of economically active women and men in Spain from the first trimester in 2002 to the fourth one in 2019.
• Secondly, ECResources is a data set containing as variables, the unitary value (euros) and consumption (thousands of units) of several combustibles and other energy resources for the main home in Spain from 2006 to 2015. It was used in this paper for illustrating complex index numbers.
• An additional data set called Mortgages was also included in the package. In this case, the variables correspond to the number of mortgages constituted on urban properties in Spain from 2003 to 2018, distinguished between the kind of mortgages entities (banks, saving banks and other types). The corresponding mortgages amounts (thousands of euros) were also included as variables.
• Finally, the variables in the data set Food are the unitary value (euros) and consumed amount (thousands of units) of the main types of food in Spain from 2006 to 2015.
Once the package is installed and loaded, a full description of these data sets is shown through help(ActivePeople), help(ECResources), help(Mortgages), and help(Food), respectively.

Functions in IndexNumber
IndexNumber package includes several functions that enable users to determine the index numbers, simple and complex (weighted and non-weighted), described in previous sections. The functions incorporated in the package are summarized in Table 12.

Function Description
aggregated.index.number Function to obtain several non-weighted index numbers: the Sauerbeck index number (3), the Geometric index number (4), the Harmonic index number (5) the Bradstreet-Dûtot index number (6), the Carli index number (7), the Jevons index number (8)

laspeyres.index.number
Function to determine the Laspeyres index number (10).

paasche.index.number
Function to obtain the Paasche index number (11). Users can obtain different kinds of index numbers by introducing the associated parameters in the corresponding function. Table 13 describes the different options to determine those index numbers whose implementation was included in IndexNumber package. However, not all of the mentioned options are required since only some of them are specific for each particular class of index number. Thus, Table 14 summarizes the arguments associated with each function. Examples of usage for the implemented functions are described in the next section.
Argument Description x A matrix that contains the magnitude(s) under study. In each column, it contains the magnitude of a different product considered. Thus, we have nrow(x) values of a magnitude for ncol(x) products. Notice that if we intend to analyze a single magnitude, x corresponds to a vector of length equal to the total instants of time registered. y A matrix that contains that magnitude used as weight. In each column, it contains another magnitude associated to each different product along the time. Thus, we have nrow(x) values of magnitudes for the set of ncol(x) products. It is only required for obtaining those weighted index numbers mentioned in the paper. base A chain of characters that indicates the nature of the index number. If we introduce base="serie", we compare each value with respect to the initial one. In this case, it is said to be an index number in series. Otherwise, if we introduce base="chain", we obtain the index number in chain, by comparing each value with the immediately previous value. type A chain of characters to indicate the type of non-weighted index number to evaluate the evolution of a set of magnitudes (even for different products). By considering base="serie", if we introduce type="arithmetic", we obtain the Sauerbeck index number in (3). If we introduce type="geometric", we obtain the Geometric index in (4). If we choose type="harmonic", we obtain the Harmonic mean index in (5). If we write type="BDutot", we will obtain the Bradstreet-Dûtot index in (6). This argument is only required in the function aggregated.index.number. Otherwise, if we take base="chain" and type="Carli", we obtain the Carli index number in (7). If we introduce type="Jevons", we obtain the Jevons index in (8) and if we choose type="Dutot", we obtain the Dûtot index in (9). This argument is only required in the function aggregated.index.number. name A chain of characters to indicate the name of the variable under study.

opt.plot
A Boolean variable that indicates if a graphical description of the index number along the different stages is required. If it is desired, opt.plot=TRUE, else opt.plot=FALSE. opt.summary A Boolean variable that indicates if a basic statistical summary of the index number is required. If it is desired, opt.summary=TRUE, else opt.summary=FALSE.

Examples of using IndexNumber
In what follows, we describe several examples of the application of the IndexNumber package that is used to illustrate its performance. Initially, a user has to incorporate the package from the CRAN in the R Console. After its installation, the next code allows its usage:

> library("IndexNumber")
Below, it is shown how to use the different functions implemented for determining index numbers on the real data sets presented in the preliminaries section.

Simple index numbers in series in R
The example that we consider describes the obtaining of the simple index numbers in series (1) in R software on the real data partially given in Table 1. Remember that it depicts the number (thousands) of economically active women and men in Spain. As we mentioned before, this information is also included in the data set ActivePeople in IndexNumber package. The first trimester of 2002 is considered as the reference value.
Using index.numer.serie() function, we obtain the simple index number in series for the first instants of time in the example.  We include a graphical summary of the evolution of this magnitude under the fixed criteria in Figure 3, by using opt.plot=TRUE. We also summarize the most relevant information in terms of the instant in which the maximum and minimum values are reached choosing opt.summary=TRUE. Analogously, the user can obtain the corresponding results for the data associated to TotalMen. The required code in this case is the shown below: index.number.serie(ActivePeople$TotalMen[1:15],name="Man",opt.plot=TRUE,opt.summary = TRUE) Results contained in Table 2 have been obtained using both functions of IndexNumber package in R.

Simple index numbers in chain in R
Again, we take the data set ActivePeople to determine the corresponding simple index number in chain (2) for the number (thousands) of economically active women in Spain. Note that the reference value in each instant of time is the immediately previous one in the series.
Alternatively, we use index.numer.chain() function for obtaining the simple index number in chain for the first instants of time for the variable considered in the example. Also in this case, the option opt.summary=TRUE summarizes the most relevant information about the corresponding simple index number. The option opt.plot=TRUE provides a graphical representation of the evolution of the magnitude as Figure 4 depicts. Table 3 also includes the numerical analysis of the evolution of economically active men in Spain.

Non-weighted complex index numbers in R
In this section, we illustrate the usage of IndexNumber to determine non-weighted complex index numbers.
As in its theoretical description, we take the example described in Table 6 to show its performance in practice. That table describes the unitary value of prices of several energy resources for the period 2005-2015. As we have mentioned, this data set is available in library IndexNumber under the name ECResources (in particular, from the second to the sixth column).  First, we describe the R procedures that provide the variations of a magnitude in time t with respect to the base period by using non-weighted index numbers. For this purpose, we have to introduce the option base="serie". Notice that all the values included in Table 8 were obtained by using the code in R that we show in the current section.

Sauerbeck index in R
Next, we determine the Sauerbeck index (3) in R software. To this aim, we use the corresponding function aggregated.index.number() by adding, as option, type="arithmetic". Recall that it corresponds to an average by stages. In this case, we also include a graphical description of the joint evolution of prices in Figure 5 with opt.plot=TRUE, and a numerical summary of such magnitude (with opt.summary=TRUE).

Geometric mean index in R
The second approach that we consider is the one given by the Geometric mean index (4). To obtain for the case of prices of the energetic resources, we slightly change the parameters of the function aggregated.index.number(). We have to introduce the parameter type="geometric" on it.
aggregated.index.number(ECResources[,2:6],base="serie",type="geometric", name="Prices",opt.plot=FALSE,opt.summary=FALSE) The results have the same structure as the previous case that we have explained. For this reason, they have not already been included here.

Harmonic mean index in R
The third option of a non-weighted complex index is the Harmonic mean index (5). With regard to the previous cases, the main difference is the parameter type that, in this case, has to take the value "harmonic".

Bradstreet-Dûtot index in R
The Bradstreet-Dûtot index (6) is determined in R software by using aggregated.index.number() with the parameter type="BDutot". We illustrate the case of obtaining the indicated index for the prices of energetic resources. Again, the output has the same structure as the previous cases.
aggregated.index.number(ECResources[,2:6],base="serie",type="BDutot", name="Prices",opt.plot=FALSE,opt.summary=FALSE) Secondly, we describe examples of usage of IndexNumber package that involves non-weighted and weighted index numbers in chain. Specifically, we show those ones required for obtaining the results in Table 9. They involves the usage of base="chain". As before, if the option opt.plot=TRUE is considered, the output of the function also includes a graphical representation in which the joint evolution can be analyzed as Figure 6 depicts.

Paasche index in R
Analogously, the joint evolution of magnitudes under the Paasche index (11) can be also determined by using IndexNumber package in R software. More specifically, paasche.index.number() provides the mentioned weighted index number. The results of the function follows a similar structure as the function previously mentioned, and using the same graphical and numerical options.

Marshall-Edgeworth index in R
The obtaining of the Marshall-Edgeworth index number (12) is also possible in R software through the use of IndexNumber package. In particular, we have to use the function edgeworth.index.number() with the above-mentioned options for obtaining graphics and summaries.

Fisher index in R
Here, we consider the case of determining the Fisher index (13). In this case, fisher.index.number() provides a measure of the considered magnitude. Again, the options opt.plot and opt.summary allow the obtaining of additional information that may be of interest to the user.

A complex index for v in R
The complex index for v given in (14) can be easily obtained as the Bradstreet-Dûtot index for the value in each instant of time. Recall that the value is obtained as the product of the amount of good by its price in each instant of time. Thus, the function aggregated.index.number() provides the value of this new index number as follows.

Concluding Remarks
This paper discusses the implementation in R of classical index numbers used for comparing magnitudes mainly in economic contexts. Therefore, the IndexNumber package provides R users a set of functions to calculate index numbers. Concretely, this library allows the calculation of simple index numbers in series and in chain. Furthermore, complex index numbers are also implemented. In particular, the non-weigthed index numbers included are the Sauerbeck, Geometric mean, Harmonic mean, Bradstreet-Dûtot, Carli, Jevons, and Dûtot indexes; as weighted index numbers, the Laspeyres, Paasche, Marshall-Edgeworth, Fisher, and Bradstreet-Dûtot indexes were considered. Additionally, this package contains graphical tools in order to facilitate the results visualization and four real data sets that can be used as illustrative examples. Moreover, the use of this library could be easily combined with other classical packages focused on time series analysis. Future research and development plans for forthcoming versions of the package include the addition of new index numbers already considered in the literature that can be dealt with in the framework presented above. Of course, the corresponding graphical tools should also be implemented.