Announcement

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

  • #16
    so the command is
    Code:
    graph twoway line tradevalueus period_new if tradeflow=="exports" & partner=="belgium", c(L)
    Than the graph is:
    Click image for larger version

Name:	Bildschirmfoto 2022-10-13 um 13.03.38.png
Views:	1
Size:	505.2 KB
ID:	1685261
    Hope I'm getting closer to my solution step by step, but this graph doesn't seems to be the right.
    Thanks for your prompt replies helps me not to be completely frustrated directly

    Comment


    • #17
      Note however that your period_new axis labels make no sense.

      It's possible to reconstruct what you did.

      You wrote something like


      Code:
      format %tm period_new 
      on the grounds that period_new is a monthly date variable. But Stata's idea of a monthly date variable is strict. It is that 0 indicates January 1960. In your case 0 implies some other date.

      For most purposes mdate would be better for graphing the data than period_new. If you want period_new shown as such, with values 1 up, then take off the monthly date format by assigning

      Code:
      format %4.0f period_new

      Comment


      • #18
        .
        Last edited by Nico Stappen; 13 Oct 2022, 06:01.

        Comment


        • #19
          I can't see the graph in #18. Only a .png attachment will work.

          The option syntax looks right in #18, but #17 implies that period_new is not the best choice here.

          Comment


          • #20
            .
            Last edited by Nico Stappen; 13 Oct 2022, 06:01.

            Comment


            • #21
              Code:
              *Data import*
              
              
              import excel "/Users/nicolasstappen/Desktop/Nico/Studium/Master/5. Semester/Masterarbeit/Daten/all Data in one file nur ab 2019.xlsx", sheet("Trade values") firstrow case(lower)
              
              codebook // entweder nur codebook oder codebook varname
              
              drop classification // no information and/or variation
              drop perioddesc // no info that is not within Period already
              drop reportercode // no information and/or variation
              drop partnercode // no added information
              drop tradeflowcode // no added information
              
              replace tradeflow="exports" if tradeflow=="Exports"
              replace tradeflow="imports" if tradeflow=="Imports"
              replace tradeflow="reimports" if tradeflow=="Re-imports"
              
              replace reporter="united kingdom" if reporter=="United Kingdom"
              
              replace partner = lower(partner)
              
              gen mdate = ym(floor(period/100), mod(period, 100)) 
              gen period_new = mdate - ym(2008, 12)
              
              format %100.0g tradevalueus // um e's wegzubekommen
              
              graph twoway line tradevalueus period_new if tradeflow=="exports" & partner=="belgium", c(L) //

              still gives me a strange graph..
              Click image for larger version

Name:	Bildschirmfoto 2022-10-13 um 14.28.15.png
Views:	1
Size:	495.5 KB
ID:	1685276

              Comment


              • #22
                The strangeness in the graph in #21 could arise for one or both of two reasons:

                1. The observations are out of order. For the graph to be sensible, you need an order in which year varies upwards within blocks of observations for each partner country.

                2. There are missing values in the data.

                If there are other reasons I can't think of them right now, but that just means what it says.

                Either way, further comment requires that you show us the data, namely observations defined by

                Code:
                 
                 dataex tradevalueus period_new if tradeflow=="exports" & partner=="belgium"

                Comment


                • #23
                  I think the data are complete, but probably they are not in order. How could I put them in the right order?

                  ----------------------- copy starting from the next line -----------------------
                  Code:
                  * Example generated by -dataex-. For more info, type help dataex
                  clear
                  input double tradevalueus float period_new
                  1389925243 129
                  1109607898 128
                  1555220225 130
                  1342127516 126
                  1486437485 122
                  1587587248 125
                  1495376569 121
                  1703458074 123
                  1103589216 131
                  1264351333 127
                  1283133285 124
                  1165201243 132
                  1273365175 143
                  1241221182 144
                  1058626805 138
                  1204877695 141
                  1149956896 139
                   817803249 137
                  1394906146 142
                   998034226 140
                  1204468225 135
                  1248488810 134
                  1283858194 133
                   761431299 136
                  1698244185 156
                  1890874478 155
                  1538208377 152
                  1619116915 150
                   850887378 145
                  1709780733 149
                  1773939695 146
                  1716886789 153
                  1528463529 148
                  2058386730 147
                  1835505541 154
                  1748230297 151
                  2004987726 158
                  1435397606 157
                  end
                  ------------------ copy up to and including the previous line ------------------

                  Listed 38 out of 796 observations

                  Comment


                  • #24
                    You see that period_new jumps around, which is why you got the graph you got. As said, you need to sort first on partner country then on the time variable.


                    help sort

                    Comment


                    • #25
                      But is it possible to show a graph which shows the imports and exports of one country (e.g Belgium) over the whole period? I think a bar diagram would be appropriate. So for every period two Bars (1x import, 1x export). X-Axis would be the time. Y-Axis would be the tradevalues. Or am I on the wrong way to get that?

                      Comment


                      • #26
                        The imports and exports of one country could be shown as an intelligible bar chart if (and I guess only if) you work with totals of each for each year.

                        Comment


                        • #27
                          ah okay. Yes the tradevalue data in my data set are the totals of each period, so of each month.
                          But my data is from January 2019 - April 2022. If it could only be shown in yearly bar diagrams it is only 4 periods, 2 bars each (import and export) would be 8 bars in total. That would be clear but maybe a little bit less expressive .
                          If I'd show it in monthly bar diagrams that would be 40 month, 2 bars each, so 80 bars. That would be very expressive but hard to show in one diagram I guess.. Do you have an idea how to solve this?
                          Last edited by Nico Stappen; 13 Oct 2022, 14:08.

                          Comment


                          • #28
                            This problem keeps changing. I think I will sign off this thread with a suggestion to look at help egen to find out how to calculate totals over trade partners, which seems to be what your latest version implies.

                            Comment


                            • #29
                              I think about how to solve it. But I think with your help my graph now looks good.
                              Click image for larger version

Name:	Bildschirmfoto 2022-10-14 um 08.29.43.png
Views:	1
Size:	176.3 KB
ID:	1685405


                              Is there a way to get another colored line into this graph with the imports?
                              And how can I change the x-axis the way that the period isn't from 0-40 but from 01/2019 - 04/2022?

                              Comment

                              Working...
                              X