testy=Import["https://onemocneni-aktualne.mzcr.cz/api/v2/covid-19/testy.csv","CSV"];
indikovani=Import["https://onemocneni-aktualne.mzcr.cz/api/v2/covid-19/nakaza.csv","CSV"];
umrti=Import["https://onemocneni-aktualne.mzcr.cz/api/v2/covid-19/nakazeni-vyleceni-umrti-testy.csv", "CSV"];

findT[i_,date_]:=Position[Map[#[[1]],i],date][[1,1]]
findFirst[i_]:=Position[i,Select[i,#[[2]]>0&][[1]]][[1,1]]

ind=Table[indikovani[[i]][[3]],{i,2,Length@indikovani}];
RegressionR0[ind_,γ_,t_,range_]:=(data=Table[{k,Log@ind[[k]]},{k,t-range+1,t}];slope=LinearModelFit[data,x,x][[1]][[2,2]];slope/γ+1)

RegressionR0[ind-mrt-vyl, 1/7,267,7]

a=1/7;
range=7;
line1=Plot[1,{i,0,Length@indikovani-1},PlotStyle->{Gray,Dashed}];
line15=Plot[1.5,{i,0,Length@indikovani-1},PlotStyle->{Gray,Dashed}];
graph=ListLinePlot[Table[{i,RegressionR0[ind-mrt-vyl, a,i,range]},{i,findFirst[indikovani]+range-1,Length@indikovani-1,3}],PlotStyle->{Red}];
Show[line1,line15,graph,PlotRange->{0,3}]

umrti;
vyl=Table[umrti[[i]][[3]],{i,2,Length@umrti}];
mrt=Table[umrti[[i]][[4]],{i,2,Length@umrti}];

f[x_]:=(g1=ListLinePlot[Table[{i+x,RegressionR0[ind, a,i,range]},{i,100+range-1,Length@indikovani-1,3}],PlotStyle->{Red}];
g2=ListLinePlot[Table[{i,RegressionR0[vyl+mrt, a,i,range]},{i,100+range-1,Length@indikovani-1,3}],PlotStyle->{Green}];
Show[g1,g2])

g[x_]:=(t1=Table[RegressionR0[ind, a,i-x,range],{i,100+range-1,Length@indikovani-1,3}];t2=Table[RegressionR0[vyl+mrt, a,i,range],{i,100+range-1,Length@indikovani-1,3}];Norm[t1-t2])

norm=Table[g[j],{j,1,20}]
Position[norm,Min@norm][[1,1]]

f[11]