Announcement

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

  • Overlaying two way graphs

    Hi there,

    I'm trying to create two different types of two-way graph based on the below sample of my data. Essentially I need a two way graph with y=leverageratio and x=year per cluster, where each graph the leverage ratio means are plotted and connect by a simple line from year to year and this is over-layed with a confidence interval lfit plot for the same data.

    So far I have managed to create a confidence interval lfit plot for each cluster using the following command:

    twoway lfitci leverageratio year, by(_clus_7) ciplot(rline)

    But I don't know how to add a simple year-by-year lineplot of the mean leverage ratio of each year to the graphs produced.

    This command gives me an individual graph per cluster which is useful as I can scan across to determine differences fairly easily but is there also a way to combine these into one graph (with maybe each set of plots colour coordinated according to their cluster value)? I would love to check for practical comparison. If not, is there a way to get stata to display each cluster graph in a straight horizontal line rather than staked above each other?

    Many thanks for your time and help

    Olly





    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str86 institutionname int year double leverageratio byte _clus_7
    "321 Crédito – Instituição Financeira de Crédito, SA" 2010  .9389913082122803 4
    "321 Crédito – Instituição Financeira de Crédito, SA" 2011  .9274295568466187 4
    "321 Crédito – Instituição Financeira de Crédito, SA" 2012  .9187982082366943 4
    "321 Crédito – Instituição Financeira de Crédito, SA" 2013  .9250616431236267 4
    "321 Crédito – Instituição Financeira de Crédito, SA" 2014  .8373574614524841 4
    "321 Crédito – Instituição Financeira de Crédito, SA" 2015  .8773081302642822 4
    "321 Crédito – Instituição Financeira de Crédito, SA" 2016  .8790023922920227 4
    "A.B.S. Factoring AG"                                       2010   .752466082572937 4
    "A.B.S. Factoring AG"                                       2011  .8283402323722839 4
    "A.B.S. Factoring AG"                                       2012  .7865426540374756 4
    "A.B.S. Factoring AG"                                       2013  .7933895587921143 4
    "A.B.S. Factoring AG"                                       2014  .7725772261619568 4
    "A.B.S. Factoring AG"                                       2015  .5135195851325989 5
    "A.B.S. Factoring AG"                                       2016 .21618571877479553 5
    "ABC Factors SA"                                            2010   .877510666847229 4
    "ABC Factors SA"                                            2011  .8239607810974121 4
    "ABC Factors SA"                                            2012  .7777330875396729 4
    "ABC Factors SA"                                            2013  .7878907918930054 4
    "ABC Factors SA"                                            2014  .7992507815361023 4
    "ABC Factors SA"                                            2015  .7905886769294739 4
    "ABC Factors SA"                                            2016  .8044500350952148 4
    "ABH Financial Ltd."                                        2010  .8918814659118652 4
    "ABH Financial Ltd."                                        2011   .890483021736145 4
    "ABH Financial Ltd."                                        2012  .9096055030822754 4
    "ABH Financial Ltd."                                        2013  .9009599685668945 4
    "ABH Financial Ltd."                                        2014  .9013909697532654 4
    "ABH Financial Ltd."                                        2015  .8619637489318848 4
    "ABH Financial Ltd."                                        2016  .8500797152519226 4
    "ABK Allgemeine Beamten Bank AG"                            2010  .8813025951385498 4
    "ABK Allgemeine Beamten Bank AG"                            2011   .879583477973938 4
    "ABK Allgemeine Beamten Bank AG"                            2012  .8811082243919373 4
    "ABK Allgemeine Beamten Bank AG"                            2013  .8809574842453003 4
    "ABK Allgemeine Beamten Bank AG"                            2014  .8816251754760742 4
    "ABK Allgemeine Beamten Bank AG"                            2015  .8741796612739563 4
    "ABK Allgemeine Beamten Bank AG"                            2016  .8684602379798889 4
    "ABK Bank"                                                  2010  .5765788555145264 2
    "ABK Bank"                                                  2011  .6777274012565613 2
    "ABK Bank"                                                  2012  .6582133173942566 2
    "ABK Bank"                                                  2013  .7334760427474976 4
    "ABK Bank"                                                  2014  .6657310724258423 5
    "ABK Bank"                                                  2015  .6377254128456116 5
    "ABK Bank"                                                  2016  .6085771918296814 5
    "ABN AMRO Bank (Luxembourg) SA"                             2010   .888306736946106 3
    "ABN AMRO Bank (Luxembourg) SA"                             2011  .7975928783416748 3
    "ABN AMRO Bank (Luxembourg) SA"                             2012  .8175475001335144 3
    "ABN AMRO Bank (Luxembourg) SA"                             2013  .9294227361679077 3
    "ABN AMRO Bank (Luxembourg) SA"                             2014  .9240388870239258 3
    "ABN AMRO Bank (Luxembourg) SA"                             2015  .9283875823020935 3
    "ABN AMRO Bank (Luxembourg) SA"                             2016  .9353662133216858 3
    "ABN AMRO Bank NV"                                          2010  .9678966999053955 4
    "ABN AMRO Bank NV"                                          2011  .9717803001403809 4
    "ABN AMRO Bank NV"                                          2012  .9672819375991821 4
    "ABN AMRO Bank NV"                                          2013  .9635290503501892 4
    "ABN AMRO Bank NV"                                          2014   .961544930934906 4
    "ABN AMRO Bank NV"                                          2015  .9568356275558472 4
    "ABN AMRO Bank NV"                                          2016  .9519952535629273 4
    "ABN AMRO Group NV"                                         2010  .9678966999053955 4
    "ABN AMRO Group NV"                                         2011  .9717803001403809 4
    "ABN AMRO Group NV"                                         2012  .9672819375991821 4
    "ABN AMRO Group NV"                                         2013  .9635290503501892 4
    "ABN AMRO Group NV"                                         2014  .9640417695045471 4
    "ABN AMRO Group NV"                                         2015  .9568356275558472 4
    "ABN AMRO Group NV"                                         2016  .9519927501678467 4
    "AEGON Bank NV"                                             2010  .9375515580177307 2
    "AEGON Bank NV"                                             2011  .9648059606552124 2
    "AEGON Bank NV"                                             2012  .9600897431373596 2
    "AEGON Bank NV"                                             2013  .9603189826011658 2
    "AEGON Bank NV"                                             2014  .9541988968849182 4
    "AEGON Bank NV"                                             2015  .9588426947593689 4
    "AEGON Bank NV"                                             2016  .9546744227409363 4
    "AGCO Finance GmbH"                                         2010  .9309380650520325 4
    "AGCO Finance GmbH"                                         2011  .9280826449394226 4
    "AGCO Finance GmbH"                                         2012  .9179612398147583 4
    "AGCO Finance GmbH"                                         2013  .9072089791297913 4
    "AGCO Finance GmbH"                                         2014  .8959357142448425 4
    "AGCO Finance GmbH"                                         2015  .9035959839820862 4
    "AGCO Finance GmbH"                                         2016  .8883731365203857 4
    "AIB Mortgage Bank"                                         2010  .9885719418525696 3
    "AIB Mortgage Bank"                                         2011   .956977903842926 4
    "AIB Mortgage Bank"                                         2012  .9596717953681946 4
    "AIB Mortgage Bank"                                         2013  .9523066878318787 4
    "AIB Mortgage Bank"                                         2014  .9328936338424683 4
    "AIB Mortgage Bank"                                         2015  .9036802053451538 4
    "AIB Mortgage Bank"                                         2016   .881637692451477 4
    "AKA Ausfuhrkredit-Gesellschaft mbH"                        2010  .9481054544448853 3
    "AKA Ausfuhrkredit-Gesellschaft mbH"                        2011  .9440717697143555 3
    "AKA Ausfuhrkredit-Gesellschaft mbH"                        2012   .937321126461029 4
    "AKA Ausfuhrkredit-Gesellschaft mbH"                        2013  .9316751956939697 4
    "AKA Ausfuhrkredit-Gesellschaft mbH"                        2014  .9278743267059326 4
    "AKA Ausfuhrkredit-Gesellschaft mbH"                        2015  .9262809157371521 4
    "AKA Ausfuhrkredit-Gesellschaft mbH"                        2016  .9252120852470398 4
    "ALBIS Leasing AG"                                          2010  .9902958273887634 4
    "ALBIS Leasing AG"                                          2011  .9727221131324768 4
    "ALBIS Leasing AG"                                          2012  .9611541032791138 4
    "ALBIS Leasing AG"                                          2013  .9922723770141602 4
    "ALBIS Leasing AG"                                          2014  .9457637071609497 4
    "ALBIS Leasing AG"                                          2015  .9517415761947632 4
    "ALBIS Leasing AG"                                          2016  .9140797853469849 4
    "ALETTI & C. Banca di Investimento Mobiliare SpA"           2010  .9395496845245361 2
    "ALETTI & C. Banca di Investimento Mobiliare SpA"           2011  .9522174596786499 2
    end
    Last edited by Olly Rice; 08 Apr 2018, 06:30.

  • #2
    There are many ways you can do it, one quicker way probably is to use the 'lgraph' programme by Timothy Mak. Install the 'lgraph' programme from ssc and run the command:

    Code:
    ssc install lgraph //install the programme
    
    lgraph leverageratio year _clus_7, err(ci(95))
    Roman

    Comment

    Working...
    X