Search for question
Question

3 Exercise on Stata [25 pts]

To answer this question you are required to use the statistical software Stata. Make sure to create a do file with

your code, an automated log file of your answers from that code, and write down in a separate document your

answers. You are required to submit all three files (i.e., do file, log file, and Word document) before the due date.

Load the dataset nbasal using the bcuse command. The dataset contains data on salaries of NBA players and

individual player statistics.

1. What is the structure of the data? (Cross-section, time series, or panel data) [1 pt]

2. How many players are in the data? [1 pt]

3. How many of the players are centers? [1 pt]

4. What is the average years of experience of all players? [1 pt]

5. What percent of players are forwards? [1 pt]

6. Name all dummy variables in this dataset. [1 pt]

7. How many of the guards are not married? [1 pt]

8. What percentage of forwards are married? [1 pt]

9. Plot a histogram of wage. Does the wage variable look symmetrically distributed? Why is it the case? (Note

that you don't need to paste your graph into your Word document). [3 pts]

10. Find out the average salary by years of experience [Hint: Combine summarize with the prefix bysort] [2 pts]

11. Generate a variable mean_sal_byexper which equals the average salary of players by years of experience, so

that for a given player with 2 years of experience, the variable value will be the average salary for players

with 2 years of experience. [Hint: Combine egen with the prefix bysort] [3 pts]

12. Produce a scatterplot of mean_sal_byexper against exper. Make sure exper is on the x-axis. [2 pts]

13. What is the correlation between wage and exper? [2 pts]

14. Create a discrete variable called position which equals 1 if a player is a guard, 2 if a player is a center, and

3 if a player is a forward. Label this variable as "Player's position" [2 pts]

15. Create a pie chart to illustrate the frequency distribution of the variable position. Make sure to include the

command that indicates the percentages on each slice. Export the graph as .PDF file. [Hint: You will need

to use the plabel (all percent) option in order to display the percentages. In your Word document only

give the commands you use]. [3 pts]