{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

statawalk2 - Stata Walkthrough Graphics For this...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Stata Walkthrough: Graphics. For this walkthrough, you will need to download the database on US workers in the March 2005 CPS and the one on cod catches. Start with the CPS ( If you have an error loading the database, try typing the command set mem 100m to increase the memory used by Stata. ) Highest educational attainment is a categorical variable, described in six levels: less than high school, some high school, high school, technical or associate’s degree or some college, college degree, and professional or graduate degree. These are captured in the variable educ ( which takes values 1 through 6 ) or equivalently in the dummy variables educ1 through educ6 . The simplest way to illustrate these graphically is through a bar graph or pie graph. The command for the first of these is graph bar educ1-educ6 ( the dash indicates variables educ1 through educ6 , as they are listed in the variable window. ) Try both of these commands. One thing you will notice is that the bar graph returns decimal values. It is telling you the fraction of the sample in each category. This is because the default option for a bar graph is to report the mean of the variable ( and the mean of a dummy variable is the fraction in that group ) . If you want to know the total number in each category, try graph bar (sum) educ1-educ6 You can also specify other descriptive statistics in parentheses after the word bar; check the help files. To construct a pie chart, type graph pie educ1-educ6 This produces a colorful, uninformative pie chart. You can add in additional information:
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
graph pie educ1-educ6, plabel(_all percent) will superimpose the fraction in each category; graph pie educ1-educ6, plabel(_all sum) will tell you the absolute numbers in each group. ( Read the help files for other information that you can superimpose. ) Finally, rather than creating a bunch of dummy variables educ1 through educ6 , you can also the categorical variable educ to produce a pie chart. In this case, you type: graph pie, over(educ) The output is the same, and you can superimpose information in the same way. However, you know that I don’t particularly care for pie charts, since I find that they rarely invite comparisons , which is one principle for good graphics. We can create a bunch of side - by - side pie charts using the command: graph pie educ1-educ6 if race<5, by(race) The option by signals “side - by - side”. Also, note that I’ve added a qualifier to this statement, to include people with race less than 5. In the CPS, the race codes are 1 for Caucasian, 2 for African, 3 for Native American, and 4 for Asian; codes of 5 and
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern