command | [action] |
---|---|
1.1. use file_name | [loads Stata formatted data] |
We will use the current data from the Human Mortality Database. To load the data, type:
    use
command | [action] |
---|---|
2.1. describe | [describes loaded data] |
2.2. sum variable | [summarizes variable] |
2.3. tab variable | [produces 1-way table of variable ] |
To see the countries in the data, type:
    tab
countrycode
command | [action] |
---|---|
3.1. line y-variable x-variable | [creates line graph *line is just one type of graph you can make] |
3.2. twoway (graph_1) (graph_n) | [combine multiple graphs] |
3.3. if | [specifies a conditional statement] |
Now using what we have learned we can summarize total deaths in the US the year before Covid (2019) and make a basic line graph. Type:
    sum
dtotal if
year == 2019 & countrycode==
    set scheme
s1color
    line
dtotal week if
year == 2019 & countrycode==
    twoway
(line
dtotal week if
year == 2019 & countrycode==line
dtotal week if
year == 2020 & countrycode==
Let's add the 5 years prior to covid and the covid years to our graph. Type:
    twoway
(line
dtotal week if
year == 2015 & countrycode==line
dtotal week if
year == 2016 & countrycode==line
dtotal week if
year == 2017 & countrycode==line
dtotal week if
year == 2018 & countrycode==line
dtotal week if
year == 2019 & countrycode==line
dtotal week if
year == 2020 & countrycode==line
dtotal week if
year == 2021 & countrycode==line
dtotal week if
year == 2022 & countrycode==
This is a little difficult to understand. Let's change the non covid years to gray and add a legend so we know which year is which. Type:
    twoway
(line
dtotal week if
year == 2015 & countrycode==line
dtotal week if
year == 2016 & countrycode==line
dtotal week if
year == 2017 & countrycode==line
dtotal week if
year == 2018 & countrycode==line
dtotal week if
year == 2019 & countrycode==line
dtotal week if
year == 2020 & countrycode==line
dtotal week if
year == 2021 & countrycode==line
dtotal week if
year == 2022 & countrycode==
Of course we can make our graph a little prettier. Type:
    twoway
(line
dtotal week if
year == 2015 & countrycode==line
dtotal week if
year == 2016 & countrycode==line
dtotal week if
year == 2017 & countrycode==line
dtotal week if
year == 2018 & countrycode==line
dtotal week if
year == 2019 & countrycode==line
dtotal week if
year == 2020 & countrycode==line
dtotal week if
year == 2021 & countrycode==line
dtotal week if
year == 2022 & countrycode==order
(5
And we can check if things improved in 2023. Type:
    twoway
(line
dtotal week if
year == 2015 & countrycode==line
dtotal week if
year == 2016 & countrycode==line
dtotal week if
year == 2017 & countrycode==line
dtotal week if
year == 2018 & countrycode==line
dtotal week if
year == 2019 & countrycode==line
dtotal week if
year == 2020 & countrycode==line
dtotal week if
year == 2021 & countrycode==line
dtotal week if
year == 2022 & countrycode==line
dtotal week if
year == 2023 & countrycode==order
(5
command | [action] |
---|---|
4.1. display | [displays output - can be used as a calculator] |
4.2. ttesti obs_1 mean_1 sd_1 obs_2 mean_2 sd_2 | [conducts 2-way ttest] |
Let's compare death rates in the US in 2020 (observed) to the averge deaths from 2014-2019 (expected) and test if they are statistically different. Type:
    sum
rtotal if
countrycode ==
    sum
rtotal if
countrycode ==
    ttesti
53 .010187 .0012105 260 .0085809 .0005351
Now we can calculate excess deaths. We just need to multiply the difference in the expected and observed death rate (.001684) by the population 331,002,651. We can use the 95% confidence interval to calculate high and low estimates. Type:
    display
.0016061 * 331002651
    display
.0013999 * 331002651
    display
.0018123 * 331002651
***US reported 375,546 total COVID death on Jan. 1 2021***
Choose a country from the dataset other than the US. Create a graph of your country's weekly deaths from 2015-2022. Answer the questions on the handout. After you finish, type the following into Stata:
    do
"https://eddie-hearn.github.io/teaching/FYS/loop"
Find your country name.log and name.pang in the folder "reports" that will automatically open on your computer. Check your answers.