Stata 3 Question

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

3 STATA [25 marks]

Wasay Usmani and Shayan Askari


ChatGPT was given the assignment below, and it returned the shared DO File. Your task is to
grade ChatGPT’s work out of 10 by running the DO file and figuring out any mistakes.
As usual, your submission should include a fully functional DO file and a Word document with
answers below each question (20 marks). Make sure to include detailed comments on how well
ChatGPT performed in each part of the assignment in your Word doc (3 marks). Also share two
ideas on how AI technologies can be better trained for such purposes (1 mark). Lastly, suggest
two ways in which the assignment can be rewritten to make it easier for the AI to do the tasks (1
mark).
1. Load data.
a. Load the population data “pop2000” available as an example dataset.

use pop2000, the sysuse pop2000 works better as this is a data set built in in
stata
2. Create new variables.
a. Generate a variable to capture the string length for each observation. Hint: Look
for the appropriate “string function” using the help command. How frequently
does the mode of string length occur? [1 mark]

gen str_len = strlen(string_variable)


This command is wring as it shows that string_variable is not found. We need
to specify this variable
The correct command for this is
gen str_len = 0
replace str_len = strlen( agestr)

b. Construct a new variable which represents the female population in millions. Do


the same for the males. [1 mark]

gen female_population_millions = female / 1000000


gen male_population_millions = male / 1000000
In this Chat GPT takes the wrong variable names as it should be femtotal and
maletotal instead.

3. Visualize results.
a. Make a single graph with bars showing female population in millions for each age
group. Your graph should have the following characteristics:
After running the CHATGPT command for the bar graph, this is what is produced,
which we can see is clearly wrong.

i. The y-axis should read “Female population (millions)”


ii. The x-axis ticks(markers) should have the value label for each age-group.
The labels should be tiny in size and be at a 90 degrees angle to the x-axis.
iii. Which variable should be used for age groups? Why? The variable that
should be used is agegrp since it is the variable that represents the
different age groups in our model.
Export the graph as a png file and paste it below. [3 m

a
rks]
After running the correct commands we were able to get this graph bar after
making changes to what ChatGpt had tried to do.
b. Produce a single graph containing both populations in millions for age-groups for
both males and females. Hint: To avoid overlap, make the male population in
millions negative. Export your graph as a png file and paste below. [2 marks]

The variable name was too long in what chatgpt tried to use and the graph was
incorrect.

c. Generate a new variable called zero which only takes the value of 0.

gen zero = 0

d. As a final step, make a single graph with the following characteristics:


i. The bars are horizontal.
ii. Age groups are scattered about the zero variable and the markers are
invisible except for the age-group value labels.
iii. The bars for female and males are centered at zero on the x-axis.
iv. The x-axis reads “Population in millions”.
v. The x-axis markers read “0” “4” “8” and “12” in both directions about
zero.
vi. The legend shows the gender with males listed first and then females.
vii. The y-axis reads “Age group” and has no other markers. [9 marks]
This is the bar graph that CHATGPT has given which has removed the
values and we can see that it is not correct.
Note: The final output is pasted below but you need to write the code to produce it
in STATA. Paste your graph below for comparison.

After correcting CHATGPT’s command, we were able to get this bar graph.
4. Replicate
a. Create a fully functional DO file of all the commands used in this exercise. Your
DO file should include group number, names of members, date, title, and
comments for each command so that it can be easily read by others. [4 marks]
Have fun!

You might also like