Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gro-Tsen/42a8601749a69f31e2d5bacc141f5912 to your computer and use it in GitHub Desktop.
Save Gro-Tsen/42a8601749a69f31e2d5bacc141f5912 to your computer and use it in GitHub Desktop.
git clone https://github.com/pcm-dpc/COVID-19/
cd COVID-19
fgrep -i lombardia dati-regioni/dpc-covid19-ita-regioni.csv | cut -d , -f 15 > /tmp/lombardia.dat
R
data = read.table("/tmp/lombardia.dat", header=FALSE, sep="\t")
colnames(data) = c("cases")
data$variation = diff(c(0, data$cases))
data$day <- seq.int(nrow(data))
data2 = subset(data, cases>=1)
data2$smoothed_cases <- exp(predict(loess(log(cases) ~ day, data=data2, span=0.75)))
data2$smoothed_variation = diff(c(0, data2$smoothed_cases))
data2 = subset(data2, smoothed_cases>=15 & day >= 2)
fit = lm(smoothed_variation/smoothed_cases ~ day, data2)
summary(fit)
require(ggplot2)
ggplot(data=data2, mapping=aes(x=day,y=smoothed_variation/smoothed_cases)) + geom_line() + geom_point(data=data2, mapping=aes(x=day, y=variation/cases), color="red")
ggsave("/tmp/lombardia.png")
egrep '^75' /tmp/sursaud-covid19-quotidien-2020-03-26-13h19-feuille1.csv | cut -d , -f 4 > /tmp/paris.dat
R
data = read.table("/tmp/paris.dat", header=FALSE, sep="\t")
colnames(data) = c("variation")
data$day <- seq.int(nrow(data))
data <- within(data, cases <- cumsum(variation))
data2 = subset(data, cases>=1)
data2$smoothed_cases <- exp(predict(loess(log(cases) ~ day, data=data2, span=0.75)))
data2$smoothed_variation = diff(c(0, data2$smoothed_cases))
data2 = subset(data2, smoothed_cases>=5 & day >= 2)
fit = lm(smoothed_variation/smoothed_cases ~ day, data2)
summary(fit)
require(ggplot2)
ggplot(data=data2, mapping=aes(x=day,y=smoothed_variation/smoothed_cases)) + geom_line() + geom_point(data=data2, mapping=aes(x=day, y=variation/cases), color="red")
ggsave("/tmp/paris.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment