Announcement

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

  • Help Fixing Bar Graph of GDP and Dummy Variables

    Dear all,

    I am using Stata 16, on mac. I used the following command in Stata: reg lnGDP lnagedpop lnpopulation WestCoast EastCoast, robust. All of the data is based on 50 states including D.C. over a span of three years (2016-2018). lnagedpop represents (population that is 65 and older). The dummy variable WestCoast = 1 if the U.S. state is located on the West Coast and 0 if not. Similarly, the dummy variable East Coast = 1 if the U.S. state is located on the East Coast and 0 if not. Midwest is my reference category. I am trying to create a graph based on the regression model I created. I am trying to make a bar graph with lnGDP on the yaxis and the dummy variables West Coast and East Coast on the x-axis. I used the command graph bar (mean) lnGDP, over(WestCoast) over(EastCoast), but my graph doesn't look right. Could someone help me fix my bar graph or maybe have an idea of another graph I could use instead so that it looks better?

    Click image for larger version

Name:	Screen Shot 2019-11-30 at 11.22.31 PM.png
Views:	1
Size:	47.2 KB
ID:	1527015



    Thank you in advance for your help


    Jason Browen

  • #2
    The solution to your specific problem is documented, namely the nofill option of graph bar, Being on the West Coast and the East Coast are mutually exclusive, so you should not be surprised that no state is both (the 1, 1 combination)! See the help.

    But I would never use bar charts together with logarithmic scales. Bars starting at 0, the default as you have in #1, corresponds to a base of 1 in whatever units you are using, here I guess million dollars. That base is at best arbitrary and at worst very confusing or appears confused (a problem for you if you are being graded on this).

    Means of logarithms correspond to geometric means, which you would need to understand and explain.

    In any case you have a distribution, so why restrict yourself to showing means, geometric or otherwise?

    You would get a better graph first with a threefold categorisation, say

    Code:
    gen region = cond(WestCoast == 1, 1, cond(EastCoast == 1, 3, 2)) 
    label def region 1 West 2 "middle"  3 East 
    label val region region
    As a geographer, although neither US citizen nor resident, I am puzzled by the implication that every state not on the west coast or east coast is in the Midwest. Arizona? Nevada? Utah? etc. But call it what you wish.

    I would then use dotplot or stripplot (SSC) to show distributions. You don't show your data, but one of Stata's datasets allows some technique to be shown.

    Here is some syntax you can follow:

    Code:
    sysuse census, clear
    
    ssc install stripplot 
    
    * needed for call to gmean() function 
    ssc install egenmore 
    
    stripplot pop, over(region) ysc(log) center cumul cumprob refline reflevel(gmean) vertical scheme(s1color) yla(5e5 "0.5" 1e6 "1" 2e6 "2" 5e6 "5" 1e7 "10" 2e7 "20", ang(h)) ytitle("Population (m)") xla(, noticks) note(lines show geometric means)
    Showing means alone is far from fully informative. For example, in 1980, the date of this dataset, the largest and smallest states in terms of population were both in the West. Rankings have changed in some details since then, but variability remains strong,

    Click image for larger version

Name:	browen.png
Views:	1
Size:	26.2 KB
ID:	1527025

    Comment


    • #3
      Thank you so much for your help Nick! I completely agree with what you have said and now have the dummy variables south, midwest, west, and northeast. Is there a way you could help me categorize these into the variable region? I am not sure how to do this since I now have four dummy variables.

      Comment


      • #4
        You already have code in #2 which can be adapted.

        Code:
        gen region = cond(northeast == 1, 1, cond(midwest == 1, 2,  cond(south == 1, 3, 4)))
        Other ways to do it too.

        Comment


        • #5
          Thank you so much Nick, I greatly appreciate your time and efforts!

          Comment

          Working...
          X