Announcement

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

  • Graph with multiple indicators for multiple individuals

    Dear Statalist,

    Here the data.
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte(ID networkingcapitalownersequity networkingcapitalotherliabilitie reservesownersequity totalassetsnetworkingcapital)
    1 3 1 3 2
    2 3 3 3 2
    3 2 1 1 3
    4 3 3 3 2
    5 1 1 3 2
    end

    I would like to produce a graph where for each indicator and ID I assign a colour representing a degree of risk (see Table below). The idea is that for each ID (appearing on the X axis) and indicator (on the Y axis) I have a color representing low risk (1 in the table and data), medium risk (2) and high risk (3). In the graph I would like to use just colour coding, i.e. numbers should not appear in the graph. Ideally all the indicators should appear on the same graph as in the Table below.
    Net working Capital / Owener's Equity 1 1 2 3 1
    Reserves / Owners' Equity 2 1 2 3 1
    ....... 1 1 1 2 3
    ............ 3 3 3 3 3
    ...................
    1 2 3 4 5

    I have been unable to find a code or thread that can help me. I would really appreciate your help on this.

  • #2
    What you ask for seems feasible. The only questions are how well it works. How many identifiers do you have? How many risk variables? Why wire in numeric identifier order? Do you want to look for patterns or identify details or what?

    Here is some code.

    Code:
    clear
    input byte(ID networkingcapitalownersequity networkingcapitalotherliabilitie reservesownersequity totalassetsnetworkingcapital)
    1 3 1 3 2
    2 3 3 3 2
    3 2 1 1 3
    4 3 3 3 2
    5 1 1 3 2
    end
    
    preserve 
    
    ds ID, not 
    
    rename (`r(varlist)') (risk#), addnumber 
    label def  risk 1 "Net working Capital / Owners' Equity"
    label def  risk 2 "Reserves / Owners' Equity", add 
    label def  risk 3 "add some suitable" 4 "spell-checked text", add 
    
    reshape long risk, i(ID) j(which)
    
    label val which risk 
    
    * number of risk variables 
    local J = 4 
    
    scatter which ID if risk == 1, mfc(blue*0.4) mlc(blue) msize(huge)  ///
    || scatter which ID if risk == 2, mfc(red*0.4) mlc(red) msize(huge)  ///
    || scatter which ID if risk == 3, mfc(red*1.2) mlc(red) msize(huge)  ///
    legend(order(1 "low" 2 "medium" 3 "high") row(1) pos(12)) yla(1/`J', valuelabel tlc(none)) ysc(reverse) ytitle("") xsc(r(0.8 .)) ysc(r(0.8 `J'.2))
    
    restore
    Click image for larger version

Name:	risk.png
Views:	1
Size:	37.8 KB
ID:	1725002

    Comment


    • #3
      Hi Nick, the graph is what I was looking for. Below answers to your questions:
      How many identifiers do you have? --> 10. So I believe it manageable to organize the information the way you do.
      How many risk variables? --> 19. So maybe too-many. What I forgot to mention is that indicators can be grouped into broader categories (e.g., capitalization, liquidity, etc.)
      Why wire in numeric identifier order? --> Well, I do not need them really. IDs are used to anonymize info on individuals
      Do you want to look for patterns or identify details or what? --> patterns by individual or indicator.
      Thank you again Nick.

      Comment

      Working...
      X