Program code (SageMath, Python)
# An estimate of vaccination duration using linear regression
# Inputs:
# pop - population size (default 5466000)
# vac - percentage of vacctination (default 60)
# dose - number of doses (default 2)
# data - from 06.01.2021 to 11.02.2021
# region - Slovakia, EU, UK, World
#
# Slovakia population: 5466000
# [(6,6618),(13,46243),(20,85957),(27,121245),(34,178442),(42,268844)]
# EU population: 445561000
# Data= [(1,1477853),(7,4093497),(14,7141406),(20,10762226),(27,14888339), (42,19628190)]
# UK population: 67969000
# Data= [(10,2677971),(17,4514802),(24,7044048),(31,9790576),(38,12806587), (47,16499549)]
# World population: 7809575000
# [(6,16326929),(13,35780021),(20,54315120),(27,82980899),(34,115614565),(42,160070774)]
# Note: input data can be modificated
# Source: https://github.com/owid/covid-19-data/blob/master/public/data/vaccinations/vaccinations.csv
# linear regression: https://www.oxfordreference.com/view/10.1093/oi/authority.20110803100107226
# Algorithm: based on input data application of a linear regression model
# The program can also be run at: https://sagecell.sagemath.org/
# To run - paste the source code into the Sagecell box
#
# February 24, 2021 Peter Szabó, Miroslava Ferencová - updated
# auxiliary function for calculating the date
def den(i):
# calculating the date, valid only in January and February 2021,
if (i<32): s=str(i)+"th January 2021"
if (i>31) and (i<59): s=str(i-31)+"th February 2021"
return s
# the main program
@interact
def imunita(
pop = input_box(default=5466000, label="Population" ),
vac = slider(vmin=1, vmax=100, step_size=1, default=60, label="Percentage"),
dose = ("two doses", true),
data = input_box(default =[(6,6618),(13,46243),(20,85957),(27,121245),(34,178442),(42,268844),(47,322162),(54,394790)], label="Vaccinated"),
reg = selector(['Slovakia', 'European Union', 'United Kingdom','World'],buttons=True, label="Region" )):
if reg == 'European Union':
data = [(1,1477853),(7,4093497),(14,7141406),(20,10762226),(27,14888339),(42,19628190), (47,23113359), (54,28262415)]
pop = 445561000
if reg == 'United Kingdom':
data = [(10,2677971),(17,4514802),(24,7044048),(31,9790576),(38,12806587), (47,16499549), (53,18558969)]
pop = 67969000
if reg == 'World':
data = [(6,16326929),(13,35780021),(20,54315120),(27,82980899),(34,115614565),(42,160070774),(47,184585643),(54,216167273)]
pop = 7809575000
# Linear regression
# x - days, y - the number of vaccinated
var("a,b")
model(x) = a*x+b
a1=find_fit(data,model)[0].rhs()
b1=find_fit(data,model)[1].rhs()
n = len(data)-1
# input data and linear regression
p = scatter_plot(data,frame=True, gridlines=True)
p += plot(a1*x+b1, (x,data[0][0],data[n][0]), color = "blue", thickness = 2, axes_labels =[ "Days","Vaccinated"],
title="Regression analysis - Calculation of vaccination time")
p.show()
# Estimation of vaccination time , calculation of vaccination
poc=pop*vac/100
if dose : poc=2*poc
# Number of days(x) based on regression line y= a1*x+b1, x=(y-b1)/a1
dni=round((poc-b1)/a1)
# Calculation of vaccination percentage
perc=(data[n][1]/pop)*100
if dose : perc=perc/2
print("For the",vac,"% vaccination of the population is still needed ", dni,"days (",(dni/365).n(12)," years).")
print("On the date",den(data[n][0]), "percentage of vacctination is ",perc.n(20),"%.")
# print("y=",round(a1),"x + ",round(b1)," - is the regression line ")