## Simple Simulation

    library(MPI)
    library(kableExtra)

### Loading Data

`MPI::examplePovertydf` is a simulation poverty data frame contains 16 indicators column which 1 means deprived and 0 means not deprived, and simulated forth-level administrative division of France.

    data(examplePovertydf)

Access to health care | Child Mortality | Access to clean source of water | Access to an improve sanatation | Electricity | Asset ownership | Cooking Fuel | Housing Materials | School lag | School attendance | Years of education | Region
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
1 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | Olmeto
0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | Olmeto
1 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | Olmeto

### Calculation

For calculating MPI using `AF_Seq` for sequential run or `AF_Par` for parallel run.

Input will be

- `df` A poverty data frame
- `g` A column name that will be used to divide data into groups. When the value is NULL, the entire data is not separated into groups.
- `w` An indicator weight vectors
- `k` A poverty cut-off. If an aggregate value of indicators of a specific person is above or equal the value of k, then this person is considered to be a poor.(default as 1)

    out_seq <- AF_Seq(examplePovertydf, g = "Region", k = 3)

Output will be list of lists separated into group, and each list contains

- `groupname` A Grouped value from column input `g`

    ## [1] "Bastia"

- `total` Number of population in each group

    ## [1] 2

- `poors` Number of deprived people in each group

    ## [1] 2

- `H` Head count ratio, the proportion of the population that is multidimensionally deprived calculated by divide the number of poor people with the total number of people.

    ## [1] 1

- `A` Average deprivation share among poor people, by aggregating the proportion of total deprivations each person and dividing by the total number of poor people.

    ## [1] 0.4090909

- `M0` Multidimensional Poverty Index, calculated by H times A.

    ## [1] 0.4090909

- `DimentionalContribution`
  - `indnames` The poverty indicators
  - `diCont` Dimensional contributions denotes the magnitude of each indicator impacts on MPI.
  - `UncensoredHCount` Uncensored head count of indicator denotes the population that are deprived in that indicator.
  - `UncensoredHRatio` Uncensored head count ratio of indicator denotes the proportion of the population deprived in that indicator.
  - `CensoredHCount` Censored head count of indicator denotes the population that are multidimensionally poor and deprived in that indicator at the same time.
  - `CensoredHRatio` Censored head count ratio of indicator denotes the proportion that is multidimensionally poor and deprived in that indicator at the same time.

    indnames | diCont | UncensoredHCounts | UncensoredHRatio | CensoredHCounts | CensoredHRatio
    --- | --- | --- | --- | --- | ---
    Access.to.health.care | 0.1111111 | 1 | 0.5 | 1 | 0.5
    Child.Mortality | 0.1111111 | 1 | 0.5 | 1 | 0.5
    Access.to.clean.source.of.water | 0.1111111 | 1 | 0.5 | 1 | 0.5
    Access.to.an.improve.sanatation | 0.2222222 | 2 | 1.0 | 2 | 1.0
    Electricity | 0.0000000 | 0 | 0.0 | 0 | 0.0
    Asset.ownership | 0.2222222 | 2 | 1.0 | 2 | 1.0
    Cooking.Fuel | 0.0000000 | 0 | 0.0 | 0 | 0.0
    Housing.Materials | 0.1111111 | 1 | 0.5 | 1 | 0.5
    School.lag | 0.0000000 | 0 | 0.0 | 0 | 0.0
    School.attendance | 0.1111111 | 1 | 0.5 | 1 | 0.5
    Years.of.education | 0.0000000 | 0 | 0.0 | 0 | 0.0

- `pov_df` poverty data frame
  - `Cvector` is a vector of total values of deprived indicators adjusted by weight of indicators. Each element in `Cvector` represents a total value of each individual.
  - `IsPoverty` is a binary variable with only 1 and 0, with 1 indicating that person does not meet the threshold(poor person) and 0 indicating the opposite.
  - `Intensity` The intensity of a deprived indication among impoverished people is computed by dividing the number of deprived indicators by the total number of indicators.

    Access to health care | Child Mortality | Access to clean source of water | Access to an improve sanatation | Electricity | Asset ownership | Cooking Fuel | Housing Materials | School lag | School attendance | Years of education | Cvector | IsPoverty | Intensity
    --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
    1 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 5 | 1 | 0.4545455
    0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 4 | 1 | 0.3636364