puzztle with wrong savings rate
the savingsrate published by eurostat at
http://epp.eurostat.ec.europa.eu/tgm/table.do?tab=table&init=1&plugin=1&language=en&pcode=tsdec240
does not match with the one calculated from national accounts, with the formula provided.
EUROSTAT homepage states:
[tsdec240] - Household saving rate - %
Short Description: The gross saving rate of households is defined as gross saving (ESA95 code: B8G) divided by gross disposable income (B6G), with the latter being adjusted for the change in the net equity of households in pension funds reserves (D8net). Gross saving is the part of the gross disposable income which is not spent as final consumption expenditure. Detailed data and methodology on site http://ec.europa.eu/eurostat/sectoraccounts.
But it does not fit with my results:
setwd("C:/git/da/r/estimate_level_country")
source("c:/git/eurostat_r/eurostat_r.r")
## Attaching package: 'zoo'
## The following object(s) are masked from 'package:base':
##
## as.Date, as.Date.numeric
# savingsrate published by eurostat
library(reshape2)
savingsrate = read.eurostat("tsdec240", LANGUAGE)[time >= 2001 & time <= 2010,
list(GEO, value, time)]
official = dcast(savingsrate, GEO ~ time, sum)
print(official)
## GEO 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010
## 1 AT 12.57 12.91 13.66 14.03 14.46 15.1 16.3 16.2 15.6 13.45
## 2 BE 17.87 17.46 16.79 15.51 15.09 15.7 16.0 16.7 18.4 16.17
## 3 CH 17.14 16.07 14.82 14.42 15.42 16.6 17.7 16.9 17.1 NA
## 4 CY 11.25 9.50 12.18 10.26 10.04 9.9 6.8 4.8 11.3 11.55
## 5 CZ 10.21 10.12 9.05 7.86 9.52 10.6 10.2 9.3 10.6 10.28
## 6 DE 15.21 15.71 15.98 16.12 16.28 16.3 16.8 17.4 17.0 17.05
## 7 DK 9.56 9.51 9.79 6.37 3.71 5.4 4.2 5.0 8.1 8.02
## 8 EA17 13.98 14.48 14.37 14.40 13.97 13.6 14.0 14.2 15.2 13.88
## 9 EE 2.92 0.46 -0.52 -5.78 -4.12 -6.2 -1.7 3.4 11.5 9.63
## 10 ES 10.99 11.11 12.12 10.98 10.82 10.2 10.3 13.4 18.5 13.90
## 11 EU27 12.20 12.08 11.98 11.56 11.33 1.0 1.0 11.2 13.4 12.03
## 12 FI 8.10 7.92 8.65 9.83 8.46 6.0 7.2 8.0 11.9 11.28
## 13 FR 14.75 16.01 15.00 15.44 14.39 14.6 15.1 15.2 16.1 15.63
## 14 HU 11.86 10.29 7.90 10.11 11.30 11.9 8.4 NA 9.9 8.15
## 15 IE NA 6.96 6.69 8.65 9.63 8.1 7.5 11.0 14.7 13.36
## 16 IT 15.80 16.69 16.25 16.53 16.42 15.8 15.4 15.1 14.0 12.52
## 17 LT 4.35 4.43 2.43 0.81 0.96 0.8 -4.2 -3.0 4.3 1.19
## 18 LU NA NA NA NA NA 10.1 10.8 12.0 13.5 NA
## 19 LV -6.12 1.13 3.02 4.32 0.84 -4.1 -5.7 4.9 10.2 4.20
## 20 NL 14.69 13.90 13.10 13.05 12.27 12.1 13.0 12.1 12.9 10.91
## 21 NO 8.20 12.76 13.26 11.64 14.30 5.2 6.6 8.0 11.7 11.30
## 22 PL 14.11 10.55 10.12 8.01 8.32 8.5 7.1 2.3 9.0 8.46
## 23 PT 10.62 10.28 10.70 9.96 9.98 8.0 6.9 7.0 10.8 10.08
## 24 SE 9.86 9.68 8.58 7.59 6.93 7.8 10.1 11.7 13.9 11.42
## 25 SI 16.22 16.61 14.38 15.54 17.14 17.5 16.1 15.0 15.0 15.72
## 26 SK 8.96 8.56 6.77 5.92 6.61 5.0 7.2 6.1 7.8 11.26
## 27 UK 6.10 4.78 4.99 3.61 3.69 3.1 2.6 3.0 7.7 7.53
compare this table with the results when calculating by hand:
# test savingsrate
print("the savingsrate published by eurostat does not match with the one calculated from national accounts...where is the error?")
## [1] "the savingsrate published by eurostat does not match with the one calculated from national accounts...where is the error?"
library(data.table)
setwd("C:/git/da/r/estimate_level_country")
source("c:/git/eurostat_r/eurostat_r.r")
savings = read.eurostat("nama_inc_c", LANGUAGE)
savings = savings[UNIT == "EUR_HAB" & (INDIC_NA %in% c("P3", "P5", "B8N", "B8G",
"B6G_NAT", "D8")) & !is.na(value), list(GEO, time, value, INDIC_NA, INDIC_NA_desc)]
savings_wide = data.table(dcast(savings, GEO + time ~ INDIC_NA, value.var = "value",
aggregate.fun = sum))
setnames(savings_wide, "B8N", "netsavings")
setnames(savings_wide, "P3", "finalconsumptionexp")
setnames(savings_wide, "P5", "grosscapitalformation")
savings_wide[is.na(D8), `:=`(D8, 0)]
## GEO time B6G_NAT B8G netsavings D8 finalconsumptionexp
## 1: AT 1976 5000 1200 500 0 3800
## 2: AT 1977 5800 1300 500 0 4500
## 3: AT 1978 6300 1500 600 0 4800
## 4: AT 1979 7000 1700 800 0 5300
## 5: AT 1980 7700 1800 700 0 5800
## ---
## 1036: US 2007 NA 5000 700 0 29000
## 1037: US 2008 NA 4300 100 0 27700
## 1038: US 2009 NA 3600 -700 0 28700
## 1039: US 2010 NA 4300 -300 0 31100
## 1040: US 2011 NA 4200 -200 0 30600
## grosscapitalformation
## 1: 1400
## 2: 1700
## 3: 1600
## 4: 2000
## 5: 2100
## ---
## 1036: 6700
## 1037: 5800
## 1038: 4800
## 1039: 5500
## 1040: 5400
savings_wide[, `:=`(savingsrate, B8G/(B6G_NAT - D8))] # strangely this does not result in what the
## GEO time B6G_NAT B8G netsavings D8 finalconsumptionexp
## 1: AT 1976 5000 1200 500 0 3800
## 2: AT 1977 5800 1300 500 0 4500
## 3: AT 1978 6300 1500 600 0 4800
## 4: AT 1979 7000 1700 800 0 5300
## 5: AT 1980 7700 1800 700 0 5800
## ---
## 1036: US 2007 NA 5000 700 0 29000
## 1037: US 2008 NA 4300 100 0 27700
## 1038: US 2009 NA 3600 -700 0 28700
## 1039: US 2010 NA 4300 -300 0 31100
## 1040: US 2011 NA 4200 -200 0 30600
## grosscapitalformation savingsrate
## 1: 1400 0.2400
## 2: 1700 0.2241
## 3: 1600 0.2381
## 4: 2000 0.2429
## 5: 2100 0.2338
## ---
## 1036: 6700 NA
## 1037: 5800 NA
## 1038: 4800 NA
## 1039: 5500 NA
## 1040: 5400 NA
library(reshape2)
mytab = melt(savings_wide[, list(GEO, time, savingsrate)], id.var = c("GEO",
"time"))
mytab = data.table(mytab)
mytab = mytab[time >= 2001, ]
mytab = mytab[!is.na(value), ]
dcast(mytab, GEO ~ time, agg.fun = sum)
## GEO 2001 2002 2003 2004 2005 2006 2007 2008 2009
## 1 AT 0.2403 0.25468 0.2500 0.2544 0.2526 0.2630 0.27778 0.2798 0.24074
## 2 BE 0.2520 0.24904 0.2472 0.2545 0.2535 0.2591 0.26899 0.2500 0.20968
## 3 BG 0.1500 0.17391 0.1600 0.1429 0.1613 0.1471 0.10526 0.1556 0.19565
## 4 CH 0.3029 0.28401 0.3104 0.3113 0.3341 0.3466 0.31616 0.2689 0.30655
## 5 CY 0.1379 0.15132 0.1500 0.1446 0.1420 0.1390 0.10309 0.1127 0.08718
## 6 CZ 0.2647 0.24051 0.2278 0.2471 0.2604 0.2685 0.27350 0.2734 0.22400
## 7 DE 0.2080 0.20635 0.2000 0.2226 0.2230 0.2438 0.26599 0.2558 0.22184
## 8 DK 0.2446 0.23795 0.2382 0.2374 0.2520 0.2562 0.24939 0.2529 0.21040
## 9 EA 0.2168 0.21212 0.2068 0.2186 0.2134 0.2218 0.23105 0.2186 0.19101
## 10 EA12 0.2168 0.21212 0.2068 0.2186 0.2134 0.2218 0.23022 0.2179 0.19188
## 11 EA13 0.2133 0.21212 0.2076 0.2154 0.2143 0.2226 0.23105 0.2179 0.18889
## 12 EA15 0.2133 0.21304 0.2076 0.2154 0.2143 0.2226 0.23188 0.2186 0.18889
## 13 EA16 0.2162 0.21145 0.2060 0.2181 0.2129 0.2214 0.22993 0.2166 0.19101
## 14 EA17 0.2127 0.21145 0.2069 0.2149 0.2137 0.2231 0.23077 0.2174 0.19173
## 15 EE 0.3158 0.30952 0.2917 0.3019 0.3333 0.3286 0.32530 0.2921 0.30667
## 16 EL 0.1176 0.09722 0.1218 0.1198 0.1053 0.1093 0.09375 0.0650 0.04523
## 17 ES 0.2256 0.22989 0.2404 0.2280 0.2244 0.2248 0.21586 0.2043 0.19820
## 18 EU15 0.2034 0.20248 0.1992 0.2062 0.2038 0.2122 0.22069 0.2098 0.18081
## 19 EU25 0.2039 0.20188 0.2000 0.2035 0.2009 0.2114 0.22008 0.2093 0.18182
## 20 EU27 0.2041 0.19900 0.1961 0.2056 0.2027 0.2094 0.21862 0.2114 0.18182
## 21 FI 0.2932 0.27839 0.2491 0.2655 0.2559 0.2611 0.27300 0.2565 0.20370
## 22 FR 0.2082 0.19679 0.1922 0.1970 0.1941 0.2007 0.20608 0.1987 0.17065
## 23 HU 0.2037 0.18462 0.1594 0.1733 0.1707 0.1852 0.16854 0.1789 0.18824
## 24 IE 0.2539 0.24907 0.2749 0.2769 0.2783 0.2853 0.24931 0.1875 0.14879
## 25 IS 0.1767 0.19757 0.1515 0.1429 0.1268 0.1217 0.13877 0.0000 0.02765
## 26 IT 0.2130 0.21525 0.2052 0.2110 0.2033 0.2040 0.21318 0.1907 0.17339
## 27 LT 0.1500 0.15909 0.1458 0.1509 0.1639 0.1549 0.16667 0.1354 0.13253
## 28 LV 0.1750 0.18605 0.2000 0.2000 0.2105 0.1739 0.17978 0.1782 0.27273
## 29 NL 0.2708 0.25784 0.2560 0.2721 0.2669 0.2866 0.28857 0.2615 0.22523
## 30 NO 0.3548 0.31614 0.3048 0.3319 0.3769 0.3969 0.38742 0.4099 0.33453
## 31 PL 0.1818 0.16364 0.1800 0.1731 0.1935 0.1912 0.20513 0.1895 0.18182
## 32 PT 0.1705 0.17037 0.1667 0.1549 0.1319 0.1284 0.12903 0.1076 0.09804
## 33 RO 0.1905 0.20833 0.1923 0.2000 NA NA NA 0.1970 0.21429
## 34 SE 0.2444 0.23509 0.2483 0.2484 0.2579 0.2743 0.29640 0.2949 0.24013
## 35 SI 0.2435 0.25203 0.2481 0.2537 0.2553 0.2715 0.28313 0.2655 0.22485
## 36 SK 0.2273 0.20833 0.1923 0.1967 0.2029 0.2025 0.23711 0.2261 0.16814
## 37 UK 0.1516 0.14931 0.1516 0.1481 0.1489 0.1460 0.15882 0.1572 0.12941
## 2010 2011
## 1 0.24852 0.25779
## 2 0.23333 0.22917
## 3 0.22449 NA
## 4 0.33694 0.31967
## 5 0.11443 0.09645
## 6 0.21538 0.22794
## 7 0.23453 0.23824
## 8 0.22535 0.23678
## 9 0.19708 0.20000
## 10 0.19784 0.20070
## 11 0.19495 0.20070
## 12 0.19495 0.20141
## 13 0.19708 0.19929
## 14 0.19708 0.20000
## 15 0.33333 0.38272
## 16 0.04737 0.04494
## 17 0.18834 0.18304
## 18 0.18794 0.19031
## 19 0.18577 0.19305
## 20 0.18672 0.19355
## 21 0.20060 0.19714
## 22 0.17333 0.17915
## 23 0.21348 0.22581
## 24 0.16254 0.15636
## 25 0.05738 0.08614
## 26 0.17063 0.16863
## 27 0.17442 NA
## 28 0.21687 0.23762
## 29 0.23907 0.26536
## 30 0.34884 0.37324
## 31 0.18391 NA
## 32 0.10127 0.10897
## 33 0.20339 NA
## 34 0.26171 0.26952
## 35 0.21176 0.20690
## 36 0.20339 0.22581
## 37 0.12454 0.13309
# which the D8 correction it still does not fit:
savings_wide[, `:=`(savingsrate, B8G/(B6G_NAT))] # strangely this does not result in what the
## GEO time B6G_NAT B8G netsavings D8 finalconsumptionexp
## 1: AT 1976 5000 1200 500 0 3800
## 2: AT 1977 5800 1300 500 0 4500
## 3: AT 1978 6300 1500 600 0 4800
## 4: AT 1979 7000 1700 800 0 5300
## 5: AT 1980 7700 1800 700 0 5800
## ---
## 1036: US 2007 NA 5000 700 0 29000
## 1037: US 2008 NA 4300 100 0 27700
## 1038: US 2009 NA 3600 -700 0 28700
## 1039: US 2010 NA 4300 -300 0 31100
## 1040: US 2011 NA 4200 -200 0 30600
## grosscapitalformation savingsrate
## 1: 1400 0.2400
## 2: 1700 0.2241
## 3: 1600 0.2381
## 4: 2000 0.2429
## 5: 2100 0.2338
## ---
## 1036: 6700 NA
## 1037: 5800 NA
## 1038: 4800 NA
## 1039: 5500 NA
## 1040: 5400 NA
library(reshape2)
mytab = melt(savings_wide[, list(GEO, time, savingsrate)], id.var = c("GEO",
"time"))
mytab = data.table(mytab)
mytab = mytab[!is.na(value) & time >= 2001 & time <= 2010, ]
manual = dcast(mytab, GEO ~ time, agg.fun = sum)
print(manual)
## GEO 2001 2002 2003 2004 2005 2006 2007 2008 2009
## 1 AT 0.2403 0.25468 0.2500 0.2544 0.2526 0.2630 0.27778 0.2798 0.24074
## 2 BE 0.2520 0.24904 0.2472 0.2545 0.2535 0.2591 0.26899 0.2500 0.20968
## 3 BG 0.1500 0.17391 0.1600 0.1429 0.1613 0.1471 0.10526 0.1556 0.19565
## 4 CH 0.3036 0.28469 0.3112 0.3128 0.3356 0.3481 0.31765 0.2701 0.30851
## 5 CY 0.1379 0.15132 0.1500 0.1446 0.1420 0.1390 0.10309 0.1127 0.08718
## 6 CZ 0.2647 0.24051 0.2278 0.2442 0.2577 0.2661 0.27119 0.2714 0.22222
## 7 DE 0.2080 0.20635 0.2000 0.2226 0.2230 0.2438 0.26599 0.2558 0.22184
## 8 DK 0.2446 0.23795 0.2382 0.2374 0.2520 0.2562 0.24939 0.2529 0.21040
## 9 EA 0.2168 0.21212 0.2068 0.2186 0.2126 0.2218 0.23105 0.2186 0.19101
## 10 EA12 0.2168 0.21212 0.2068 0.2186 0.2126 0.2218 0.23022 0.2179 0.19188
## 11 EA13 0.2133 0.21212 0.2076 0.2154 0.2134 0.2226 0.23105 0.2179 0.18889
## 12 EA15 0.2133 0.21304 0.2076 0.2154 0.2134 0.2226 0.23188 0.2186 0.18889
## 13 EA16 0.2162 0.21145 0.2060 0.2181 0.2120 0.2214 0.22993 0.2166 0.19101
## 14 EA17 0.2127 0.21145 0.2069 0.2149 0.2129 0.2222 0.23077 0.2174 0.19173
## 15 EE 0.2400 0.23636 0.2258 0.2319 0.2500 0.2447 0.24107 0.2241 0.22772
## 16 EL 0.1176 0.09722 0.1218 0.1198 0.1053 0.1093 0.09375 0.0650 0.04523
## 17 ES 0.2256 0.22989 0.2404 0.2280 0.2244 0.2248 0.21586 0.2043 0.19820
## 18 EU15 0.2034 0.20165 0.1984 0.2054 0.2030 0.2115 0.21993 0.2091 0.18081
## 19 EU25 0.2029 0.20093 0.1991 0.2026 0.2000 0.2105 0.21923 0.2085 0.18107
## 20 EU27 0.2041 0.19802 0.1951 0.2047 0.2018 0.2085 0.21774 0.2105 0.18103
## 21 FI 0.2932 0.27737 0.2482 0.2646 0.2550 0.2611 0.27300 0.2565 0.20370
## 22 FR 0.2082 0.19679 0.1922 0.1970 0.1941 0.2007 0.20608 0.1987 0.17065
## 23 HU 0.2000 0.18182 0.1571 0.1711 0.1687 0.1807 0.16484 0.1753 0.18391
## 24 IE 0.2539 0.24453 0.2676 0.2707 0.2725 0.2798 0.24390 0.1837 0.14626
## 25 IS 0.1767 0.19757 0.1515 0.1429 0.1268 0.1217 0.13877 0.0000 0.02765
## 26 IT 0.2110 0.21333 0.2043 0.2101 0.2016 0.2024 0.21236 0.1899 0.17269
## 27 LT 0.1500 0.15909 0.1458 0.1509 0.1639 0.1549 0.16667 0.1354 0.13253
## 28 LV 0.1750 0.18605 0.2000 0.2000 0.2105 0.1739 0.17778 0.1765 0.26667
## 29 NL 0.2708 0.25784 0.2560 0.2721 0.2669 0.2866 0.28857 0.2615 0.22523
## 30 NO 0.3548 0.31614 0.3048 0.3319 0.3769 0.3969 0.38742 0.4099 0.33453
## 31 PL 0.1786 0.16071 0.1765 0.1698 0.1875 0.1857 0.20000 0.1895 0.17722
## 32 PT 0.1692 0.17037 0.1667 0.1549 0.1310 0.1275 0.12821 0.1076 0.09804
## 33 RO 0.1905 0.20833 0.1923 0.2000 NA NA NA 0.1970 0.21429
## 34 SE 0.2357 0.22789 0.2404 0.2406 0.2500 0.2657 0.28610 0.2846 0.23101
## 35 SI 0.2435 0.25203 0.2481 0.2519 0.2535 0.2697 0.28144 0.2640 0.22353
## 36 SK 0.2273 0.20833 0.1923 0.1967 0.2029 0.2025 0.23711 0.2261 0.16814
## 37 UK 0.1516 0.14931 0.1516 0.1481 0.1489 0.1460 0.15882 0.1572 0.12941
## 2010
## 1 0.24852
## 2 0.23333
## 3 0.22449
## 4 0.33816
## 5 0.11443
## 6 0.21374
## 7 0.23453
## 8 0.22535
## 9 0.19708
## 10 0.19784
## 11 0.19495
## 12 0.19495
## 13 0.19708
## 14 0.19708
## 15 0.24272
## 16 0.04737
## 17 0.18834
## 18 0.18794
## 19 0.18504
## 20 0.18595
## 21 0.20060
## 22 0.17333
## 23 0.20879
## 24 0.15972
## 25 0.05738
## 26 0.16996
## 27 0.17442
## 28 0.21429
## 29 0.23907
## 30 0.34884
## 31 0.17778
## 32 0.10127
## 33 0.20339
## 34 0.25333
## 35 0.21053
## 36 0.20339
## 37 0.12454
the difference between the two is
m = merge(official, manual, by = "GEO")
m[, 2:11] - m[, 12:21]
## 2001.x 2002.x 2003.x 2004.x 2005.x 2006.x 2007.x 2008.x 2009.x
## 1 12.330 12.6553 13.4100 13.7756 14.2074 14.8370 16.0222 15.920 15.359
## 2 17.618 17.2110 16.5428 15.2555 14.8365 15.4409 15.7310 16.450 18.190
## 3 16.836 15.7853 14.5088 14.1072 15.0844 16.2519 17.3824 16.630 16.791
## 4 11.112 9.3487 12.0300 10.1154 9.8980 9.7610 6.6969 4.687 11.213
## 5 9.945 9.8795 8.8222 7.6158 9.2623 10.3339 9.9288 9.029 10.378
## 6 15.002 15.5037 15.7800 15.8974 16.0570 16.0562 16.5340 17.144 16.778
## 7 9.315 9.2720 9.5518 6.1326 3.4580 5.1438 3.9506 4.747 7.890
## 8 13.767 14.2685 14.1631 14.1851 13.7571 13.3778 13.7692 13.983 15.008
## 9 2.680 0.2236 -0.7458 -6.0119 -4.3700 -6.4447 -1.9411 3.176 11.272
## 10 10.764 10.8801 11.8796 10.7520 10.5956 9.9752 10.0841 13.196 18.302
## 11 11.996 11.8820 11.7849 11.3553 11.1282 0.7915 0.7823 10.989 13.219
## 12 7.807 7.6426 8.4018 9.5654 8.2050 5.7389 6.9270 7.744 11.696
## 13 14.542 15.8132 14.8078 15.2430 14.1959 14.3993 14.8939 15.001 15.929
## 14 11.660 10.1082 7.7429 9.9389 11.1313 11.7193 8.2352 NA 9.716
## 15 NA 6.7155 6.4224 8.3793 9.3575 7.8202 7.2561 10.816 14.554
## 16 15.589 16.4767 16.0457 16.3199 16.2184 15.5976 15.1876 14.910 13.827
## 17 4.200 4.2709 2.2842 0.6591 0.7961 0.6451 -4.3667 -3.135 4.167
## 18 -6.295 0.9440 2.8200 4.1200 0.6295 -4.2739 -5.8778 4.724 9.933
## 19 14.419 13.6422 12.8440 12.7779 12.0031 11.8134 12.7114 11.839 12.675
## 20 7.845 12.4439 12.9552 11.3081 13.9231 4.8031 6.2126 7.590 11.365
## 21 13.931 10.3893 9.9435 7.8402 8.1325 8.3143 6.9000 2.111 8.823
## 22 10.451 10.1096 10.5333 9.8051 9.8490 7.8725 6.7718 6.892 10.702
## 23 9.624 9.4521 8.3396 7.3494 6.6800 7.5343 9.8139 11.415 13.669
## 24 15.977 16.3580 14.1319 15.2881 16.8865 17.2303 15.8186 14.736 14.776
## 25 8.733 8.3517 6.5777 5.7233 6.4071 4.7975 6.9629 5.874 7.632
## 26 5.948 4.6307 4.8384 3.4619 3.5411 2.9540 2.4412 2.843 7.571
## 2010.x
## 1 13.201
## 2 15.937
## 3 NA
## 4 11.436
## 5 10.066
## 6 16.815
## 7 7.795
## 8 13.683
## 9 9.387
## 10 13.712
## 11 11.844
## 12 11.079
## 13 15.457
## 14 7.941
## 15 13.200
## 16 12.350
## 17 1.016
## 18 3.986
## 19 10.671
## 20 10.951
## 21 8.282
## 22 9.979
## 23 11.167
## 24 15.509
## 25 11.057
## 26 7.405
#description proclaims - the published savingsrate is much lower...
#gross saving (ESA95 code: B8G) divided by gross disposable income (B6G), with the latter being adjusted for the
#change in the net equity of households in pension funds reserves (D8net).
#Gross saving is the part of the gross disposable income which is not spent as final consumption expenditure. Detailed data and methodology on site http://ec.europa.eu/eurostat/sectoraccounts.