Skip to content
{{ message }}

Instantly share code, notes, and snippets.

# rsavaris66/savariscovid_2020.ipynb Secret

Last active Mar 13, 2021
SavarisCOVID_2020.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

### rsavaris66 commented Sep 15, 2020

 #Code for RStudio. Both files are available in the supplement# ``````setwd("~/Desktop/code_COVID_xlsx/conferencia.xlsx") library("bstats") library(lmtest) library(readxl) conferencia <- read_excel("conferencia.xlsx") pares<- read_excel("pares_conf.xlsx") i=1 A=as.character(pares[i,1]) B=as.character(pares[i,2]) xyA=as.matrix(conferencia[conferencia\$location==A,2:3]) xyB=conferencia[conferencia\$location==B,2:3] deaths = (xyA - xyB)[,1] iso = (xyA - xyB)[,2] model = lm(deaths~iso) ds = summary(model) coefs = model\$coefficients pv=coef(ds)[,4] # Residual analysis resd = model\$residuals tests = c(shapiro.test(resd)\$p.value, # H0: normality white.test(model)\$p.value, # H0: homoskedasticity bgtest(model)\$p.value, # H0: uncorrelated errors resettest(model)\$p.value) # Model is functionally well specified coint = as.numeric(PP.test(lm(deaths~iso)\$residuals)) fr=data.frame("A" = A, "B" = B, "intercept" = as.numeric(coefs), "coef_isol" = as.numeric(coefs), "p.value_iso" = pv, "Shapiro" = shapiro.test(resd)\$p.value, "White" = white.test(model)\$p.value, "LM-test" = bgtest(model)\$p.value, "Reset" = resettest(model)\$p.value, "Coint" = coint) for(i in 2:dim(pares)){ A=as.character(pares[i,1]) B=as.character(pares[i,2]) xyA=as.matrix(conferencia[conferencia\$location==A,2:3]) xyB=conferencia[conferencia\$location==B,2:3] deaths = (xyA - xyB)[,1] iso = (xyA - xyB)[,2] model = lm(deaths~iso) ds = summary(model) coefs = model\$coefficients pv=coef(ds)[,4] # Residual analysis resd = model\$residuals coint = as.numeric(PP.test(lm(deaths~iso)\$residuals)) fr=rbind(fr,data.frame("A" = A, "B" = B, "intercept" = as.numeric(coefs), "coef_isol" = as.numeric(coefs), "p.value_iso" = pv, "Shapiro" = shapiro.test(resd)\$p.value, "White" = white.test(model)\$p.value, "LM-test" = bgtest(model)\$p.value, "Reset" = resettest(model)\$p.value, "Coint" = coint)) } write.table(fr, file = "Todos_conf.csv", sep = ",", row.names = F) ``````
to join this conversation on GitHub. Already have an account? Sign in to comment