Learn R Programming

convergEU (version 0.7.3.2)

demea_change: Calculate changes of deviations from the mean

Description

Deviations from the mean of a collection of countries is calculated for each year. Then differences at subsequent times are calculated within each member state. Finally negative differences are added over years within member state, and similarly positive differences are added over years within member state. The output is made by datasets with intermediate calculations, and by the component statistics which is member state by statistics.

Usage

demea_change(
  myTB,
  timeName = "time",
  time_0 = NA,
  time_t = NA,
  sele_countries = NA,
  doplot = FALSE
)

Value

A list with intermediate and final statistics; list component res_graph is a ggplot2 object if the argument doplot = TRUE; to plot the object use function plot().

Arguments

myTB

a dataset time by countries

timeName

name of the variable representing time

time_0

starting time

time_t

ending time

sele_countries

selection of countries to display; NA means all countries

doplot

if a ggplot2 graphical object desired then TRUE, otherwise it is FALSE

Details

Let $$Y_{i,t,m}$$ be the indicator value i at time t for country m. Let $$D_{i,t,m} = Y_{i,t,m} - M_{i,t,m}$$ be the departure from the mean at time t. Let $$d_{i,t,m} = | D_{i,t,m}| - | D_{i,t,m}|$$ be the difference of absolute values within country m at time t. Then the overall negative and positive changes are $$Cn(i,t,m) = \sum_{t} d_{i,t,m} I_{d<=0}(d)$$ and $$Cp(i,t,m) = \sum_{t} d_{i,t,m} I_{d>0}(d)$$

References

https://www.eurofound.europa.eu/system/files/2022-04/introduction-to-the-convergeu-package-0.6.4-tutorial-v2-apr2022.pdf

Examples

Run this code


# Example 1
# A dataset in the format time by countries:
require(tibble)
testTB <- dplyr::tribble(
~time, ~countryA ,  ~countryB,  ~countryC,
2000,     0.8,   2.7,    3.9,
2001,     1.2,   3.2,    4.2,
2002,     0.9,   2.9,    4.1,
2003,     1.3,   2.9,    4.0,
2004,     1.2,   3.1,    4.1,
2005,     1.2,   3.0,    4.0
)
res <- demea_change(testTB,
             timeName="time",
             time_0 = 2000,
             time_t = 2005,
             sele_countries= NA,
             doplot=TRUE)

# \donttest{
plot(res$res$res_graph)
# }

# Example 2
# Deviations from the mean for the emp_20_64_MS Eurofound dataset
data(emp_20_64_MS)

# Calculate deviations from the mean from 2013 to 2016 for Italy, France and Germany
res1<-demea_change(emp_20_64_MS,
      timeName="time",
      time_0 = 2013,
      time_t = 2016,
      sele_countries= c('IT','FR','DE'),
      doplot=TRUE)
# \donttest{
plot(res1$res$res_graph)
# }


Run the code above in your browser using DataLab