NOTE: To get an idea about different kinds of graph markers type: Title(Per Capita GDP for the Richest Countries) Now, let us create a line graph for the countries with per capita GDP greater than $35,000. To declare the dataset as a panel again, type: To assign numeric values to the string variable country, type: Running the codes gives us an error message as the country variable is strings. To declare the dataset as a panel data, type: Line Graphs by Country Names in Panel Data Setting Twoway connected gdppc gdppc_mean year if country="United States" | ///īy(country, title("GDP pc (PPP, 2005=100)")) /// Let us now generate line graphs for the variables gdppc_mean and gdppc_median for selected countries. Type:īysort year: egen gdppc_median=median(gdppc) Let us create two new variables, gdppc_mean and gdppc_median. We can add more than one line in each of the graphs of a panel graph. Twoway connected gdppc year if gdppc>40000, by(country) msymbol(diamond) Let us now generate a similar graph for the variable gdppc. Legend(label(1 "USA") label(2 "UK") label(3 "Australia") label(4 "Qatar"))) (connected unemp year if country="Qatar", /// (connected unemp year if country="Australia", msymbol(square_hollow)) /// (connected unemp year if country="United Kingdom", msymbol(triangle_hollow)) /// Twoway (connected unemp year if country="United States", msymbol(diamond_hollow)) /// We can present lines for each country above in a single graph. Twoway connected unemp year if country="United States" | ///īy(country, title("Unemployment Rate")) /// In this case, we have to provide the country name and use by country command. We can use Stata's two-way connected command to create separate line graphs for a selected set of countries. Twoway connected unemp unempf unempm year if country="United States", /// We can present the above graph by connecting the lines and adding symbols (circle, diamond, square, etc.) to the lines. Legend(label(1 "Total") label(2 "Females") label(3 "Males")) /// Line unemp unempf unempm year if country="United States", /// Let us add a legend, line pattern, y-axis title, and graph title to make the graph more beautiful. Stata now gives us a better-looking graph. Let us generate the line graph again using the cleaner data. Let us remove zeros for each variable to get a nicer-looking graph. We see each of the variables contains 0% unemployment rates. Let's check the variables more carefully. Stata will give us the following line graph: Line unemp unempf unempm year if country="United States" Generate a line graph for the variables unemp unempf unempm for the United States. Inspect the data to get a better idea about the data. First, open a Stata data file by typing the following codes:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |