<class 'pandas.core.frame.DataFrame'>
RangeIndex: 117670 entries, 0 to 117669
Data columns (total 62 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 iso_code 117670 non-null object
1 continent 112290 non-null object
2 location 117670 non-null object
3 date 117670 non-null datetime64[ns]
4 total_cases 111883 non-null float64
5 new_cases 111880 non-null float64
6 new_cases_smoothed 110865 non-null float64
7 total_deaths 101201 non-null float64
8 new_deaths 101356 non-null float64
9 new_deaths_smoothed 110865 non-null float64
10 total_cases_per_million 111293 non-null float64
11 new_cases_per_million 111290 non-null float64
12 new_cases_smoothed_per_million 110280 non-null float64
13 total_deaths_per_million 100624 non-null float64
14 new_deaths_per_million 100779 non-null float64
15 new_deaths_smoothed_per_million 110280 non-null float64
16 reproduction_rate 94434 non-null float64
17 icu_patients 13337 non-null float64
18 icu_patients_per_million 13337 non-null float64
19 hosp_patients 15309 non-null float64
20 hosp_patients_per_million 15309 non-null float64
21 weekly_icu_admissions 1177 non-null float64
22 weekly_icu_admissions_per_million 1177 non-null float64
23 weekly_hosp_admissions 2144 non-null float64
24 weekly_hosp_admissions_per_million 2144 non-null float64
25 new_tests 51051 non-null float64
26 total_tests 50905 non-null float64
27 total_tests_per_thousand 50905 non-null float64
28 new_tests_per_thousand 51051 non-null float64
29 new_tests_smoothed 60501 non-null float64
30 new_tests_smoothed_per_thousand 60501 non-null float64
31 positive_rate 57240 non-null float64
32 tests_per_case 56614 non-null float64
33 tests_units 62379 non-null object
34 total_vaccinations 25855 non-null float64
35 people_vaccinated 24726 non-null float64
36 people_fully_vaccinated 21723 non-null float64
37 total_boosters 2290 non-null float64
38 new_vaccinations 21401 non-null float64
39 new_vaccinations_smoothed 46078 non-null float64
40 total_vaccinations_per_hundred 25855 non-null float64
41 people_vaccinated_per_hundred 24726 non-null float64
42 people_fully_vaccinated_per_hundred 21723 non-null float64
43 total_boosters_per_hundred 2290 non-null float64
44 new_vaccinations_smoothed_per_million 46078 non-null float64
45 stringency_index 97416 non-null float64
46 population 116866 non-null float64
47 population_density 108804 non-null float64
48 median_age 104015 non-null float64
49 aged_65_older 102857 non-null float64
50 aged_70_older 103444 non-null float64
51 gdp_per_capita 104601 non-null float64
52 extreme_poverty 70245 non-null float64
53 cardiovasc_death_rate 104316 non-null float64
54 diabetes_prevalence 107469 non-null float64
55 female_smokers 81469 non-null float64
56 male_smokers 80285 non-null float64
57 handwashing_facilities 52401 non-null float64
58 hospital_beds_per_thousand 94870 non-null float64
59 life_expectancy 111623 non-null float64
60 human_development_index 104407 non-null float64
61 excess_mortality 4007 non-null float64
dtypes: datetime64[ns](1), float64(57), object(4)
memory usage: 55.7+ MB
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 612 entries, 2020-01-16 to 2021-09-18
Data columns (total 62 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 iso_code 612 non-null object
1 continent 612 non-null object
2 location 612 non-null object
3 date 612 non-null datetime64[ns]
4 total_cases 606 non-null float64
5 new_cases 605 non-null float64
6 new_cases_smoothed 600 non-null float64
7 total_deaths 581 non-null float64
8 new_deaths 581 non-null float64
9 new_deaths_smoothed 600 non-null float64
10 total_cases_per_million 606 non-null float64
11 new_cases_per_million 605 non-null float64
12 new_cases_smoothed_per_million 600 non-null float64
13 total_deaths_per_million 581 non-null float64
14 new_deaths_per_million 581 non-null float64
15 new_deaths_smoothed_per_million 600 non-null float64
16 reproduction_rate 545 non-null float64
17 icu_patients 0 non-null float64
18 icu_patients_per_million 0 non-null float64
19 hosp_patients 0 non-null float64
20 hosp_patients_per_million 0 non-null float64
21 weekly_icu_admissions 0 non-null float64
22 weekly_icu_admissions_per_million 0 non-null float64
23 weekly_hosp_admissions 0 non-null float64
24 weekly_hosp_admissions_per_million 0 non-null float64
25 new_tests 608 non-null float64
26 total_tests 608 non-null float64
27 total_tests_per_thousand 608 non-null float64
28 new_tests_per_thousand 608 non-null float64
29 new_tests_smoothed 602 non-null float64
30 new_tests_smoothed_per_thousand 602 non-null float64
31 positive_rate 597 non-null float64
32 tests_per_case 576 non-null float64
33 tests_units 609 non-null object
34 total_vaccinations 150 non-null float64
35 people_vaccinated 146 non-null float64
36 people_fully_vaccinated 78 non-null float64
37 total_boosters 0 non-null float64
38 new_vaccinations 126 non-null float64
39 new_vaccinations_smoothed 180 non-null float64
40 total_vaccinations_per_hundred 150 non-null float64
41 people_vaccinated_per_hundred 146 non-null float64
42 people_fully_vaccinated_per_hundred 78 non-null float64
43 total_boosters_per_hundred 0 non-null float64
44 new_vaccinations_smoothed_per_million 180 non-null float64
45 stringency_index 591 non-null float64
46 population 612 non-null float64
47 population_density 0 non-null float64
48 median_age 612 non-null float64
49 aged_65_older 0 non-null float64
50 aged_70_older 612 non-null float64
51 gdp_per_capita 0 non-null float64
52 extreme_poverty 0 non-null float64
53 cardiovasc_death_rate 612 non-null float64
54 diabetes_prevalence 0 non-null float64
55 female_smokers 0 non-null float64
56 male_smokers 0 non-null float64
57 handwashing_facilities 0 non-null float64
58 hospital_beds_per_thousand 0 non-null float64
59 life_expectancy 612 non-null float64
60 human_development_index 0 non-null float64
61 excess_mortality 50 non-null float64
dtypes: datetime64[ns](1), float64(57), object(4)
memory usage: 301.2+ KB
QUESTION 1
1. Pick a country and evaluate the Covid19 situation in the country.
Answer to Question 1:
In this question, we are evaluating Taiwan's Covid19 situation. As we can see from the graph, the spike of Covid19 happens in late May 2021 and lasts till July 2021. It all started with a case outbreak caused by a tested positive pilot. We can assume that a positive outbreak is a direct result from the accidental release of the virus from a confined person. We believe had this not happened then the country's outbreak wouldn't have happened, and therefore the spike in cases, and subsequent deaths would have been avoided.
Overall, there are not many death cases, and the death cases only have its spike as the new cases increased in May. Moreover, by plotting the new vaccination in Taiwan, we can see more and more people are taking vaccination after the rise in Covid19 cases. Also, from the plot, we can imply that the vaccination actually help cease the new cases. we must still be on alert as studies have shown that people with the vaccine are in some instances more likely to get the disease in a variant, however, it shouldn't be as bad and their effects will be 'supposedly' in a lesser manner.
Here we plot the new cases, new deaths, and new vaccination of the world. We can see that compared to the world's new cases, Taiwan's new cases are relatively low and seem controllable. However, the vaccination level of Taiwan is also low compared to the world. This is caused by a vaccine shortage in Taiwan.
QUESTION 2
2. Evaluate the potential hidden cases (e.g., case positivity rate) and deaths (e.g., estimated infection fatality rate, excess death).
35
Average World Positivity: 9.666241669295307
Average Taiwan Case Positivity: 0.6732414990403995
Benchmark Case Positivity Rate: 0.2669669703303415
Here we compare the average world positivity, benchmark positivity, and the case positivity in Taiwan. Taiwan appears to be well below the average world positivity rate of 9.66% with only 0.67%. However, above the benchmark positivity rate 0.26%. So, we conclude that there aren't much hidden cases in Taiwan, given the enough number of tested people country can reflect a more accurate positivity rate.
Average World Fatality: 2.7610901620719646
Average Taiwan Fatality: 1.9360694249456274
Benchmark Fatality Rate: 2.1652237114269783
Here we compare the average world fatality, benchmark infection fatality, and the case fatality in Taiwan. Taiwan appears to be below the average world fatality rate of 2.76% and benchmark fatality of 2.17% with only 1.92%. There could be potential hidden death due to the disparity in the fatality rate. Yet, shouldn't be much since 1.92% isn't far from 2.17%.
60.55249569707401
There is a big gap between the fatality before 7.63 and after 60.76 Covid19 in Taiwan. So, we can infer that there is not much hidden death in Taiwan.
There seems to be positive correlation between the case fatality and the spread of the infection as seen in the regression above. The line plot below also suggests the same, where increases in the case positivity have been followed by increases in case fatality. We can infer from the graph that the community spread has a relationship with fatality. Taiwan has also started vaccinating its residents long after the world began rolling out vaccines. This is because there are not enough capacity in health care and medical centers in Taiwan when it comes to community spread with many people ending up in severe cases and need a lot of medical resources. Since the vaccination rate is low, so the likelihood for patients to be in severe case is higher and need more medical capacity.
We also can see from the graph that, once the vaccination rate in creases, the death rate lowers.
Here, we see a positive correlation between the total tests taken and the total cases. The more total_tests, the more likely we are going to capture more Covid19 cases. However, there is a diminishing return effect. When total_test reaches 3 million, it seems that the more tests taken wouldn't help much in capturing more cases since most cases are already identified. As a result, when we set the benchmark country, we use a positivity rate that's below 0.5% (15000 cases/ 3000000 tests).
QUESTION 3
3. Explore the relationship between the country's Covid19 cases and deaths and government health intervention policies (e.g., vaccination rate, closure), as well as Google community mobility reports.
The Stringency Index measures the strictness go government intervention policies but doesn't imply the effectiveness or appropriateness of the country's response. The graph for the index remains flat in many areas indicating that the index has remained the same and new cases, new deaths have remained low. We can infer that the government intervention is taking effect. However, recently there has been a huge spike and outbreak in the number of Covid19 cases in Taiwan in May 2021. The Stringency Index had increased right away to reflect this spike from an average of about 30 to 70. Given that the number of cases have fallen, it can be understood that the Government's quick Intervention reflected by the Index has played a part in this decrease.
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 575 entries, 2020-02-15 to 2021-09-11
Data columns (total 79 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 country_region_code 575 non-null object
1 country_region 575 non-null object
2 sub_region_1 0 non-null float64
3 sub_region_2 0 non-null float64
4 metro_area 0 non-null float64
5 iso_3166_2_code 0 non-null float64
6 census_fips_code 0 non-null float64
7 place_id 575 non-null object
8 date_x 575 non-null object
9 retail_and_recreation_percent_change_from_baseline 575 non-null int64
10 grocery_and_pharmacy_percent_change_from_baseline 575 non-null int64
11 parks_percent_change_from_baseline 575 non-null int64
12 transit_stations_percent_change_from_baseline 575 non-null int64
13 workplaces_percent_change_from_baseline 575 non-null int64
14 residential_percent_change_from_baseline 575 non-null int64
15 iso_code 575 non-null object
16 continent 575 non-null object
17 location 575 non-null object
18 date_y 575 non-null datetime64[ns]
19 total_cases 575 non-null float64
20 new_cases 575 non-null float64
21 new_cases_smoothed 575 non-null float64
22 total_deaths 574 non-null float64
23 new_deaths 574 non-null float64
24 new_deaths_smoothed 575 non-null float64
25 total_cases_per_million 575 non-null float64
26 new_cases_per_million 575 non-null float64
27 new_cases_smoothed_per_million 575 non-null float64
28 total_deaths_per_million 574 non-null float64
29 new_deaths_per_million 574 non-null float64
30 new_deaths_smoothed_per_million 575 non-null float64
31 reproduction_rate 542 non-null float64
32 icu_patients 0 non-null float64
33 icu_patients_per_million 0 non-null float64
34 hosp_patients 0 non-null float64
35 hosp_patients_per_million 0 non-null float64
36 weekly_icu_admissions 0 non-null float64
37 weekly_icu_admissions_per_million 0 non-null float64
38 weekly_hosp_admissions 0 non-null float64
39 weekly_hosp_admissions_per_million 0 non-null float64
40 new_tests 575 non-null float64
41 total_tests 575 non-null float64
42 total_tests_per_thousand 575 non-null float64
43 new_tests_per_thousand 575 non-null float64
44 new_tests_smoothed 575 non-null float64
45 new_tests_smoothed_per_thousand 575 non-null float64
46 positive_rate 575 non-null float64
47 tests_per_case 554 non-null float64
48 tests_units 575 non-null object
49 total_vaccinations 144 non-null float64
50 people_vaccinated 140 non-null float64
51 people_fully_vaccinated 72 non-null float64
52 total_boosters 0 non-null float64
53 new_vaccinations 121 non-null float64
54 new_vaccinations_smoothed 174 non-null float64
55 total_vaccinations_per_hundred 144 non-null float64
56 people_vaccinated_per_hundred 140 non-null float64
57 people_fully_vaccinated_per_hundred 72 non-null float64
58 total_boosters_per_hundred 0 non-null float64
59 new_vaccinations_smoothed_per_million 174 non-null float64
60 stringency_index 561 non-null float64
61 population 575 non-null float64
62 population_density 0 non-null float64
63 median_age 575 non-null float64
64 aged_65_older 0 non-null float64
65 aged_70_older 575 non-null float64
66 gdp_per_capita 0 non-null float64
67 extreme_poverty 0 non-null float64
68 cardiovasc_death_rate 575 non-null float64
69 diabetes_prevalence 0 non-null float64
70 female_smokers 0 non-null float64
71 male_smokers 0 non-null float64
72 handwashing_facilities 0 non-null float64
73 hospital_beds_per_thousand 0 non-null float64
74 life_expectancy 575 non-null float64
75 human_development_index 0 non-null float64
76 excess_mortality 46 non-null float64
77 case_positivity 575 non-null float64
78 case_fatality 574 non-null float64
dtypes: datetime64[ns](1), float64(64), int64(6), object(8)
memory usage: 359.4+ KB
Upon comparing the changes in retail, parks and grocery with the case positivity, the recent sudden spike in cases have been met by a fall in grocery and pharmaceutical runs, parks and retail and recreation. This may be due to voluntary avoidance by the residents of Taiwan. But a portion of it can also be attributed to restrictions imposed by the government as indicated by the stringency levels which increased during this period. Taiwan immediately went into level 3 soft lock down right after the outbreak of cases in May 2021.
Upon comparing the changes in residential, workplace and transit stations with the case positivity, the recent sudden spike in cases have been met by a surprising rise in the residential percentage. There has however been a fall in the workspaces and the transit stations. As see above this could be due to higher stringency levels and imposition of lockdowns.
Overall we can say the government reacted pretty fast in leveling up the restriction after the Covid19 outbreak, and Taiwanese also tighten their mobility according to the policy. We observe the decrease of cases right after that.
LAB 5
Industries:
[*********************100%***********************] 7 of 7 completed
Collecting PyPortfolioOpt==1.2.1
Downloading PyPortfolioOpt-1.2.1-py3-none-any.whl (49 kB)
|████████████████████████████████| 49 kB 11.6 MB/s
Requirement already satisfied: numpy in /shared-libs/python3.7/py/lib/python3.7/site-packages (from PyPortfolioOpt==1.2.1) (1.19.5)
Requirement already satisfied: scipy in /shared-libs/python3.7/py/lib/python3.7/site-packages (from PyPortfolioOpt==1.2.1) (1.7.1)
Collecting cvxpy<2.0.0,>=1.0.28
Downloading cvxpy-1.1.15-cp37-cp37m-manylinux_2_24_x86_64.whl (2.7 MB)
|████████████████████████████████| 2.7 MB 53.5 MB/s
Collecting pandas<0.26.0,>=0.25.3
Downloading pandas-0.25.3-cp37-cp37m-manylinux1_x86_64.whl (10.4 MB)
|████████████████████████████████| 10.4 MB 49.5 MB/s
Collecting scs>=1.1.6
Downloading scs-2.1.4.tar.gz (6.6 MB)
|████████████████████████████████| 6.6 MB 64.2 MB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Collecting ecos>=2
Downloading ecos-2.0.7.post1-cp37-cp37m-manylinux1_x86_64.whl (147 kB)
|████████████████████████████████| 147 kB 77.2 MB/s
Collecting osqp>=0.4.1
Downloading osqp-0.6.2.post0-cp37-cp37m-manylinux2014_x86_64.whl (212 kB)
|████████████████████████████████| 212 kB 79.3 MB/s
Collecting qdldl
Downloading qdldl-0.1.5.post0-cp37-cp37m-manylinux2014_x86_64.whl (941 kB)
|████████████████████████████████| 941 kB 60.7 MB/s
Requirement already satisfied: python-dateutil>=2.6.1 in /shared-libs/python3.7/py-core/lib/python3.7/site-packages (from pandas<0.26.0,>=0.25.3->PyPortfolioOpt==1.2.1) (2.8.2)
Requirement already satisfied: pytz>=2017.2 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from pandas<0.26.0,>=0.25.3->PyPortfolioOpt==1.2.1) (2021.1)
Requirement already satisfied: six>=1.5 in /shared-libs/python3.7/py-core/lib/python3.7/site-packages (from python-dateutil>=2.6.1->pandas<0.26.0,>=0.25.3->PyPortfolioOpt==1.2.1) (1.16.0)
Building wheels for collected packages: scs
Building wheel for scs (PEP 517) ... done
Created wheel for scs: filename=scs-2.1.4-cp37-cp37m-linux_x86_64.whl size=113462 sha256=cfe45cf2093f5528be232905b1e9f3b45e1ad107e7b50857347a1b6ee60e32f8
Stored in directory: /root/.cache/pip/wheels/d6/58/0b/a55ff6d4e2da4c9776e363a778ea13e4068037a7be82eb85e0
Successfully built scs
Installing collected packages: qdldl, scs, osqp, ecos, pandas, cvxpy, PyPortfolioOpt
Attempting uninstall: pandas
Found existing installation: pandas 1.2.5
Not uninstalling pandas at /shared-libs/python3.7/py/lib/python3.7/site-packages, outside environment /root/venv
Can't uninstall 'pandas'. No files were found to uninstall.
Successfully installed PyPortfolioOpt-1.2.1 cvxpy-1.1.15 ecos-2.0.7.post1 osqp-0.6.2.post0 pandas-0.25.3 qdldl-0.1.5.post0 scs-2.1.4
WARNING: You are using pip version 21.2.3; however, version 21.2.4 is available.
You should consider upgrading via the '/root/venv/bin/python -m pip install --upgrade pip' command.
TSM 0
TLC 594
BNTX 815
CHT 0
ASX 0
UMC 0
EWT 0
dtype: int64
ASX 0.195913
BNTX 2.256440
CHT 0.064080
EWT 0.199110
TLC 0.370357
TSM 0.369458
UMC 0.462993
dtype: float64
ASX BNTX CHT EWT TLC TSM UMC
ASX 0.135827 0.046578 0.015103 0.049189 0.035185 0.065884 0.063968
BNTX 0.046578 1.300404 0.017043 0.025382 0.031571 0.058421 0.052941
CHT 0.015103 0.017043 0.012803 0.012473 0.007097 0.012878 0.009698
EWT 0.049189 0.025382 0.012473 0.040825 0.029105 0.047660 0.038566
TLC 0.035185 0.031571 0.007097 0.029105 0.632766 0.039781 0.021155
TSM 0.065884 0.058421 0.012878 0.047660 0.039781 0.093203 0.058008
UMC 0.063968 0.052941 0.009698 0.038566 0.021155 0.058008 0.157886
QUESTION 1
1. Based on your investment strategy (i.e., chosen stocks, industries, asset classes), identify the maximum Sharpe ratio and minimum volatility portfolios.
{'ASX': -0.32434, 'BNTX': 0.33452, 'CHT': -0.21005, 'EWT': 0.30105, 'TLC': 0.06969, 'TSM': 0.43368, 'UMC': 0.39544}
Maximum Shape Ratio Portfolio {'ASX': -0.32434, 'BNTX': 0.33452, 'CHT': -0.21005, 'EWT': 0.30105, 'TLC': 0.06969, 'TSM': 0.43368, 'UMC': 0.39544}.
QUESTION 2
2. If you have USD 1 million now, how much should you invest in each?
{'TSM': 2305, 'UMC': 21548, 'BNTX': 651, 'EWT': 3010, 'TLC': 6343, 'ASX': -20119, 'CHT': -2952}
Leftover Fund value for the maximum Sharpe portfolio is $129.66
Out of the $1000000 available for allocation, the amounts have been invested in the stocks as shown above. The leftover fund in the maximum Sharpe portfolio is $69.73. The portfolio indicates that we short the stocks of ASX a tech company and CHT a telecom company.
QUESTION 3
3. Plot a graph showing how your portfolios (maximum Sharpe and minimum volatility portfolios) perform relative to the market (i.e., SPY)
QUESTION 1
1. Calculate the Minimum Volatility Portfolio
{'ASX': -0.03946, 'BNTX': -0.0034, 'CHT': 0.97866, 'EWT': 0.03672, 'TLC': 0.00927, 'TSM': -0.01263, 'UMC': 0.03084}
For our MVP we calculated that we need a majority of CHT for our portfolio, along with smaller amounts EWT, UMC, TLC. We had to short stocks for TSM, BNTX, and ASX for the portfolio as well.
{'CHT': 23215, 'EWT': 533, 'UMC': 2443, 'TLC': 1227, 'ASX': -23573, 'TSM': -557, 'BNTX': -54}
Leftover Fund value for the maximum Sharpe portfolio is $348.54
As per MVP, the funds are allocated as shown above. We short the stocks of ASX a tech company, TSM a semi-conductor manufacturing company and BNTX a pharma company. The leftover fund for the maximum Sharpe portfolio is now $102.48.
QUESTION 4
4. Comment on your strategy note and highlight the potential future issues/risks.
We chose to diversify our portfolio by choosing Taiwanese stocks or companies critical to Taiwan traded in USD. The portfolio comprises stocks of TSM, an electricity manufacturing company; TLC and BNTX pharma companies; CHT in the telecom industry; and ASX a tech & hardware manufacturing company; and UMC a tech company. The market index we chose is EWT which comprises of the top 85% of Taiwanese companies.
The sharpe portfolio helps provide the weights of each stock. TSM appears to be the largest by weight with us shorting ASX. Based on our observation of the covid situation in Taiwan, we believe that technology sector represents the strongest growth in the Taiwan economy. As a result we take portfolio is consisting to take the advantage of technology sector. As our portfolio is tech sector weighted heavy, We choose to put CHT(Taiwan Telecom Company) in our portfolio to reduce the risk variance of our portfolio. As CHT is in defense industry(Telecom), it will add diversification in our portfolio. As a result we take advantage of the technology sector. Although shorting could be inherently volatile, it could help the portfolio in long-term risk exposure.
The potential qualitative risk will be global competition on semiconductor, the rising shortage on semiconductor and competition in manufacture in future.