## PILL STUDY - CORONA FOLLOW UP ## SOCIAL # Lotte P. Brinkhof - May 2020 #Load functions: ---- #R functions library(readr); library(dplyr); library(reshape); library(reshape2); library(Rmisc) library(doBy); library(car); library(Hmisc); library(psych); library(utils); library(plotrix) library(readxl); options(contrasts=c("contr.sum","contr.poly")); library(afex); library(rethinking); library(ramify); library(imputeTS); library(readxl); library(nparLD); library(effsize) is.even <- function(x) x %% 2 == 0 #Customized functions load("Social_clean.Rdata") #Color settings ---- cold = "Grey30" #Load data: ---- NOTE: PATHS NEED TO BE CHANGED TO THE APPROPRIATE FOLDER B_FollowUp <- read.csv(".../Data/B.FollowUp.COVID.May2020.csv") B_FollowUp <- B_FollowUp[-c(which(B_FollowUp$ppnr == 237,)[2], which(B_FollowUp$ppnr == 212,)[2]),] #remove duplicates Social <- Social_clean(B_FollowUp) save(Social, file = "Social.Rdata") #Analysis: --- #Living alone or together table(Social$X600.1) #Sociaal contact: echt (< minder) tbl1 <- table(Social$X600.2_1); barc <- barplot(tbl1, border = NA, col = cold, xaxt = "n", ylim = c(0,20), ylab = "Frequency") axis(1, at = barc, labels = c("1x p/m", "1x p/w", "< 1x p/w", "Daily"), tick = F) quantile(Social$X600.2_1) tbl2 <- table(Social$X600.3_1); barc <- barplot(tbl2, border = NA, col = cold, xaxt = "n", ylim = c(0,20), ylab = "Frequency") axis(1, at = barc, labels = c("No contact", "< 1x p/m", "1x p/m", "1x p/w", "> 1x p/w", "Daily"), tick = F) quantile(Social$X600.3_1) wilcox.test(Social$X600.2_1, Social$X600.3_1, paired = T) Social_long <- melt(Social[,c(2:3,16)], id = "ppnr") rcompanion::wilcoxonPairedRC(Social_long$value, Social_long$variable, paired = T) boxplot(Social_long$value~Social_long$variable, frame = F, col = cold, pch = 19, xlab = "", xaxt = "n", ylab = "Relative Frequency of face-to-face contacts") axis(1, at = c(1,2), labels = c("Normally", "Now"), tick = F) #Sociaal contact: alternatief (zelfde) tbl3 <- table(Social$X600.4_1); barc <- barplot(tbl3, border = NA, col = cold, xaxt = "n", ylim = c(0,20), ylab = "Frequency") axis(1, at = barc, labels = c("< 1x p/m", "1x p/w", "> 1x p/w", "Daily"), tick = F) quantile(Social$X600.4_1) tbl4 <- table(Social$X600.5_1); barc <- barplot(tbl4, border = NA, col = cold, xaxt = "n", ylim = c(0,20), ylab = "Frequency") axis(1, at = barc, labels = c("1x p/w", "> 1x p/w", "Daily"), tick = F) quantile(Social$X600.5_1) wilcox.test(Social$X600.4_1, Social$X600.5_1, paired = T) Social_long <- melt(Social[,c(4:5,16)], id = "ppnr") rcompanion::wilcoxonPairedRC(Social_long$value, Social_long$variable, paired = T) #Beperking samenkomsten: quantile(Social$X600.6_19); mean(Social$X600.6_19); hist(Social$X600.6_19) wilcox.test(Social$X600.6_19, mu = 50); rcompanion::wilcoxonOneSampleR(Social$X600.6_19,mu = 50) mean(Social$X600.6_20); sd(Social$X600.6_20); hist(Social$X600.6_20) t.test(Social$X600.6_20, mu = 50) effsize::cohen.d(Social$X600.6_20, NA, mu = 50) mean(Social$X600.6_21);sd(Social$X600.6_21); hist(Social$X600.6_21) t.test(Social$X600.6_21, mu = 50) effsize::cohen.d(Social$X600.6_21, NA, mu = 50) quantile(Social$X600.6_22); mean(Social$X600.6_22); hist(Social$X600.6_22) wilcox.test(Social$X600.6_22, mu = 50); rcompanion::wilcoxonOneSampleR(Social$X600.6_22,mu = 50) #zinvolle maatregel quantile(Social$X600.6_23); mean(Social$X600.6_23) hist(Social$X600.6_23) wilcox.test(Social$X600.6_23, mu = 50); rcompanion::wilcoxonOneSampleR(Social$X600.6_23,mu = 50) #Beperking uit huis gaan: quantile(Social$X600.7_19); mean(Social$X600.7_19); hist(Social$X600.7_19) wilcox.test(Social$X600.7_19, mu = 50); rcompanion::wilcoxonOneSampleR(Social$X600.7_19,mu = 50) mean(Social$X600.7_20); sd(Social$X600.7_20); hist(Social$X600.7_20) t.test(Social$X600.7_20, mu = 50) effsize::cohen.d(Social$X600.7_20, NA, mu = 50) mean(Social$X600.7_21); sd(Social$X600.7_21); hist(Social$X600.7_21) t.test(Social$X600.7_21, mu = 50) effsize::cohen.d(Social$X600.7_21, NA, mu = 50) quantile(Social$X600.7_22); mean(Social$X600.7_22); hist(Social$X600.7_22) wilcox.test(Social$X600.7_22, mu = 50); rcompanion::wilcoxonOneSampleR(Social$X600.7_22,mu = 50) quantile(Social$X600.7_23); mean(Social$X600.7_23); hist(Social$X600.7_23) wilcox.test(Social$X600.7_23, mu = 50); rcompanion::wilcoxonOneSampleR(Social$X600.7_23,mu = 50)