Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help in plotting equiplot for the DHS dataset

    Hello Everyone.
    Recently i was working in a project of maternal inequality of BDHS 2011,2014,2017 data by measuring the changes in concentration indexes of ANC, SBA & PNC utilization. I wanted to plot an equiplot for a better understanding of the inequality. But i am new to this forum and have very little knowledge about this software. I have arranged my data set in the following format Graph Variables.dta
    i wanted my graph to look like this Click image for larger version

Name:	Screenshot 2024-04-09 134942.png
Views:	1
Size:	22.7 KB
ID:	1749377 Click image for larger version

Name:	Screenshot 2024-04-09 135039.png
Views:	1
Size:	38.2 KB
ID:	1749378
    i know the command of equiplot but am unable to sort my datset according to my needs.
    any help is highly appreciated.
    Thanks in Advance.

  • #2

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double(Division_2011 Residence_2011 ANC_greater_or_4_2011 Wealth_Index_2011 Division_2014 Residence_2014 ANC_greater_or_4_2014 Wealth_Index_2014 Division_2017 Residence_2017 ANC_greater_or_4_2017 Wealth_Index_2017)
    1 1 0 3 1 1 0 1 1 1 0 1
    1 1 0 3 1 1 0 1 1 1 0 1
    1 1 0 3 1 1 1 2 1 1 1 2
    1 1 1 2 1 1 1 2 1 1 0 1
    1 1 0 2 1 1 0 2 1 1 0 1
    1 1 0 2 1 1 0 1 1 1 0 1
    1 1 0 4 1 1 0 1 1 1 1 3
    1 1 0 1 1 1 1 1 1 1 0 2
    1 1 1 3 1 1 1 4 1 1 0 2
    1 1 0 2 1 1 1 2 1 1 0 2
    1 1 0 2 1 1 0 3 1 1 1 1
    1 1 1 2 1 1 0 2 1 1 0 2
    1 1 0 2 1 1 0 2 1 1 0 1
    1 1 0 3 1 1 1 1 1 1 0 1
    1 1 0 2 1 1 0 2 1 1 0 2
    1 1 0 3 1 1 0 1 1 1 0 1
    1 1 0 2 1 1 0 2 1 1 1 3
    1 1 0 3 1 1 1 2 1 1 0 1
    1 1 0 2 1 1 1 2 1 1 0 2
    1 1 0 2 1 1 0 4 1 1 0 1
    1 1 0 2 1 1 0 2 1 1 1 5
    1 1 1 2 1 1 0 3 1 1 0 1
    1 1 0 1 1 1 1 3 1 1 1 4
    1 1 0 1 1 1 1 4 1 1 0 1
    1 1 0 4 1 1 1 3 1 1 0 3
    1 1 0 2 1 1 0 1 1 1 0 3
    1 1 0 2 1 1 1 1 1 1 0 2
    1 0 1 5 1 1 0 2 1 1 1 3
    1 0 1 5 1 1 1 5 1 1 1 1
    1 0 1 5 1 1 1 2 1 1 1 2
    1 0 1 5 1 1 1 1 1 1 0 1
    1 0 1 5 1 1 1 1 1 1 0 1
    1 0 0 4 1 1 0 1 1 1 1 3
    1 0 0 5 1 1 1 3 1 1 0 1
    1 0 1 5 1 1 0 3 1 1 0 3
    1 0 1 5 1 1 0 2 1 1 1 4
    1 0 0 4 1 1 0 4 1 1 1 1
    1 1 1 2 1 1 0 5 1 1 0 1
    1 1 0 2 1 1 0 4 1 1 0 1
    1 1 0 3 1 1 0 1 1 1 0 2
    1 1 1 1 1 1 0 4 1 1 1 1
    1 1 0 5 1 1 1 3 1 1 0 1
    1 1 1 1 1 1 0 2 1 1 0 1
    1 1 0 2 1 1 0 2 1 1 1 1
    1 1 1 2 1 1 0 3 1 1 0 1
    1 1 0 3 1 1 0 3 1 1 1 1
    1 1 1 2 1 1 1 1 1 1 1 1
    1 1 0 2 1 1 1 1 1 1 1 3
    1 1 0 4 1 1 0 3 1 1 1 5
    1 1 0 1 1 1 1 4 1 1 1 3
    1 1 1 2 1 1 0 3 1 1 0 5
    1 1 0 2 1 1 0 3 1 1 0 4
    1 1 0 2 1 1 0 2 1 1 0 2
    1 1 0 1 1 1 0 4 1 1 1 4
    1 1 0 2 1 1 0 1 1 1 0 3
    1 1 0 3 1 1 0 3 1 1 1 4
    1 1 0 3 1 1 0 2 1 1 1 2
    1 1 0 3 1 1 0 1 1 1 0 1
    1 1 1 3 1 1 1 1 1 1 1 3
    1 1 0 4 1 1 1 1 1 1 0 2
    1 1 0 2 1 1 0 2 1 1 1 4
    1 1 0 3 1 1 0 4 1 1 1 3
    1 1 0 3 1 1 0 4 1 1 0 3
    1 1 0 3 1 1 0 4 1 1 1 4
    1 1 0 4 1 1 0 3 1 1 1 3
    1 1 0 4 1 1 0 2 1 1 1 2
    1 1 0 1 1 1 0 1 1 1 1 2
    1 1 0 1 1 1 0 2 1 1 1 2
    1 0 0 2 1 1 0 2 1 1 1 1
    1 0 0 3 1 1 1 4 1 1 1 3
    1 0 0 1 1 1 1 3 1 1 0 3
    1 0 0 1 1 1 0 3 1 1 1 2
    1 0 0 3 1 1 0 1 1 1 0 2
    1 0 0 1 1 1 0 2 1 1 0 3
    1 0 0 1 1 1 0 4 1 1 0 2
    1 1 0 3 1 1 0 3 1 1 0 2
    1 1 0 1 1 1 0 3 1 1 1 2
    1 1 0 2 1 1 0 2 1 1 1 2
    1 1 1 3 1 1 0 2 1 1 1 4
    1 1 0 1 1 1 1 4 1 1 1 4
    1 1 0 2 1 1 1 3 1 1 1 4
    1 1 0 3 1 1 0 3 1 1 1 2
    1 1 0 3 1 1 1 4 1 1 0 2
    1 1 0 3 1 1 1 2 1 1 1 4
    1 1 0 1 1 1 1 3 1 1 1 3
    1 1 0 2 1 1 0 4 1 1 1 4
    1 1 0 3 1 1 0 5 1 1 0 1
    1 1 0 1 1 1 0 2 1 1 0 2
    1 1 0 3 1 1 0 3 1 1 0 2
    1 1 0 4 1 1 0 5 1 1 0 2
    1 1 0 2 1 1 1 3 1 1 0 1
    1 1 1 3 1 1 1 4 1 1 0 5
    1 1 0 3 1 1 0 3 1 1 0 1
    1 1 1 3 1 1 0 3 1 1 1 3
    1 1 1 2 1 1 1 4 1 1 0 1
    1 1 0 4 1 1 0 5 1 1 0 1
    1 1 0 3 1 1 1 4 1 1 0 2
    1 1 1 3 1 1 0 1 1 1 0 1
    1 1 1 3 1 1 0 2 1 1 0 1
    1 1 0 3 1 1 0 2 1 1 0 1
    end
    label values Division_2011 Division_2011
    label def Division_2011 1 "Barisal", modify
    label values Residence_2011 Residence_2011
    label def Residence_2011 0 "Urban", modify
    label def Residence_2011 1 "Rural", modify
    label values ANC_greater_or_4_2011 ANC_greater_or_4_2011
    label def ANC_greater_or_4_2011 0 "No", modify
    label def ANC_greater_or_4_2011 1 "Yes", modify
    label values Wealth_Index_2011 Wealth_Index_2011
    label def Wealth_Index_2011 1 "Poorest", modify
    label def Wealth_Index_2011 2 "Poorer", modify
    label def Wealth_Index_2011 3 "Middle", modify
    label def Wealth_Index_2011 4 "Richer", modify
    label def Wealth_Index_2011 5 "Richest", modify
    label values Division_2014 Division_2014
    label def Division_2014 1 "Barisal", modify
    label values Residence_2014 Residence_2014
    label def Residence_2014 1 "Rural", modify
    label values ANC_greater_or_4_2014 ANC_greater_or_4_2014
    label def ANC_greater_or_4_2014 0 "Less Than 4", modify
    label def ANC_greater_or_4_2014 1 "4 or more", modify
    label values Wealth_Index_2014 Wealth_index_2014
    label def Wealth_index_2014 1 "Poorest", modify
    label def Wealth_index_2014 2 "Poorer", modify
    label def Wealth_index_2014 3 "Middle", modify
    label def Wealth_index_2014 4 "Richer", modify
    label def Wealth_index_2014 5 "Richest", modify
    label values Division_2017 Division_2017
    label def Division_2017 1 "Barisal", modify
    label values Residence_2017 Residence_2017
    label def Residence_2017 1 "Rural", modify
    label values ANC_greater_or_4_2017 ANC_greater_or_4_2017
    label def ANC_greater_or_4_2017 0 "3 or less", modify
    label def ANC_greater_or_4_2017 1 "4 or more", modify
    label values Wealth_Index_2017 Wealth_index_2017
    label def Wealth_index_2017 1 "Poorest", modify
    label def Wealth_index_2017 2 "Poorer", modify
    label def Wealth_index_2017 3 "Middle", modify
    label def Wealth_index_2017 4 "Richer", modify
    label def Wealth_index_2017 5 "Richest", modify
    This is my dataset and i found this code in net that i am sharing Template_Practice2.docx
    by this approach i tried to reshape my data into long format by year
    Code:
    egen id = seq(), from(1)
    reshape long Division_ Residence_ ANC_greater_or_4_ Wealth_Index_, i(id) j(year)
    (j = 2011 2014 2017)
    
    Data                               Wide   ->   Long
    -----------------------------------------------------------------------------
    Number of observations            7,319   ->   21,957      
    Number of variables                  13   ->   6           
    j variable (3 values)                     ->   year
    xij variables:
    Division_2011 Division_2014 Division_2017 ->   Division_
    Residence_2011 Residence_2014 Residence_2017-> Residence_
    ANC_greater_or_4_2011 ANC_greater_or_4_2014 ANC_greater_or_4_2017->ANC_greater_o
    > r_4_
    Wealth_Index_2011 Wealth_Index_2014 Wealth_Index_2017->Wealth_Index_
    -----------------------------------------------------------------------------
    Here is my new dataset
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int(id year) double(Division_ Residence_ ANC_greater_or_4_ Wealth_Index_)
     1 2011 1 1 0 3
     1 2014 1 1 0 1
     1 2017 1 1 0 1
     2 2011 1 1 0 3
     2 2014 1 1 0 1
     2 2017 1 1 0 1
     3 2011 1 1 0 3
     3 2014 1 1 1 2
     3 2017 1 1 1 2
     4 2011 1 1 1 2
     4 2014 1 1 1 2
     4 2017 1 1 0 1
     5 2011 1 1 0 2
     5 2014 1 1 0 2
     5 2017 1 1 0 1
     6 2011 1 1 0 2
     6 2014 1 1 0 1
     6 2017 1 1 0 1
     7 2011 1 1 0 4
     7 2014 1 1 0 1
     7 2017 1 1 1 3
     8 2011 1 1 0 1
     8 2014 1 1 1 1
     8 2017 1 1 0 2
     9 2011 1 1 1 3
     9 2014 1 1 1 4
     9 2017 1 1 0 2
    10 2011 1 1 0 2
    10 2014 1 1 1 2
    10 2017 1 1 0 2
    11 2011 1 1 0 2
    11 2014 1 1 0 3
    11 2017 1 1 1 1
    12 2011 1 1 1 2
    12 2014 1 1 0 2
    12 2017 1 1 0 2
    13 2011 1 1 0 2
    13 2014 1 1 0 2
    13 2017 1 1 0 1
    14 2011 1 1 0 3
    14 2014 1 1 1 1
    14 2017 1 1 0 1
    15 2011 1 1 0 2
    15 2014 1 1 0 2
    15 2017 1 1 0 2
    16 2011 1 1 0 3
    16 2014 1 1 0 1
    16 2017 1 1 0 1
    17 2011 1 1 0 2
    17 2014 1 1 0 2
    17 2017 1 1 1 3
    18 2011 1 1 0 3
    18 2014 1 1 1 2
    18 2017 1 1 0 1
    19 2011 1 1 0 2
    19 2014 1 1 1 2
    19 2017 1 1 0 2
    20 2011 1 1 0 2
    20 2014 1 1 0 4
    20 2017 1 1 0 1
    21 2011 1 1 0 2
    21 2014 1 1 0 2
    21 2017 1 1 1 5
    22 2011 1 1 1 2
    22 2014 1 1 0 3
    22 2017 1 1 0 1
    23 2011 1 1 0 1
    23 2014 1 1 1 3
    23 2017 1 1 1 4
    24 2011 1 1 0 1
    24 2014 1 1 1 4
    24 2017 1 1 0 1
    25 2011 1 1 0 4
    25 2014 1 1 1 3
    25 2017 1 1 0 3
    26 2011 1 1 0 2
    26 2014 1 1 0 1
    26 2017 1 1 0 3
    27 2011 1 1 0 2
    27 2014 1 1 1 1
    27 2017 1 1 0 2
    28 2011 1 0 1 5
    28 2014 1 1 0 2
    28 2017 1 1 1 3
    29 2011 1 0 1 5
    29 2014 1 1 1 5
    29 2017 1 1 1 1
    30 2011 1 0 1 5
    30 2014 1 1 1 2
    30 2017 1 1 1 2
    31 2011 1 0 1 5
    31 2014 1 1 1 1
    31 2017 1 1 0 1
    32 2011 1 0 1 5
    32 2014 1 1 1 1
    32 2017 1 1 0 1
    33 2011 1 0 0 4
    33 2014 1 1 0 1
    33 2017 1 1 1 3
    34 2011 1 0 0 5
    end
    label values Division_ Division_2017
    label def Division_2017 1 "Barisal", modify
    label values Residence_ Residence_2017
    label def Residence_2017 0 "Urban", modify
    label def Residence_2017 1 "Rural", modify
    label values ANC_greater_or_4_ ANC_greater_or_4_2017
    label def ANC_greater_or_4_2017 0 "3 or less", modify
    label def ANC_greater_or_4_2017 1 "4 or more", modify
    label values Wealth_Index_ Wealth_index_2017
    label def Wealth_index_2017 1 "Poorest", modify
    label def Wealth_index_2017 2 "Poorer", modify
    label def Wealth_index_2017 3 "Middle", modify
    label def Wealth_index_2017 4 "Richer", modify
    label def Wealth_index_2017 5 "Richest", modify
    Now for the equiplot when i try to reshape the data into wide format by dividing into wealth quantiles for division & year it is what i get
    Code:
    drop if missing( Wealth_Index_ )
    reshape wide ANC_greater_or_4_, i( Division_ year ) j( Wealth_Index_ )
    Code:
    . reshape wide ANC_greater_or_4_, i( Division_ year ) j( Wealth_Index_ )
    (j = 1 2 3 4 5)
    values of variable Wealth_Index_ not unique within Division_ year
        Your data are currently long. You are performing a reshape wide. You
        specified i(Division_ year) and j(Wealth_Index_). There are observations
        within i(Division_ year) with the same value of j(Wealth_Index_). In the
        long data, variables i() and j() together must uniquely identify the
        observations.
    
             long                                wide
            +---------------+                   +------------------+
            | i   j   a   b |                   | i   a1 a2  b1 b2 |
            |---------------| <--- reshape ---> |------------------|
            | 1   1   1   2 |                   | 1   1   3   2  4 |
            | 1   2   3   4 |                   | 2   5   7   6  8 |
            | 2   1   5   6 |                   +------------------+
            | 2   2   7   8 |
            +---------------+
        Type reshape error for a list of the problem variables.
    r(9);
    If anyone can give solution then it would be really benificial

    Comment

    Working...
    X