Collecting statsmodels
Downloading statsmodels-0.13.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.8 MB)
|████████████████████████████████| 9.8 MB 36.0 MB/s
Requirement already satisfied: scipy>=1.3 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from statsmodels) (1.7.1)
Collecting patsy>=0.5.2
Downloading patsy-0.5.2-py2.py3-none-any.whl (233 kB)
|████████████████████████████████| 233 kB 46.8 MB/s
Requirement already satisfied: numpy>=1.17 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from statsmodels) (1.19.5)
Requirement already satisfied: pandas>=0.25 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from statsmodels) (1.2.5)
Requirement already satisfied: pytz>=2017.3 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from pandas>=0.25->statsmodels) (2021.1)
Requirement already satisfied: python-dateutil>=2.7.3 in /shared-libs/python3.7/py-core/lib/python3.7/site-packages (from pandas>=0.25->statsmodels) (2.8.2)
Requirement already satisfied: six in /shared-libs/python3.7/py-core/lib/python3.7/site-packages (from patsy>=0.5.2->statsmodels) (1.16.0)
Installing collected packages: patsy, statsmodels
Successfully installed patsy-0.5.2 statsmodels-0.13.0
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 121036 entries, 0 to 121035
Data columns (total 65 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 iso_code 121036 non-null object
1 continent 115521 non-null object
2 location 121036 non-null object
3 date 121036 non-null datetime64[ns]
4 total_cases 114912 non-null float64
5 new_cases 114909 non-null float64
6 new_cases_smoothed 113894 non-null float64
7 total_deaths 104123 non-null float64
8 new_deaths 104278 non-null float64
9 new_deaths_smoothed 113894 non-null float64
10 total_cases_per_million 114307 non-null float64
11 new_cases_per_million 114304 non-null float64
12 new_cases_smoothed_per_million 113294 non-null float64
13 total_deaths_per_million 103531 non-null float64
14 new_deaths_per_million 103686 non-null float64
15 new_deaths_smoothed_per_million 113294 non-null float64
16 reproduction_rate 97393 non-null float64
17 icu_patients 13700 non-null float64
18 icu_patients_per_million 13700 non-null float64
19 hosp_patients 15745 non-null float64
20 hosp_patients_per_million 15745 non-null float64
21 weekly_icu_admissions 1254 non-null float64
22 weekly_icu_admissions_per_million 1254 non-null float64
23 weekly_hosp_admissions 2155 non-null float64
24 weekly_hosp_admissions_per_million 2155 non-null float64
25 new_tests 51915 non-null float64
26 total_tests 51988 non-null float64
27 total_tests_per_thousand 51988 non-null float64
28 new_tests_per_thousand 51915 non-null float64
29 new_tests_smoothed 62362 non-null float64
30 new_tests_smoothed_per_thousand 62362 non-null float64
31 positive_rate 59043 non-null float64
32 tests_per_case 58403 non-null float64
33 tests_units 64281 non-null object
34 total_vaccinations 27778 non-null float64
35 people_vaccinated 26421 non-null float64
36 people_fully_vaccinated 23387 non-null float64
37 total_boosters 2970 non-null float64
38 new_vaccinations 23013 non-null float64
39 new_vaccinations_smoothed 49593 non-null float64
40 total_vaccinations_per_hundred 27778 non-null float64
41 people_vaccinated_per_hundred 26421 non-null float64
42 people_fully_vaccinated_per_hundred 23387 non-null float64
43 total_boosters_per_hundred 2970 non-null float64
44 new_vaccinations_smoothed_per_million 49593 non-null float64
45 stringency_index 100934 non-null float64
46 population 120175 non-null float64
47 population_density 111880 non-null float64
48 median_age 106841 non-null float64
49 aged_65_older 105653 non-null float64
50 aged_70_older 106255 non-null float64
51 gdp_per_capita 107480 non-null float64
52 extreme_poverty 72105 non-null float64
53 cardiovasc_death_rate 107125 non-null float64
54 diabetes_prevalence 110454 non-null float64
55 female_smokers 83635 non-null float64
56 male_smokers 82421 non-null float64
57 handwashing_facilities 53826 non-null float64
58 hospital_beds_per_thousand 97396 non-null float64
59 life_expectancy 114786 non-null float64
60 human_development_index 107218 non-null float64
61 excess_mortality_cumulative_absolute 4129 non-null float64
62 excess_mortality_cumulative 4129 non-null float64
63 excess_mortality 4275 non-null float64
64 excess_mortality_cumulative_per_million 4129 non-null float64
dtypes: datetime64[ns](1), float64(60), object(4)
memory usage: 60.0+ MB
Here we compare the Stringency Index from the Covid dataset with the case positivity and the case fatality rate.
/shared-libs/python3.7/py/lib/python3.7/site-packages/seaborn/_decorators.py:43: FutureWarning:
Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
/shared-libs/python3.7/py/lib/python3.7/site-packages/seaborn/_decorators.py:43: FutureWarning:
Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
/shared-libs/python3.7/py/lib/python3.7/site-packages/seaborn/_decorators.py:43: FutureWarning:
Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
According to the graph above, every spike in the case positivity and fatality is being met by an increase in the stringency index. From the graph it appears as though there is a fall in the case positivity and fatality after the implementation of government measures. However we look further into the actual impact of these measures on the covid cases down below.
We regress the total cases on the stringency index to see if government interventions have caused any impact on Covid 19.
1187 8339841.0
1188 8339841.0
1189 8339841.0
1190 8339841.0
1191 8339841.0
...
121031 130485.0
121032 130820.0
121033 131028.0
121034 131094.0
121035 131129.0
Name: total_cases, Length: 112489, dtype: float64
/shared-libs/python3.7/py/lib/python3.7/site-packages/seaborn/_decorators.py:43: FutureWarning:
Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
/shared-libs/python3.7/py/lib/python3.7/site-packages/seaborn/_decorators.py:43: FutureWarning:
Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation.
This regression shows that the stringency and the total cases is positively correlated, wh=ith there being a rise in stringency post a rise in total cases and vice versa.
Results: Ordinary least squares
====================================================================
Model: OLS Adj. R-squared: 0.005
Dependent Variable: log_total_cases AIC: 587493.5520
Date: 2021-10-05 06:12 BIC: 587512.8132
No. Observations: 112489 Log-Likelihood: -2.9374e+05
Df Model: 1 F-statistic: 611.3
Df Residuals: 112487 Prob (F-statistic): 1.31e-134
R-squared: 0.005 Scale: 10.857
---------------------------------------------------------------------
Coef. Std.Err. t P>|t| [0.025 0.975]
---------------------------------------------------------------------
const 9.5342 0.0298 320.3846 0.0000 9.4758 9.5925
stringency_index 0.0123 0.0005 24.7254 0.0000 0.0113 0.0132
--------------------------------------------------------------------
Omnibus: 1358.257 Durbin-Watson: 0.020
Prob(Omnibus): 0.000 Jarque-Bera (JB): 1407.651
Skew: -0.273 Prob(JB): 0.000
Kurtosis: 3.057 Condition No.: 182
====================================================================
#OLS Interpretation: Here we take the total cases to be the dependent variable which is log transformed. To identify the percentage increase or decrease we exponentiate the coefficient, subtract one from this number, and multiply by 100. The coefficient is (e^(0.0123)-1) * 100 =1.24%. Therefore, the increase in the stringency index has actually seen a rise in the total cases by 1.24% rather than a fall. Every rise in the total number of cases is being met by an increase in government measures. This does however lead to a fall in the covid cases in the next few periods as identified earlier.
We are seeing a positive coefficient for the stringency. We inferred that this is the result from the fact that policies tightening the government restriction usually come in place right after a spike in total case. Therefore, we see a positive correlation between the 2. Although we have used the log of the total cases as the dependent variable, it appears as though the stringency index is dependent on the number of cases.
/root/venv/lib/python3.7/site-packages/statsmodels/graphics/gofplots.py:1045: UserWarning:
color is redundantly defined by the 'color' keyword argument and the fmt string "b" (-> color=(0.0, 0.0, 1.0, 1)). The keyword argument will take precedence.