# Estimate and Manage Empirical Distributions

Tools to estimate and manage empirical distributions, which should work with survey data. One of the main features is the possibility to create data cubes of estimated statistics, that include all the combinations of the variables of interest (see for example functions dcc5() and dcc6()).

# Overview

distrr provides some tools to estimate and manage empirical distributions. In particular, one of the main features of distrr is the creation of data cubes of estimated statistics, that include all the combinations of the variables of interest. The package makes strong usage of the tools provided by dplyr, which is a grammar of data manipulation.

The main functions to create a data cube are `dcc5()` and `dcc6()` (`dcc` stands for data cube creation).

The data cube creation is like:

``````data %>%
group_by(some variables) %>%
summarise(one or more estimated statistic)
``````

in dplyr terms, but the operation is done for each possible combination of the variables used for grouping. The result will be a data frame in “tidy form”. See some examples in the Usage section below.

# Installation

``````install.packages("distrr")

# Or the development version from GitHub:
# install.packages("devtools")
devtools::install_github("gibonet/distrr")
``````

# Usage

Consider the `invented_wages` dataset:

If we want to count the number of observations and estimate the average wage by gender, with dplyr we can do:

We can estimate the same statistics but grouped by education by changing the argument inside `group_by`:

and estimate the statistics by gender and education including both variables in `group_by`:

With `dcc5` we can perform all the steps above with one call:

The resulting data frame contains a column for each grouping variable, and the estimations of all the combinations of the variables:

• by gender
• by education
• by gender and education
• plus the same statistics for all the dataset, without any grouping (this can be set with the argument `.all`, which by default is `TRUE`).

Note that in the result there are some rows where the variables take the value `"Totale"`. When a variable has this value, it means that the subset of the data considered in that row contains all the values of the variable. For example, the first row of the result of `dcc5` contains the estimations for all the dataset. The value `"Totale"` can be changed with the argument `.total`.

The same result of `dcc5` can be produced by `dcc6`, with a slightly different approach.

Compared to the results obtained with `dcc5`, we added the weighted average of wages and changed the `"Totale"` value to `"TOTAL"`.

# News

## distrr 0.0.5

• lazyeval has been substituted with rlang (tidy evaluation). This means that all the softly-deprecated dplyr functions that ended with an underscore (like summarise_(), select_(), ...) have been substituted with the versions without underscore (like summarise(), select(), and so on). All the dplyr functions are in dplyr_new_wrappers.R.
• In some functions (jointfun_(), dcc6() and joint_all_funs_()) n() has been replaced with dplyr::n() (to be compatible with dplyr 0.0.8).

# Reference manual

install.packages("distrr")

0.0.5 by Sandro Petrillo Burri, a year ago

https://gibonet.github.io/distrr, https://github.com/gibonet/distrr

Browse source code at https://github.com/cran/distrr

Authors: Sandro Petrillo Burri [aut, cre]

Documentation:   PDF Manual