qsu, shorthand for quick-summary, is an extremely fast summary command inspired by the (xt)summarize command in the STATA statistical software.

It computes a set of 7 statistics (nobs, mean, sd, min, max, skewness and kurtosis) using a numerically stable one-pass method generalized from Welford's Algorithm. Statistics can be computed weighted, by groups, and also within-and between entities (for panel data, see Details).

qsu(x, ...)

# S3 method for default
qsu(x, g = NULL, pid = NULL, w = NULL, higher = FALSE, array = TRUE, ...)

# S3 method for matrix
qsu(x, g = NULL, pid = NULL, w = NULL, higher = FALSE, array = TRUE, ...)

# S3 method for data.frame
qsu(x, by = NULL, pid = NULL, w = NULL, cols = NULL,
    higher = FALSE, array = TRUE, vlabels = FALSE, ...)

# Methods for compatibility with plm:

# S3 method for pseries
qsu(x, g = NULL, w = NULL, effect = 1L, higher = FALSE, array = TRUE, ...)

# S3 method for pdata.frame
qsu(x, by = NULL, w = NULL, cols = NULL, effect = 1L,
    higher = FALSE, array = TRUE, vlabels = FALSE, ...)


# S3 method for qsu
print(x, digits = 4, nonsci.digits = 9, na.print = "-",
      return = FALSE, print.gap = 2, ...)

Arguments

x

a vector, matrix, data frame, panel series (plm::pseries) or panel data frame (plm::pdata.frame).

g

a factor, GRP object, atomic vector (internally converted to factor) or a list of vectors / factors (internally converted to a GRP object) used to group x.

by

(p)data.frame method: Same as g, but also allows one- or two-sided formulas i.e. ~ group1 + group2 or var1 + var2 ~ group1 + group2. See Examples.

pid

same input as g/by: Specify a panel-identifier to also compute statistics on between- and within- transformed data. Data frame method also supports one- or two-sided formulas. Transformations are taken independently from grouping with g/by (grouped statistics are computed on the transformed data if g/by is also used). However, passing any LHS variables to pid will overwrite any LHS variables passed to by.

w

a vector of (non-negative) weights. Adding weights will compute the weighted mean, sd, skewness and kurtosis, and transform the data using weighted individual means if pid is used.

cols

select columns to summarize using column names, indices, a logical vector or a function (i.e. is.numeric). Two-sided formulas passed to by or pid overwrite cols.

higher

logical. Add higher moments (skewness and kurtosis).

array

logical. If computations have more than 2 dimensions (up to a maximum of 4D: variables, statistics, groups and panel-decomposition) output to array, else output (nested) list of matrices.

vlabels

logical. Use variable labels in the summary. See vlabels.

effect

plm methods: Select which panel identifier should be used for between and within transformations of the data. 1L takes the first variable in the plm::index, 2L the second etc.. Index variables can also be called by name using a character string. More than one variable can be supplied.

...

arguments to be passed to or from other methods.

digits

the number of digits to print after the comma/dot.

nonsci.digits

the number of digits to print before resorting to scientific notation (default is to print out numbers with up to 9 digits and print larger numbers scientifically).

na.print

character string to substitute for missing values.

return

logical. Don't print but instead return the formatted object.

print.gap

integer. Spacing between printed columns. Passed to print.default.

Details

The algorithm used to compute statistics is well described here [see sections Welford's online algorithm, Weighted incremental algorithm and Higher-order statistics. Skewness and kurtosis are calculated as described in Higher-order statistics and are mathematically identical to those implemented in the moments package. Just note that qsu computes the kurtosis (like momens::kurtosis), not the excess-kurtosis (= kurtosis - 3) defined in Higher-order statistics. The Weighted incremental algorithm described can easily be generalized to higher-order statistics].

Grouped computations specified with g/by are carried out extremely efficiently as in fsum (in a single pass, without splitting the data).

If pid is used, qsu performs a panel-decomposition of each variable and computes 3 sets of statistics: Statistics computed on the 'Overall' (raw) data, statistics computed on the 'Between' - transformed (pid - averaged) data, and statistics computed on the 'Within' - transformed (pid - demeaned) data.

More formally, let x (bold) be a panel vector of data for N individuals indexed by i, recorded for T periods, indexed by t. xit then denotes a single data-point belonging to individual i in time-period t (t/T must not represent time). Then xi. denotes the average of all values for individual i (averaged over t), and by extension xN. is the vector (length N) of such averages for all individuals. If no groups are supplied to g/by, the 'Between' statistics are computed on xN., the vector of individual averages. (This means that for a non-balanced panel or in the presence of missing values, the 'Overall' mean computed on x can be slightly different than the 'Between' mean computed on xN.). If groups are supplied to g/by, xN. is expanded to the vector xi. (length N x T) by replacing each value xit in x with xi., while preserving missing values in x. Grouped Between-statistics are then computed on xi., with the only difference that the number of observations ('Between-N') reported for each group is the number of distinct non-missing values of xi. in each group (not the total number of non-missing values of xi. in each group, which is already reported in 'Overall-N').

'Within' statistics are always computed on the vector x - xi. + x.., where x.. is simply the 'Overall' mean computed from x, which is added back to preserve the level of the data. The 'Within' mean computed on this data will always be identical to the 'Overall' mean. In the summary output, qsu reports not 'N', which would be identical to the 'Overall-N', but 'T', the average number of time-periods of data available for each individual obtained as 'T' = 'Overall-N / 'Between-N'. See Examples.

Apart from 'N/T' and the extrema, the standard-deviations ('SD') computed on between- and within- transformed data are extremely valuable because they indicate how much of the variation in a panel-variable is between-individuals and how much of the variation is within-individuals (over time). At the extremes, variables that have common values across individuals (such as the time-variable(s) 't' in a balanced panel), can readily be identified as individual-invariant because the 'Between-SD' on this variable is 0 and the 'Within-SD' is equal to the 'Overall-SD'. Analogous, time-invariant individual characteristics (such as the individual-id 'i') have a 0 'Within-SD' and a 'Between-SD' equal to the 'Overall-SD'.

qsu comes with it's own print method which by default writes out up to 9 digits at 4 decimal places. Larger numbers are printed in scientific format. for numbers between 7 and 9 digits, a comma ',' is placed after the 6th digit to designate the millions. Missing values are printed using '-'.

Value

A vector, matrix, array or list of matrices of summary statistics. All matrices and arrays have a class 'qsu' and a class 'table' attached.

References

Welford, B. P. (1962). Note on a method for calculating corrected sums of squares and products. Technometrics. 4 (3): 419-420. doi:10.2307/1266577.

Note

If weights w are used together with pid, transformed data is computed using weighted individual means i.e. weighted xi. and weighted x... Weighted statistics are subsequently computed on this weighted-transformed data.

See also

Examples

## World Development Panel Data # Simple Summaries ------------------------- qsu(wlddev) # Simple summary
#> N Mean SD Min Max #> country 12744 - - - - #> iso3c 12744 - - - - #> date 12744 - - - - #> year 12744 1989 17.0301 1960 2018 #> decade 12744 1988.9831 17.6311 1960 2020 #> region 12744 - - - - #> income 12744 - - - - #> OECD 12744 - - - - #> PCGDP 8995 11563.6529 18348.4052 131.6464 191586.64 #> LIFEEX 11068 63.8411 11.4497 18.907 85.4171 #> GINI 1356 39.3976 9.6764 16.2 65.8 #> ODA 8336 428,746468 819,868971 -1.08038000e+09 2.45521800e+10
qsu(wlddev, vlabels = TRUE) # Display variable labels
#> N Mean SD #> country: Country Name 12744 - - #> iso3c: Country Code 12744 - - #> date: Date Recorded (Fictitious) 12744 - - #> year: Year 12744 1989 17.0301 #> decade: Decade 12744 1988.9831 17.6311 #> region: Region 12744 - - #> income: Income Level 12744 - - #> OECD: Is OECD Member Country? 12744 - - #> PCGDP: GDP per capita (constant 2010 US$) 8995 11563.6529 18348.4052 #> LIFEEX: Life expectancy at birth, total (years) 11068 63.8411 11.4497 #> GINI: GINI index (World Bank estimate) 1356 39.3976 9.6764 #> ODA: Net ODA received (constant 2015 US$) 8336 428,746468 819,868971 #> Min #> country: Country Name - #> iso3c: Country Code - #> date: Date Recorded (Fictitious) - #> year: Year 1960 #> decade: Decade 1960 #> region: Region - #> income: Income Level - #> OECD: Is OECD Member Country? - #> PCGDP: GDP per capita (constant 2010 US$) 131.6464 #> LIFEEX: Life expectancy at birth, total (years) 18.907 #> GINI: GINI index (World Bank estimate) 16.2 #> ODA: Net ODA received (constant 2015 US$) -1.08038000e+09 #> Max #> country: Country Name - #> iso3c: Country Code - #> date: Date Recorded (Fictitious) - #> year: Year 2018 #> decade: Decade 2020 #> region: Region - #> income: Income Level - #> OECD: Is OECD Member Country? - #> PCGDP: GDP per capita (constant 2010 US$) 191586.64 #> LIFEEX: Life expectancy at birth, total (years) 85.4171 #> GINI: GINI index (World Bank estimate) 65.8 #> ODA: Net ODA received (constant 2015 US$) 2.45521800e+10
qsu(wlddev, higher = TRUE) # Add skewness and kurtosis
#> N Mean SD Min Max #> country 12744 - - - - #> iso3c 12744 - - - - #> date 12744 - - - - #> year 12744 1989 17.0301 1960 2018 #> decade 12744 1988.9831 17.6311 1960 2020 #> region 12744 - - - - #> income 12744 - - - - #> OECD 12744 - - - - #> PCGDP 8995 11563.6529 18348.4052 131.6464 191586.64 #> LIFEEX 11068 63.8411 11.4497 18.907 85.4171 #> GINI 1356 39.3976 9.6764 16.2 65.8 #> ODA 8336 428,746468 819,868971 -1.08038000e+09 2.45521800e+10 #> Skew Kurt #> country - - #> iso3c - - #> date - - #> year -0 1.7993 #> decade 0.0062 1.9463 #> region - - #> income - - #> OECD - - #> PCGDP 3.1121 16.9585 #> LIFEEX -0.6692 2.6458 #> GINI 0.4613 2.2932 #> ODA 7.1918 122.9003
# Grouped Summaries ------------------------ qsu(wlddev, ~ region, vlabels = TRUE) # Statistics by World Bank Region
#> , , country: Country Name #> #> N Mean SD Min Max #> East Asia & Pacific 2124 - - - - #> Europe & Central Asia 3422 - - - - #> Latin America & Caribbean 2478 - - - - #> Middle East & North Africa 1239 - - - - #> North America 177 - - - - #> South Asia 472 - - - - #> Sub-Saharan Africa 2832 - - - - #> #> , , iso3c: Country Code #> #> N Mean SD Min Max #> East Asia & Pacific 2124 - - - - #> Europe & Central Asia 3422 - - - - #> Latin America & Caribbean 2478 - - - - #> Middle East & North Africa 1239 - - - - #> North America 177 - - - - #> South Asia 472 - - - - #> Sub-Saharan Africa 2832 - - - - #> #> , , date: Date Recorded (Fictitious) #> #> N Mean SD Min Max #> East Asia & Pacific 2124 - - - - #> Europe & Central Asia 3422 - - - - #> Latin America & Caribbean 2478 - - - - #> Middle East & North Africa 1239 - - - - #> North America 177 - - - - #> South Asia 472 - - - - #> Sub-Saharan Africa 2832 - - - - #> #> , , year: Year #> #> N Mean SD Min Max #> East Asia & Pacific 2124 1989 17.0334 1960 2018 #> Europe & Central Asia 3422 1989 17.0319 1960 2018 #> Latin America & Caribbean 2478 1989 17.0328 1960 2018 #> Middle East & North Africa 1239 1989 17.0363 1960 2018 #> North America 177 1989 17.0777 1960 2018 #> South Asia 472 1989 17.0475 1960 2018 #> Sub-Saharan Africa 2832 1989 17.0324 1960 2018 #> #> , , decade: Decade #> #> N Mean SD Min Max #> East Asia & Pacific 2124 1988.9831 17.6345 1960 2020 #> Europe & Central Asia 3422 1988.9831 17.633 1960 2020 #> Latin America & Caribbean 2478 1988.9831 17.6339 1960 2020 #> Middle East & North Africa 1239 1988.9831 17.6375 1960 2020 #> North America 177 1988.9831 17.6804 1960 2020 #> South Asia 472 1988.9831 17.6491 1960 2020 #> Sub-Saharan Africa 2832 1988.9831 17.6335 1960 2020 #> #> , , income: Income Level #> #> N Mean SD Min Max #> East Asia & Pacific 2124 - - - - #> Europe & Central Asia 3422 - - - - #> Latin America & Caribbean 2478 - - - - #> Middle East & North Africa 1239 - - - - #> North America 177 - - - - #> South Asia 472 - - - - #> Sub-Saharan Africa 2832 - - - - #> #> , , OECD: Is OECD Member Country? #> #> N Mean SD Min Max #> East Asia & Pacific 2124 - - - - #> Europe & Central Asia 3422 - - - - #> Latin America & Caribbean 2478 - - - - #> Middle East & North Africa 1239 - - - - #> North America 177 - - - - #> South Asia 472 - - - - #> Sub-Saharan Africa 2832 - - - - #> #> , , PCGDP: GDP per capita (constant 2010 US$) #> #> N Mean SD Min #> East Asia & Pacific 1391 10337.0463 14094.8338 131.9634 #> Europe & Central Asia 2084 25664.8064 26181.671 367.0493 #> Latin America & Caribbean 1896 6976.0649 6705.5377 662.2795 #> Middle East & North Africa 805 13760.2761 18374.2208 570.5574 #> North America 170 43650.5193 18345.0419 17550.5732 #> South Asia 366 1178.3447 1581.2678 267.0736 #> Sub-Saharan Africa 2283 1750.0069 2553.7889 131.6464 #> Max #> East Asia & Pacific 72183.3033 #> Europe & Central Asia 191586.64 #> Latin America & Caribbean 42491.454 #> Middle East & North Africa 113682.038 #> North America 94903.1915 #> South Asia 8971.1285 #> Sub-Saharan Africa 20333.9404 #> #> , , LIFEEX: Life expectancy at birth, total (years) #> #> N Mean SD Min Max #> East Asia & Pacific 1717 65.6493 10.1221 18.907 84.278 #> Europe & Central Asia 2886 71.9323 5.4596 45.369 85.4171 #> Latin America & Caribbean 1995 67.7473 7.2844 42.113 82.1902 #> Middle East & North Africa 1163 65.7501 9.5211 34.361 82.4073 #> North America 135 75.9931 3.4825 68.8978 82.3005 #> South Asia 456 56.7471 11.1073 32.292 77.339 #> Sub-Saharan Africa 2716 51.0007 8.5873 27.61 74.3949 #> #> , , GINI: GINI index (World Bank estimate) #> #> N Mean SD Min Max #> East Asia & Pacific 92 38.5065 5.3684 27.8 55.4 #> Europe & Central Asia 588 31.902 4.7383 16.2 48.4 #> Latin America & Caribbean 363 50.5664 5.3238 34.4 63.3 #> Middle East & North Africa 76 36.1947 5.1244 27.6 47.4 #> North America 22 36.1636 3.9282 31 41.1 #> South Asia 39 34.1641 4.3411 25.9 43.8 #> Sub-Saharan Africa 176 44.8165 8.3376 28.9 65.8 #> #> , , ODA: Net ODA received (constant 2015 US$) #> #> N Mean SD #> East Asia & Pacific 1491 346,977686 615,361973 #> Europe & Central Asia 751 394,089867 566,834650 #> Latin America & Caribbean 1918 173,728368 259,343122 #> Middle East & North Africa 1079 663,574245 1.40635884e+09 #> North America 39 423846.154 9,678883.86 #> South Asia 450 1.25150376e+09 1.56736667e+09 #> Sub-Saharan Africa 2608 440,308474 596,033604 #> Min Max #> East Asia & Pacific -1.08038000e+09 3.92003000e+09 #> Europe & Central Asia -343,480000 4.64666000e+09 #> Latin America & Caribbean -512,730000 2.95163000e+09 #> Middle East & North Africa -169,710000 2.45521800e+10 #> North America -14,520000 55,820000 #> South Asia 80000 8.53900000e+09 #> Sub-Saharan Africa -16,780000 1.12780600e+10 #>
qsu(wlddev, PCGDP + LIFEEX ~ income) # Summarize GDP per Capita and Life Expectancy by
#> , , PCGDP #> #> N Mean SD Min Max #> High income 3038 28974.7264 22910.7155 944.2924 191586.64 #> Low income 1405 596.7977 308.2129 131.6464 1506.3002 #> Lower middle income 2120 1583.371 890.7439 150.2214 4662.8838 #> Upper middle income 2432 4849.7499 2959.2271 131.9634 20333.9404 #> #> , , LIFEEX #> #> N Mean SD Min Max #> High income 3682 73.2157 5.5133 42.672 85.4171 #> Low income 1881 49.6189 8.8925 27.61 74.43 #> Lower middle income 2628 58.555 9.3854 18.907 76.253 #> Upper middle income 2877 65.9705 7.6509 36.74 79.831 #>
stats <- qsu(wlddev, ~ region + income, # World Bank Income Level cols = 9:10, higher = TRUE) # Same variables, by both region and income aperm(stats) # A different perspective on the same stats
#> , , East Asia & Pacific.High income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 467 26042.2796 14593.6195 944.2924 72183.3033 0.2886 2.5833 #> LIFEEX 631 73.228 6.3633 53.0018 84.278 -0.5398 2.8883 #> #> , , East Asia & Pacific.Lower middle income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 527 1621.1783 908.9503 150.2214 4498.6561 0.4401 2.8782 #> LIFEEX 741 58.838 9.384 18.907 76.052 -1.0707 4.517 #> #> , , East Asia & Pacific.Upper middle income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 397 3432.559 2418.0954 131.9634 11528.2969 1.4942 5.0692 #> LIFEEX 345 66.4175 6.4518 43.725 76.252 -0.9503 3.7035 #> #> , , Europe & Central Asia.High income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 1433 35516.4191 26131.2384 4506.0504 191586.64 2.1574 9.2428 #> LIFEEX 1748 74.4894 4.212 62.8089 85.4171 0.0397 2.2671 #> #> , , Europe & Central Asia.Low income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 33 788.0229 338.9391 367.0493 1459.0104 0.5918 2.1621 #> LIFEEX 57 63.6855 3.9541 56.152 70.879 0.1809 2.3413 #> #> , , Europe & Central Asia.Lower middle income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 188 2056.5151 1148.7397 535.044 4662.8838 0.5182 2.0046 #> LIFEEX 321 67.3641 3.3672 56.1281 73.261 -0.8949 3.6862 #> #> , , Europe & Central Asia.Upper middle income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 430 5064.6473 2650.7359 698.5643 14936.4018 0.9523 3.7693 #> LIFEEX 760 68.5988 5.1392 45.369 78.345 -1.1915 5.3463 #> #> , , Latin America & Caribbean .High income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 579 13198.647 8495.8391 2139.5473 42491.454 1.0555 3.2954 #> LIFEEX 679 71.5427 4.5417 57.285 82.1902 -0.41 2.633 #> #> , , Latin America & Caribbean .Low income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 58 884.5499 158.3409 662.2795 1245.7079 0.2953 1.9501 #> LIFEEX 57 53.4959 6.0085 42.113 63.055 -0.1348 1.9273 #> #> , , Latin America & Caribbean .Lower middle income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 227 1853.4711 573.985 995.479 3463.5436 0.778 2.7763 #> LIFEEX 228 60.6888 8.9867 42.138 75.149 -0.1644 1.8525 #> #> , , Latin America & Caribbean .Upper middle income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 1032 4954.0316 2898.9104 1072.0096 15557.332 1.3419 4.6926 #> LIFEEX 1031 67.5965 6.1318 46.702 79.831 -0.6464 3.3037 #> #> , , Middle East & North Africa.High income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 331 28654.266 20919.8468 2350.4623 113682.038 1.6976 5.7821 #> LIFEEX 452 70.1049 8.0708 42.672 82.4073 -1.2998 4.3623 #> #> , , Middle East & North Africa.Low income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 28 1084.5999 140.4327 754.0579 1309.232 -1.0608 4.1727 #> LIFEEX 114 59.8538 10.8992 34.361 74.43 -0.7235 2.7446 #> #> , , Middle East & North Africa.Lower middle income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 188 1999.6767 878.5357 570.5574 4303.9636 0.6303 3.1072 #> LIFEEX 255 61.7893 9.1703 42.021 75.821 -0.2014 1.8081 #> #> , , Middle East & North Africa.Upper middle income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 258 4597.4892 2236.6643 1427.9212 12120.5622 1.1456 3.984 #> LIFEEX 342 64.9134 8.459 42.609 79.584 -0.6719 2.5216 #> #> , , North America.High income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 170 43650.5193 18345.0419 17550.5732 94903.1915 0.9047 3.3501 #> LIFEEX 135 75.9931 3.4825 68.8978 82.3005 -0.144 1.9842 #> #> , , South Asia.Low income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 74 415.7625 132.7529 267.0736 690.075 0.6292 2.1476 #> LIFEEX 114 50.43 10.9819 32.292 69.887 0.0899 1.7696 #> #> , , South Asia.Lower middle income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 269 921.2851 698.8565 304.2319 3768.5168 1.9652 6.9579 #> LIFEEX 285 58.7775 9.7167 34.526 75.088 -0.4424 2.3804 #> #> , , South Asia.Upper middle income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 23 6638.3501 1243.055 4600.6696 8559.3509 0.1317 1.9273 #> LIFEEX 57 59.2287 13.1054 37.397 77.042 -0.1248 1.6532 #> #> , , Sub-Saharan Africa .High income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 58 7263.4247 3246.7659 2616.8743 13598.3363 0.3107 2.0355 #> LIFEEX 37 71.403 1.8648 67.9707 74.2951 -0.2738 1.9513 #> #> , , Sub-Saharan Africa .Low income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 1212 577.6047 302.6247 131.6464 1506.3002 1.3404 4.1921 #> LIFEEX 1539 48.1361 7.6996 27.61 67.146 0.0454 2.5365 #> #> , , Sub-Saharan Africa .Lower middle income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 721 1485.7945 775.9211 254.5931 3980.7744 1.2385 3.9967 #> LIFEEX 798 53.0262 7.3473 33.251 72.798 0.0984 2.9692 #> #> , , Sub-Saharan Africa .Upper middle income #> #> N Mean SD Min Max Skew Kurt #> PCGDP 292 6173.5362 3951.8202 390.8297 20333.9404 1.0227 4.3495 #> LIFEEX 342 56.958 8.1124 36.74 74.3949 -0.2548 3.0184 #>
# Panel Data Summaries --------------------- qsu(wlddev, pid = ~ iso3c, vlabels = TRUE) # Adding between and within countries statistics
#> , , country: Country Name #> #> N/T Mean SD Min Max #> Overall 12744 - - - - #> Between 216 - - - - #> Within 59 - - - - #> #> , , date: Date Recorded (Fictitious) #> #> N/T Mean SD Min Max #> Overall 12744 - - - - #> Between 216 - - - - #> Within 59 - - - - #> #> , , year: Year #> #> N/T Mean SD Min Max #> Overall 12744 1989 17.0301 1960 2018 #> Between 216 1989 0 1989 1989 #> Within 59 1989 17.0301 1960 2018 #> #> , , decade: Decade #> #> N/T Mean SD Min Max #> Overall 12744 1988.9831 17.6311 1960 2020 #> Between 216 1988.9831 0 1988.9831 1988.9831 #> Within 59 1988.9831 17.6311 1960 2020 #> #> , , region: Region #> #> N/T Mean SD Min Max #> Overall 12744 - - - - #> Between 216 - - - - #> Within 59 - - - - #> #> , , income: Income Level #> #> N/T Mean SD Min Max #> Overall 12744 - - - - #> Between 216 - - - - #> Within 59 - - - - #> #> , , OECD: Is OECD Member Country? #> #> N/T Mean SD Min Max #> Overall 12744 - - - - #> Between 216 - - - - #> Within 59 - - - - #> #> , , PCGDP: GDP per capita (constant 2010 US$) #> #> N/T Mean SD Min Max #> Overall 8995 11563.6529 18348.4052 131.6464 191586.64 #> Between 203 12488.8577 19628.3668 255.3999 141165.083 #> Within 44.3103 11563.6529 6334.9523 -30529.0928 75348.067 #> #> , , LIFEEX: Life expectancy at birth, total (years) #> #> N/T Mean SD Min Max #> Overall 11068 63.8411 11.4497 18.907 85.4171 #> Between 207 64.5285 10.0235 39.349 85.4171 #> Within 53.4686 63.8411 5.8292 33.4671 83.8595 #> #> , , GINI: GINI index (World Bank estimate) #> #> N/T Mean SD Min Max #> Overall 1356 39.3976 9.6764 16.2 65.8 #> Between 161 39.5799 8.3679 23.3667 61.7143 #> Within 8.4224 39.3976 3.0406 23.9576 54.7976 #> #> , , ODA: Net ODA received (constant 2015 US$) #> #> N/T Mean SD Min Max #> Overall 8336 428,746468 819,868971 -1.08038000e+09 2.45521800e+10 #> Between 178 418,026522 548,293709 423846.154 3.53258914e+09 #> Within 46.8315 428,746468 607,024040 -2.47969577e+09 2.35093916e+10 #>
# -> They show amongst other things that year and decade are individual-invariant, # that we have GINI-data on only 161 countries, with only 8.42 observations per country on average, # and that GDP, LIFEEX and GINI vary more between-countries, but ODA received varies more within # countries over time. # Using plm: pwlddev <- plm::pdata.frame(wlddev, # Creating a Panel Data Frame frame from this data index = c("iso3c","year")) qsu(pwlddev) # Summary for pdata.frame -> qsu(wlddev, pid = ~ iso3c)
#> , , country #> #> N/T Mean SD Min Max #> Overall 12744 - - - - #> Between 216 - - - - #> Within 59 - - - - #> #> , , iso3c #> #> N/T Mean SD Min Max #> Overall 12744 - - - - #> Between 216 - - - - #> Within 59 - - - - #> #> , , date #> #> N/T Mean SD Min Max #> Overall 12744 - - - - #> Between 216 - - - - #> Within 59 - - - - #> #> , , year #> #> N/T Mean SD Min Max #> Overall 12744 - - - - #> Between 216 - - - - #> Within 59 - - - - #> #> , , decade #> #> N/T Mean SD Min Max #> Overall 12744 1988.9831 17.6311 1960 2020 #> Between 216 1988.9831 0 1988.9831 1988.9831 #> Within 59 1988.9831 17.6311 1960 2020 #> #> , , region #> #> N/T Mean SD Min Max #> Overall 12744 - - - - #> Between 216 - - - - #> Within 59 - - - - #> #> , , income #> #> N/T Mean SD Min Max #> Overall 12744 - - - - #> Between 216 - - - - #> Within 59 - - - - #> #> , , OECD #> #> N/T Mean SD Min Max #> Overall 12744 - - - - #> Between 216 - - - - #> Within 59 - - - - #> #> , , PCGDP #> #> N/T Mean SD Min Max #> Overall 8995 11563.6529 18348.4052 131.6464 191586.64 #> Between 203 12488.8577 19628.3668 255.3999 141165.083 #> Within 44.3103 11563.6529 6334.9523 -30529.0928 75348.067 #> #> , , LIFEEX #> #> N/T Mean SD Min Max #> Overall 11068 63.8411 11.4497 18.907 85.4171 #> Between 207 64.5285 10.0235 39.349 85.4171 #> Within 53.4686 63.8411 5.8292 33.4671 83.8595 #> #> , , GINI #> #> N/T Mean SD Min Max #> Overall 1356 39.3976 9.6764 16.2 65.8 #> Between 161 39.5799 8.3679 23.3667 61.7143 #> Within 8.4224 39.3976 3.0406 23.9576 54.7976 #> #> , , ODA #> #> N/T Mean SD Min Max #> Overall 8336 428,746468 819,868971 -1.08038000e+09 2.45521800e+10 #> Between 178 418,026522 548,293709 423846.154 3.53258914e+09 #> Within 46.8315 428,746468 607,024040 -2.47969577e+09 2.35093916e+10 #>
qsu(pwlddev$PCGDP) # Default summary for Panel Series (class pseries)
#> N/T Mean SD Min Max #> Overall 8995 11563.6529 18348.4052 131.6464 191586.64 #> Between 203 12488.8577 19628.3668 255.3999 141165.083 #> Within 44.3103 11563.6529 6334.9523 -30529.0928 75348.067
qsu(G(pwlddev$PCGDP)) # Summarizing GDP growth, see also ?G
#> N/T Mean SD Min Max #> Overall 8792 2.1275 6.1625 -64.9963 140.5011 #> Between 200 2.2322 1.9197 -1.9044 13.0459 #> Within 43.96 2.1275 5.9311 -67.432 132.1934
# Grouped Panel Data Summaries ------------- qsu(wlddev, ~ region, ~ iso3c, cols = 9:12) # Panel-Statistics by region
#> , , Overall, PCGDP #> #> N/T Mean SD Min #> East Asia & Pacific 1391 10337.0463 14094.8338 131.9634 #> Europe & Central Asia 2084 25664.8064 26181.671 367.0493 #> Latin America & Caribbean 1896 6976.0649 6705.5377 662.2795 #> Middle East & North Africa 805 13760.2761 18374.2208 570.5574 #> North America 170 43650.5193 18345.0419 17550.5732 #> South Asia 366 1178.3447 1581.2678 267.0736 #> Sub-Saharan Africa 2283 1750.0069 2553.7889 131.6464 #> Max #> East Asia & Pacific 72183.3033 #> Europe & Central Asia 191586.64 #> Latin America & Caribbean 42491.454 #> Middle East & North Africa 113682.038 #> North America 94903.1915 #> South Asia 8971.1285 #> Sub-Saharan Africa 20333.9404 #> #> , , Between, PCGDP #> #> N/T Mean SD Min Max #> East Asia & Pacific 34 10337.0463 12576.62 410.2004 40046.4089 #> Europe & Central Asia 56 25664.8064 24008.1006 788.0229 141165.083 #> Latin America & Caribbean 36 6976.0649 6294.8452 884.5499 36049.6948 #> Middle East & North Africa 20 13760.2761 17291.0461 1084.5999 65963.2711 #> North America 3 43650.5193 12062.9919 35346.4194 61278.2411 #> South Asia 8 1178.3447 1470.7041 397.4451 6638.3501 #> Sub-Saharan Africa 46 1750.0069 2199.9901 255.3999 9916.656 #> #> , , Within, PCGDP #> #> N/T Mean SD Min #> East Asia & Pacific 40.9118 11563.6529 6363.4087 -11892.0702 #> Europe & Central Asia 37.2143 11563.6529 10444.6637 -30529.0928 #> Latin America & Caribbean 52.6667 11563.6529 2310.6622 -519.1743 #> Middle East & North Africa 40.25 11563.6529 6215.4419 -18492.1455 #> North America 56.6667 11563.6529 13821.1717 -21876.1952 #> South Asia 45.75 11563.6529 580.8934 9525.9724 #> Sub-Saharan Africa 49.6304 11563.6529 1296.8738 4528.6387 #> Max #> East Asia & Pacific 50475.9873 #> Europe & Central Asia 75348.067 #> Latin America & Caribbean 21734.0427 #> Middle East & North Africa 60152 #> North America 45188.6033 #> South Asia 13896.4313 #> Sub-Saharan Africa 24375.5944 #> #> , , Overall, LIFEEX #> #> N/T Mean SD Min Max #> East Asia & Pacific 1717 65.6493 10.1221 18.907 84.278 #> Europe & Central Asia 2886 71.9323 5.4596 45.369 85.4171 #> Latin America & Caribbean 1995 67.7473 7.2844 42.113 82.1902 #> Middle East & North Africa 1163 65.7501 9.5211 34.361 82.4073 #> North America 135 75.9931 3.4825 68.8978 82.3005 #> South Asia 456 56.7471 11.1073 32.292 77.339 #> Sub-Saharan Africa 2716 51.0007 8.5873 27.61 74.3949 #> #> , , Between, LIFEEX #> #> N/T Mean SD Min Max #> East Asia & Pacific 32 65.6493 7.7148 48.8626 77.5681 #> Europe & Central Asia 55 71.9323 4.2526 61.9424 85.4171 #> Latin America & Caribbean 40 67.7473 4.9716 53.4959 82.1902 #> Middle East & North Africa 21 65.7501 5.8655 53.0192 76.401 #> North America 3 75.9931 1.2682 74.6066 77.9553 #> South Asia 8 56.7471 5.8027 47.8822 68.6733 #> Sub-Saharan Africa 48 51.0007 5.9389 39.349 71.403 #> #> , , Within, LIFEEX #> #> N/T Mean SD Min Max #> East Asia & Pacific 53.6562 63.8411 6.5528 33.4671 83.8595 #> Europe & Central Asia 52.4727 63.8411 3.4239 46.6863 77.0723 #> Latin America & Caribbean 49.875 63.8411 5.3241 47.1311 78.2611 #> Middle East & North Africa 55.381 63.8411 7.4998 41.8394 78.4739 #> North America 45 63.8411 3.2433 54.7836 69.485 #> South Asia 57 63.8411 9.4711 42.0094 82.0276 #> Sub-Saharan Africa 56.5833 63.8411 6.2025 43.7422 83.2612 #> #> , , Overall, GINI #> #> N/T Mean SD Min Max #> East Asia & Pacific 92 38.5065 5.3684 27.8 55.4 #> Europe & Central Asia 588 31.902 4.7383 16.2 48.4 #> Latin America & Caribbean 363 50.5664 5.3238 34.4 63.3 #> Middle East & North Africa 76 36.1947 5.1244 27.6 47.4 #> North America 22 36.1636 3.9282 31 41.1 #> South Asia 39 34.1641 4.3411 25.9 43.8 #> Sub-Saharan Africa 176 44.8165 8.3376 28.9 65.8 #> #> , , Between, GINI #> #> N/T Mean SD Min Max #> East Asia & Pacific 21 38.5065 4.8352 30.8 48.65 #> Europe & Central Asia 47 31.902 4.054 23.3667 40.8 #> Latin America & Caribbean 25 50.5664 4.0186 41.1 57.7333 #> Middle East & North Africa 14 36.1947 4.6346 29.05 43.0667 #> North America 2 36.1636 3.5731 32.6727 39.6545 #> South Asia 7 34.1641 3.4562 30.3556 39.85 #> Sub-Saharan Africa 45 44.8165 7.0733 31.45 61.7143 #> #> , , Within, GINI #> #> N/T Mean SD Min Max #> East Asia & Pacific 4.381 39.3976 2.3325 32.6476 46.1476 #> Europe & Central Asia 12.5106 39.3976 2.4529 28.636 54.4976 #> Latin America & Caribbean 14.52 39.3976 3.4921 26.3076 48.7365 #> Middle East & North Africa 5.4286 39.3976 2.1863 32.6309 46.6404 #> North America 11 39.3976 1.6323 34.343 40.843 #> South Asia 5.5714 39.3976 2.6268 34.6726 45.9309 #> Sub-Saharan Africa 3.9111 39.3976 4.4142 23.9576 54.7976 #> #> , , Overall, ODA #> #> N/T Mean SD #> East Asia & Pacific 1491 346,977686 615,361973 #> Europe & Central Asia 751 394,089867 566,834650 #> Latin America & Caribbean 1918 173,728368 259,343122 #> Middle East & North Africa 1079 663,574245 1.40635884e+09 #> North America 39 423846.154 9,678883.86 #> South Asia 450 1.25150376e+09 1.56736667e+09 #> Sub-Saharan Africa 2608 440,308474 596,033604 #> Min Max #> East Asia & Pacific -1.08038000e+09 3.92003000e+09 #> Europe & Central Asia -343,480000 4.64666000e+09 #> Latin America & Caribbean -512,730000 2.95163000e+09 #> Middle East & North Africa -169,710000 2.45521800e+10 #> North America -14,520000 55,820000 #> South Asia 80000 8.53900000e+09 #> Sub-Saharan Africa -16,780000 1.12780600e+10 #> #> , , Between, ODA #> #> N/T Mean SD Min #> East Asia & Pacific 31 346,977686 460,186340 1,550512.82 #> Europe & Central Asia 32 394,089867 446,099453 12,115777.8 #> Latin America & Caribbean 37 173,728368 169,248215 2,089677.42 #> Middle East & North Africa 21 663,574245 725,711345 2,946923.08 #> North America 1 423846.154 0 423846.154 #> South Asia 8 1.25150376e+09 1.15946284e+09 25,663448.3 #> Sub-Saharan Africa 48 440,308474 357,457530 27,340689.7 #> Max #> East Asia & Pacific 1.64164241e+09 #> Europe & Central Asia 2.16970133e+09 #> Latin America & Caribbean 560,007241 #> Middle East & North Africa 2.73873224e+09 #> North America 423846.154 #> South Asia 3.53258914e+09 #> Sub-Saharan Africa 1.41753857e+09 #> #> , , Within, ODA #> #> N/T Mean SD #> East Asia & Pacific 48.0968 428,746468 408,532605 #> Europe & Central Asia 23.4688 428,746468 349,709591 #> Latin America & Caribbean 51.8378 428,746468 196,504190 #> Middle East & North Africa 51.381 428,746468 1.20465275e+09 #> North America 39 428,746468 9,678883.86 #> South Asia 56.25 428,746468 1.05464885e+09 #> Sub-Saharan Africa 54.3333 428,746468 476,948814 #> Min Max #> East Asia & Pacific -2.18778866e+09 3.57867647e+09 #> Europe & Central Asia -1.14106420e+09 3.01475819e+09 #> Latin America & Caribbean -579,470773 2.97543078e+09 #> Middle East & North Africa -2.47969577e+09 2.35093916e+10 #> North America 413,802622 484,142622 #> South Asia -2.37972267e+09 5.51177302e+09 #> Sub-Saharan Africa -825,184566 1.07855444e+10 #>
psr <- qsu(pwlddev, ~ region, cols = 9:12) # Same on plm pdata.frame psr # -> Gives a 4D array
#> , , Overall, PCGDP #> #> N/T Mean SD Min #> East Asia & Pacific 1391 10337.0463 14094.8338 131.9634 #> Europe & Central Asia 2084 25664.8064 26181.671 367.0493 #> Latin America & Caribbean 1896 6976.0649 6705.5377 662.2795 #> Middle East & North Africa 805 13760.2761 18374.2208 570.5574 #> North America 170 43650.5193 18345.0419 17550.5732 #> South Asia 366 1178.3447 1581.2678 267.0736 #> Sub-Saharan Africa 2283 1750.0069 2553.7889 131.6464 #> Max #> East Asia & Pacific 72183.3033 #> Europe & Central Asia 191586.64 #> Latin America & Caribbean 42491.454 #> Middle East & North Africa 113682.038 #> North America 94903.1915 #> South Asia 8971.1285 #> Sub-Saharan Africa 20333.9404 #> #> , , Between, PCGDP #> #> N/T Mean SD Min Max #> East Asia & Pacific 34 10337.0463 12576.62 410.2004 40046.4089 #> Europe & Central Asia 56 25664.8064 24008.1006 788.0229 141165.083 #> Latin America & Caribbean 36 6976.0649 6294.8452 884.5499 36049.6948 #> Middle East & North Africa 20 13760.2761 17291.0461 1084.5999 65963.2711 #> North America 3 43650.5193 12062.9919 35346.4194 61278.2411 #> South Asia 8 1178.3447 1470.7041 397.4451 6638.3501 #> Sub-Saharan Africa 46 1750.0069 2199.9901 255.3999 9916.656 #> #> , , Within, PCGDP #> #> N/T Mean SD Min #> East Asia & Pacific 40.9118 11563.6529 6363.4087 -11892.0702 #> Europe & Central Asia 37.2143 11563.6529 10444.6637 -30529.0928 #> Latin America & Caribbean 52.6667 11563.6529 2310.6622 -519.1743 #> Middle East & North Africa 40.25 11563.6529 6215.4419 -18492.1455 #> North America 56.6667 11563.6529 13821.1717 -21876.1952 #> South Asia 45.75 11563.6529 580.8934 9525.9724 #> Sub-Saharan Africa 49.6304 11563.6529 1296.8738 4528.6387 #> Max #> East Asia & Pacific 50475.9873 #> Europe & Central Asia 75348.067 #> Latin America & Caribbean 21734.0427 #> Middle East & North Africa 60152 #> North America 45188.6033 #> South Asia 13896.4313 #> Sub-Saharan Africa 24375.5944 #> #> , , Overall, LIFEEX #> #> N/T Mean SD Min Max #> East Asia & Pacific 1717 65.6493 10.1221 18.907 84.278 #> Europe & Central Asia 2886 71.9323 5.4596 45.369 85.4171 #> Latin America & Caribbean 1995 67.7473 7.2844 42.113 82.1902 #> Middle East & North Africa 1163 65.7501 9.5211 34.361 82.4073 #> North America 135 75.9931 3.4825 68.8978 82.3005 #> South Asia 456 56.7471 11.1073 32.292 77.339 #> Sub-Saharan Africa 2716 51.0007 8.5873 27.61 74.3949 #> #> , , Between, LIFEEX #> #> N/T Mean SD Min Max #> East Asia & Pacific 32 65.6493 7.7148 48.8626 77.5681 #> Europe & Central Asia 55 71.9323 4.2526 61.9424 85.4171 #> Latin America & Caribbean 40 67.7473 4.9716 53.4959 82.1902 #> Middle East & North Africa 21 65.7501 5.8655 53.0192 76.401 #> North America 3 75.9931 1.2682 74.6066 77.9553 #> South Asia 8 56.7471 5.8027 47.8822 68.6733 #> Sub-Saharan Africa 48 51.0007 5.9389 39.349 71.403 #> #> , , Within, LIFEEX #> #> N/T Mean SD Min Max #> East Asia & Pacific 53.6562 63.8411 6.5528 33.4671 83.8595 #> Europe & Central Asia 52.4727 63.8411 3.4239 46.6863 77.0723 #> Latin America & Caribbean 49.875 63.8411 5.3241 47.1311 78.2611 #> Middle East & North Africa 55.381 63.8411 7.4998 41.8394 78.4739 #> North America 45 63.8411 3.2433 54.7836 69.485 #> South Asia 57 63.8411 9.4711 42.0094 82.0276 #> Sub-Saharan Africa 56.5833 63.8411 6.2025 43.7422 83.2612 #> #> , , Overall, GINI #> #> N/T Mean SD Min Max #> East Asia & Pacific 92 38.5065 5.3684 27.8 55.4 #> Europe & Central Asia 588 31.902 4.7383 16.2 48.4 #> Latin America & Caribbean 363 50.5664 5.3238 34.4 63.3 #> Middle East & North Africa 76 36.1947 5.1244 27.6 47.4 #> North America 22 36.1636 3.9282 31 41.1 #> South Asia 39 34.1641 4.3411 25.9 43.8 #> Sub-Saharan Africa 176 44.8165 8.3376 28.9 65.8 #> #> , , Between, GINI #> #> N/T Mean SD Min Max #> East Asia & Pacific 21 38.5065 4.8352 30.8 48.65 #> Europe & Central Asia 47 31.902 4.054 23.3667 40.8 #> Latin America & Caribbean 25 50.5664 4.0186 41.1 57.7333 #> Middle East & North Africa 14 36.1947 4.6346 29.05 43.0667 #> North America 2 36.1636 3.5731 32.6727 39.6545 #> South Asia 7 34.1641 3.4562 30.3556 39.85 #> Sub-Saharan Africa 45 44.8165 7.0733 31.45 61.7143 #> #> , , Within, GINI #> #> N/T Mean SD Min Max #> East Asia & Pacific 4.381 39.3976 2.3325 32.6476 46.1476 #> Europe & Central Asia 12.5106 39.3976 2.4529 28.636 54.4976 #> Latin America & Caribbean 14.52 39.3976 3.4921 26.3076 48.7365 #> Middle East & North Africa 5.4286 39.3976 2.1863 32.6309 46.6404 #> North America 11 39.3976 1.6323 34.343 40.843 #> South Asia 5.5714 39.3976 2.6268 34.6726 45.9309 #> Sub-Saharan Africa 3.9111 39.3976 4.4142 23.9576 54.7976 #> #> , , Overall, ODA #> #> N/T Mean SD #> East Asia & Pacific 1491 346,977686 615,361973 #> Europe & Central Asia 751 394,089867 566,834650 #> Latin America & Caribbean 1918 173,728368 259,343122 #> Middle East & North Africa 1079 663,574245 1.40635884e+09 #> North America 39 423846.154 9,678883.86 #> South Asia 450 1.25150376e+09 1.56736667e+09 #> Sub-Saharan Africa 2608 440,308474 596,033604 #> Min Max #> East Asia & Pacific -1.08038000e+09 3.92003000e+09 #> Europe & Central Asia -343,480000 4.64666000e+09 #> Latin America & Caribbean -512,730000 2.95163000e+09 #> Middle East & North Africa -169,710000 2.45521800e+10 #> North America -14,520000 55,820000 #> South Asia 80000 8.53900000e+09 #> Sub-Saharan Africa -16,780000 1.12780600e+10 #> #> , , Between, ODA #> #> N/T Mean SD Min #> East Asia & Pacific 31 346,977686 460,186340 1,550512.82 #> Europe & Central Asia 32 394,089867 446,099453 12,115777.8 #> Latin America & Caribbean 37 173,728368 169,248215 2,089677.42 #> Middle East & North Africa 21 663,574245 725,711345 2,946923.08 #> North America 1 423846.154 0 423846.154 #> South Asia 8 1.25150376e+09 1.15946284e+09 25,663448.3 #> Sub-Saharan Africa 48 440,308474 357,457530 27,340689.7 #> Max #> East Asia & Pacific 1.64164241e+09 #> Europe & Central Asia 2.16970133e+09 #> Latin America & Caribbean 560,007241 #> Middle East & North Africa 2.73873224e+09 #> North America 423846.154 #> South Asia 3.53258914e+09 #> Sub-Saharan Africa 1.41753857e+09 #> #> , , Within, ODA #> #> N/T Mean SD #> East Asia & Pacific 48.0968 428,746468 408,532605 #> Europe & Central Asia 23.4688 428,746468 349,709591 #> Latin America & Caribbean 51.8378 428,746468 196,504190 #> Middle East & North Africa 51.381 428,746468 1.20465275e+09 #> North America 39 428,746468 9,678883.86 #> South Asia 56.25 428,746468 1.05464885e+09 #> Sub-Saharan Africa 54.3333 428,746468 476,948814 #> Min Max #> East Asia & Pacific -2.18778866e+09 3.57867647e+09 #> Europe & Central Asia -1.14106420e+09 3.01475819e+09 #> Latin America & Caribbean -579,470773 2.97543078e+09 #> Middle East & North Africa -2.47969577e+09 2.35093916e+10 #> North America 413,802622 484,142622 #> South Asia -2.37972267e+09 5.51177302e+09 #> Sub-Saharan Africa -825,184566 1.07855444e+10 #>
print.qsu(psr[,"N/T",,]) # Checking out the number of observations:
#> , , PCGDP #> #> Overall Between Within #> East Asia & Pacific 1391 34 40.9118 #> Europe & Central Asia 2084 56 37.2143 #> Latin America & Caribbean 1896 36 52.6667 #> Middle East & North Africa 805 20 40.25 #> North America 170 3 56.6667 #> South Asia 366 8 45.75 #> Sub-Saharan Africa 2283 46 49.6304 #> #> , , LIFEEX #> #> Overall Between Within #> East Asia & Pacific 1717 32 53.6562 #> Europe & Central Asia 2886 55 52.4727 #> Latin America & Caribbean 1995 40 49.875 #> Middle East & North Africa 1163 21 55.381 #> North America 135 3 45 #> South Asia 456 8 57 #> Sub-Saharan Africa 2716 48 56.5833 #> #> , , GINI #> #> Overall Between Within #> East Asia & Pacific 92 21 4.381 #> Europe & Central Asia 588 47 12.5106 #> Latin America & Caribbean 363 25 14.52 #> Middle East & North Africa 76 14 5.4286 #> North America 22 2 11 #> South Asia 39 7 5.5714 #> Sub-Saharan Africa 176 45 3.9111 #> #> , , ODA #> #> Overall Between Within #> East Asia & Pacific 1491 31 48.0968 #> Europe & Central Asia 751 32 23.4688 #> Latin America & Caribbean 1918 37 51.8378 #> Middle East & North Africa 1079 21 51.381 #> North America 39 1 39 #> South Asia 450 8 56.25 #> Sub-Saharan Africa 2608 48 54.3333 #>
# In North america we only have 3 countries, for the GINI we only have 3.91 observations on average # for 45 Sub-Saharan-African countries, etc.. print.qsu(psr[,"SD",,]) # Considering only standard deviations
#> , , PCGDP #> #> Overall Between Within #> East Asia & Pacific 14094.8338 12576.62 6363.4087 #> Europe & Central Asia 26181.671 24008.1006 10444.6637 #> Latin America & Caribbean 6705.5377 6294.8452 2310.6622 #> Middle East & North Africa 18374.2208 17291.0461 6215.4419 #> North America 18345.0419 12062.9919 13821.1717 #> South Asia 1581.2678 1470.7041 580.8934 #> Sub-Saharan Africa 2553.7889 2199.9901 1296.8738 #> #> , , LIFEEX #> #> Overall Between Within #> East Asia & Pacific 10.1221 7.7148 6.5528 #> Europe & Central Asia 5.4596 4.2526 3.4239 #> Latin America & Caribbean 7.2844 4.9716 5.3241 #> Middle East & North Africa 9.5211 5.8655 7.4998 #> North America 3.4825 1.2682 3.2433 #> South Asia 11.1073 5.8027 9.4711 #> Sub-Saharan Africa 8.5873 5.9389 6.2025 #> #> , , GINI #> #> Overall Between Within #> East Asia & Pacific 5.3684 4.8352 2.3325 #> Europe & Central Asia 4.7383 4.054 2.4529 #> Latin America & Caribbean 5.3238 4.0186 3.4921 #> Middle East & North Africa 5.1244 4.6346 2.1863 #> North America 3.9282 3.5731 1.6323 #> South Asia 4.3411 3.4562 2.6268 #> Sub-Saharan Africa 8.3376 7.0733 4.4142 #> #> , , ODA #> #> Overall Between Within #> East Asia & Pacific 615,361973 460,186340 408,532605 #> Europe & Central Asia 566,834650 446,099453 349,709591 #> Latin America & Caribbean 259,343122 169,248215 196,504190 #> Middle East & North Africa 1.40635884e+09 725,711345 1.20465275e+09 #> North America 9,678883.86 0 9,678883.86 #> South Asia 1.56736667e+09 1.15946284e+09 1.05464885e+09 #> Sub-Saharan Africa 596,033604 357,457530 476,948814 #>
# -> In all regions variations in inequality (GINI) between countries are greater than variations # in inequality within countries. The opposite is true for Life-Expectancy in all regions apart # from Europe, etc.. psrl <- qsu(wlddev, ~ region, ~ iso3c, # Same, but output as nested list cols = 9:12, array = FALSE) psrl # We can use unlist2d to create a tidy data.frame
#> $PCGDP #> $PCGDP$Overall #> N Mean SD Min #> East Asia & Pacific 1391 10337.0463 14094.8338 131.9634 #> Europe & Central Asia 2084 25664.8064 26181.671 367.0493 #> Latin America & Caribbean 1896 6976.0649 6705.5377 662.2795 #> Middle East & North Africa 805 13760.2761 18374.2208 570.5574 #> North America 170 43650.5193 18345.0419 17550.5732 #> South Asia 366 1178.3447 1581.2678 267.0736 #> Sub-Saharan Africa 2283 1750.0069 2553.7889 131.6464 #> Max #> East Asia & Pacific 72183.3033 #> Europe & Central Asia 191586.64 #> Latin America & Caribbean 42491.454 #> Middle East & North Africa 113682.038 #> North America 94903.1915 #> South Asia 8971.1285 #> Sub-Saharan Africa 20333.9404 #> #> $PCGDP$Between #> N Mean SD Min Max #> East Asia & Pacific 34 10337.0463 12576.62 410.2004 40046.4089 #> Europe & Central Asia 56 25664.8064 24008.1006 788.0229 141165.083 #> Latin America & Caribbean 36 6976.0649 6294.8452 884.5499 36049.6948 #> Middle East & North Africa 20 13760.2761 17291.0461 1084.5999 65963.2711 #> North America 3 43650.5193 12062.9919 35346.4194 61278.2411 #> South Asia 8 1178.3447 1470.7041 397.4451 6638.3501 #> Sub-Saharan Africa 46 1750.0069 2199.9901 255.3999 9916.656 #> #> $PCGDP$Within #> N Mean SD Min #> East Asia & Pacific 40.9118 11563.6529 6363.4087 -11892.0702 #> Europe & Central Asia 37.2143 11563.6529 10444.6637 -30529.0928 #> Latin America & Caribbean 52.6667 11563.6529 2310.6622 -519.1743 #> Middle East & North Africa 40.25 11563.6529 6215.4419 -18492.1455 #> North America 56.6667 11563.6529 13821.1717 -21876.1952 #> South Asia 45.75 11563.6529 580.8934 9525.9724 #> Sub-Saharan Africa 49.6304 11563.6529 1296.8738 4528.6387 #> Max #> East Asia & Pacific 50475.9873 #> Europe & Central Asia 75348.067 #> Latin America & Caribbean 21734.0427 #> Middle East & North Africa 60152 #> North America 45188.6033 #> South Asia 13896.4313 #> Sub-Saharan Africa 24375.5944 #> #> #> $LIFEEX #> $LIFEEX$Overall #> N Mean SD Min Max #> East Asia & Pacific 1717 65.6493 10.1221 18.907 84.278 #> Europe & Central Asia 2886 71.9323 5.4596 45.369 85.4171 #> Latin America & Caribbean 1995 67.7473 7.2844 42.113 82.1902 #> Middle East & North Africa 1163 65.7501 9.5211 34.361 82.4073 #> North America 135 75.9931 3.4825 68.8978 82.3005 #> South Asia 456 56.7471 11.1073 32.292 77.339 #> Sub-Saharan Africa 2716 51.0007 8.5873 27.61 74.3949 #> #> $LIFEEX$Between #> N Mean SD Min Max #> East Asia & Pacific 32 65.6493 7.7148 48.8626 77.5681 #> Europe & Central Asia 55 71.9323 4.2526 61.9424 85.4171 #> Latin America & Caribbean 40 67.7473 4.9716 53.4959 82.1902 #> Middle East & North Africa 21 65.7501 5.8655 53.0192 76.401 #> North America 3 75.9931 1.2682 74.6066 77.9553 #> South Asia 8 56.7471 5.8027 47.8822 68.6733 #> Sub-Saharan Africa 48 51.0007 5.9389 39.349 71.403 #> #> $LIFEEX$Within #> N Mean SD Min Max #> East Asia & Pacific 53.6562 63.8411 6.5528 33.4671 83.8595 #> Europe & Central Asia 52.4727 63.8411 3.4239 46.6863 77.0723 #> Latin America & Caribbean 49.875 63.8411 5.3241 47.1311 78.2611 #> Middle East & North Africa 55.381 63.8411 7.4998 41.8394 78.4739 #> North America 45 63.8411 3.2433 54.7836 69.485 #> South Asia 57 63.8411 9.4711 42.0094 82.0276 #> Sub-Saharan Africa 56.5833 63.8411 6.2025 43.7422 83.2612 #> #> #> $GINI #> $GINI$Overall #> N Mean SD Min Max #> East Asia & Pacific 92 38.5065 5.3684 27.8 55.4 #> Europe & Central Asia 588 31.902 4.7383 16.2 48.4 #> Latin America & Caribbean 363 50.5664 5.3238 34.4 63.3 #> Middle East & North Africa 76 36.1947 5.1244 27.6 47.4 #> North America 22 36.1636 3.9282 31 41.1 #> South Asia 39 34.1641 4.3411 25.9 43.8 #> Sub-Saharan Africa 176 44.8165 8.3376 28.9 65.8 #> #> $GINI$Between #> N Mean SD Min Max #> East Asia & Pacific 21 38.5065 4.8352 30.8 48.65 #> Europe & Central Asia 47 31.902 4.054 23.3667 40.8 #> Latin America & Caribbean 25 50.5664 4.0186 41.1 57.7333 #> Middle East & North Africa 14 36.1947 4.6346 29.05 43.0667 #> North America 2 36.1636 3.5731 32.6727 39.6545 #> South Asia 7 34.1641 3.4562 30.3556 39.85 #> Sub-Saharan Africa 45 44.8165 7.0733 31.45 61.7143 #> #> $GINI$Within #> N Mean SD Min Max #> East Asia & Pacific 4.381 39.3976 2.3325 32.6476 46.1476 #> Europe & Central Asia 12.5106 39.3976 2.4529 28.636 54.4976 #> Latin America & Caribbean 14.52 39.3976 3.4921 26.3076 48.7365 #> Middle East & North Africa 5.4286 39.3976 2.1863 32.6309 46.6404 #> North America 11 39.3976 1.6323 34.343 40.843 #> South Asia 5.5714 39.3976 2.6268 34.6726 45.9309 #> Sub-Saharan Africa 3.9111 39.3976 4.4142 23.9576 54.7976 #> #> #> $ODA #> $ODA$Overall #> N Mean SD #> East Asia & Pacific 1491 346,977686 615,361973 #> Europe & Central Asia 751 394,089867 566,834650 #> Latin America & Caribbean 1918 173,728368 259,343122 #> Middle East & North Africa 1079 663,574245 1.40635884e+09 #> North America 39 423846.154 9,678883.86 #> South Asia 450 1.25150376e+09 1.56736667e+09 #> Sub-Saharan Africa 2608 440,308474 596,033604 #> Min Max #> East Asia & Pacific -1.08038000e+09 3.92003000e+09 #> Europe & Central Asia -343,480000 4.64666000e+09 #> Latin America & Caribbean -512,730000 2.95163000e+09 #> Middle East & North Africa -169,710000 2.45521800e+10 #> North America -14,520000 55,820000 #> South Asia 80000 8.53900000e+09 #> Sub-Saharan Africa -16,780000 1.12780600e+10 #> #> $ODA$Between #> N Mean SD Min #> East Asia & Pacific 31 346,977686 460,186340 1,550512.82 #> Europe & Central Asia 32 394,089867 446,099453 12,115777.8 #> Latin America & Caribbean 37 173,728368 169,248215 2,089677.42 #> Middle East & North Africa 21 663,574245 725,711345 2,946923.08 #> North America 1 423846.154 0 423846.154 #> South Asia 8 1.25150376e+09 1.15946284e+09 25,663448.3 #> Sub-Saharan Africa 48 440,308474 357,457530 27,340689.7 #> Max #> East Asia & Pacific 1.64164241e+09 #> Europe & Central Asia 2.16970133e+09 #> Latin America & Caribbean 560,007241 #> Middle East & North Africa 2.73873224e+09 #> North America 423846.154 #> South Asia 3.53258914e+09 #> Sub-Saharan Africa 1.41753857e+09 #> #> $ODA$Within #> N Mean SD #> East Asia & Pacific 48.0968 428,746468 408,532605 #> Europe & Central Asia 23.4688 428,746468 349,709591 #> Latin America & Caribbean 51.8378 428,746468 196,504190 #> Middle East & North Africa 51.381 428,746468 1.20465275e+09 #> North America 39 428,746468 9,678883.86 #> South Asia 56.25 428,746468 1.05464885e+09 #> Sub-Saharan Africa 54.3333 428,746468 476,948814 #> Min Max #> East Asia & Pacific -2.18778866e+09 3.57867647e+09 #> Europe & Central Asia -1.14106420e+09 3.01475819e+09 #> Latin America & Caribbean -579,470773 2.97543078e+09 #> Middle East & North Africa -2.47969577e+09 2.35093916e+10 #> North America 413,802622 484,142622 #> South Asia -2.37972267e+09 5.51177302e+09 #> Sub-Saharan Africa -825,184566 1.07855444e+10 #> #>
head(unlist2d(psrl, c("Variable","Trans"), row.names = "Region"))
#> Variable Trans Region N Mean SD #> 1 PCGDP Overall East Asia & Pacific 1391 10337.046 14094.834 #> 2 PCGDP Overall Europe & Central Asia 2084 25664.806 26181.671 #> 3 PCGDP Overall Latin America & Caribbean 1896 6976.065 6705.538 #> 4 PCGDP Overall Middle East & North Africa 805 13760.276 18374.221 #> 5 PCGDP Overall North America 170 43650.519 18345.042 #> 6 PCGDP Overall South Asia 366 1178.345 1581.268 #> Min Max #> 1 131.9634 72183.303 #> 2 367.0493 191586.640 #> 3 662.2795 42491.454 #> 4 570.5574 113682.038 #> 5 17550.5732 94903.192 #> 6 267.0736 8971.128
# Weighted Summaries ----------------------- n <- nrow(wlddev) weights <- abs(rnorm(n)) # Generate random weights qsu(wlddev, w = weights, higher = TRUE) # Computed weighted mean, SD, skewness and kurtosis
#> N Mean SD Min Max #> country 12744 - - - - #> iso3c 12744 - - - - #> date 12744 - - - - #> year 12744 1989.0998 19.2519 1960 2018 #> decade 12744 1989.0942 19.91 1960 2020 #> region 12744 - - - - #> income 12744 - - - - #> OECD 12744 - - - - #> PCGDP 8995 11795.1066 21006.6495 131.6464 191586.64 #> LIFEEX 11068 63.9185 13.058 18.907 85.4171 #> GINI 1356 39.4496 11.1782 16.2 65.8 #> ODA 8336 420,722658 847,083073 -1.08038000e+09 2.45521800e+10 #> Skew Kurt #> country - - #> iso3c - - #> date - - #> year -0.0273 4.3155 #> decade -0.026 4.6907 #> region - - #> income - - #> OECD - - #> PCGDP 4.4054 38.9941 #> LIFEEX -0.8989 6.2774 #> GINI 0.7985 6.9324 #> ODA 6.0537 65.9787
weightsNA <- weights # Weights may contain missing values.. inserting 1000 weightsNA[sample.int(n, 1000)] <- NA qsu(wlddev, w = weightsNA, higher = TRUE) # But now these values are removed from all variables
#> N Mean SD Min Max #> country 12744 - - - - #> iso3c 12744 - - - - #> date 12744 - - - - #> year 11744 1989.1442 19.2227 1960 2018 #> decade 11744 1989.1335 19.8649 1960 2020 #> region 12744 - - - - #> income 12744 - - - - #> OECD 12744 - - - - #> PCGDP 8302 11822.4141 21087.0964 131.6464 191586.64 #> LIFEEX 10195 63.9559 13.0413 18.907 85.4171 #> GINI 1239 39.56 11.111 16.2 65.8 #> ODA 7697 417,130367 837,962090 -1.08038000e+09 2.45521800e+10 #> Skew Kurt #> country - - #> iso3c - - #> date - - #> year -0.0453 4.321 #> decade -0.0495 4.6983 #> region - - #> income - - #> OECD - - #> PCGDP 4.4713 40.1835 #> LIFEEX -0.907 6.3303 #> GINI 0.8861 7.1904 #> ODA 6.0594 67.3546
# Grouped and panel-summaries can also be weighted in the same manor