str_detect(item,  "D3.1.3")  ~ "Policy-related quality",
str_detect(item,  "D3.1.4")  ~ "Use-related quality",
str_detect(item,  "D3.2.1.")  ~ "Implementation outcomes",
str_detect(item,  "D3.2.2.")  ~ "Implementation strategies",
TRUE ~ NA_character_) %>%
# If you want to change the order of the labels on the graphics,
# then you should just reorder the following:
factor(., levels = revRatings))
# Sort Data
lastdayokdataHITlong_lab = lastdayokdataHITlong_lab %>%
arrange(Question, Outcome)
tab.3h_cap <- table_nums(name="tab_3h", caption = "Summary statistics definition ratings HIT")
#### Panel plot ####
# Get Summary Statistics
summary_stats_PanelHIT_def = get_summary(data = lastdaysomedataHITlong_lab, question = Question, outcome = Outcome)
#show the descriptives table - here can exclude some columns by taking out their names from the c() in the first row below
kable_styling(knitr::kable(summary_stats_PanelHIT_def[, c("Question", "Outcome", "median", "LowerIPR", "UpperIPR", "IPRCP", "AssymIndex", "IPRAS", "IPR",  "DisagIndex", "Disagreement")], caption = tab.3h_cap),
bootstrap_options = c("striped", "hover", "condensed", "responsive"))
tab.3i_cap <- table_nums(name="tab_3i", caption = "Summary statistics descriptor group ratings HIT")
#### Panel plot ####
# Get Summary Statistics
summary_stats_PanelHIT = get_summary(data = lastdayokdataHITlong_lab, question = Question, outcome = Outcome)
# Create Panel B Graphic
plot_Panel1HIT = graphic_panel(summary = summary_stats_PanelHIT)
# Save Panel A Graphic
save_graphic(file = "PanelB_Round1_HITRatings.png", graphic = plot_Panel1HIT)
#show the descriptives table - here can exclude some columns by taking out their names from the c() in the first row below
kable_styling(knitr::kable(summary_stats_PanelHIT[, c("Question", "Outcome", "median", "LowerIPR", "UpperIPR", "IPRCP", "AssymIndex", "IPRAS", "IPR",  "DisagIndex", "Disagreement")], caption = tab.3i_cap),
bootstrap_options = c("striped", "hover", "condensed", "responsive"))
# select REP vs others
lastdaysomedataREP <- lastdaysomedata[lastdaysomedata$research.education!="", ]
lastdaysomedataREPother <- lastdaysomedata[lastdaysomedata$research.education=="", ]
# for attribute groups - only full data
lastdayokdataREP <- lastdayokdata[lastdayokdata$research.education!="", ]
lastdayokdataREPother <- lastdayokdata[lastdayokdata$research.education=="", ]
# redo plots only with REPs
# adapt to have longdata on Delphi questions with Outcome variable relevance = 1, clarity = 2 and Question as 1 - 20
lastdaysomedataREPlong <- gather(lastdaysomedataREP[,c("Q1.Gender","Q2.Age","Q3.Country","Q4.Education" ,"Q5.Expertise", "DefinitionAgreement", "DefinitionClarity")],
item, rating, c("DefinitionAgreement", "DefinitionClarity"), factor_key=TRUE)
# label outcomes
lastdaysomedataREPlong_lab <- lastdaysomedataREPlong %>%
mutate(
Outcome = case_when(
str_detect(item, "Agreement") ~ "Agreement",
str_detect(item, "Clarity") ~ "Clarity",
TRUE ~ NA_character_) %>%
factor(., levels = c("Agreement", "Clarity")))
DefRatings <- c("Definition")
#Label Question Variables
lastdaysomedataREPlong_lab = lastdaysomedataREPlong_lab %>%
mutate(Question = case_when(str_detect(item,  "Definition")  ~ "Definition",
TRUE ~ NA_character_) %>%
# If you want to change the order of the labels on the graphics,
# then you should just reorder the following:
factor(., levels = DefRatings))
# Sort Data
lastdaysomedataREPlong_lab = lastdaysomedataREPlong_lab %>%
arrange(Question, Outcome)
# adapt to have longdata on Delphi questions with Outcome variable relevance = 1, clarity = 2 and Question as 1 - 20
lastdayokdataREPlong <- gather(lastdayokdataREP[,c(VarSD2, VarRatings)], item, rating, VarRatings[-c(1,2)], factor_key=TRUE)
# label outcomes
lastdayokdataREPlong_lab <- lastdayokdataREPlong %>%
mutate(
Outcome = case_when(
str_detect(item, "Relevance") ~ "Relevance",
str_detect(item, "Clarity") ~ "Clarity",
TRUE ~ NA_character_) %>%
factor(., levels = c("Relevance", "Clarity")))
#Label Question Variables
lastdayokdataREPlong_lab = lastdayokdataREPlong_lab %>%
mutate(Question = case_when(str_detect(item,  "D1.1")  ~ "Product and provider information",
str_detect(item,  "D2.1") ~ "Target use scenario",
str_detect(item,  "D2.2") ~ "Target health conditions",
str_detect(item,  "D2.3") ~ "Medication regimen",
str_detect(item,  "D2.4.1") ~ "Medication adherence phase",
str_detect(item,  "D2.4.2.A") ~ "Medication adherence measurement",
str_detect(item,  "D2.4.2.B.S") ~ "Medication adherence intervention",
str_detect(item,  "D2.4.2.B.1") ~ "Intervention mode of delivery",
str_detect(item,  "D2.4.2.B.2") ~ "Target behaviour determinants",
str_detect(item,  "D2.4.2.B.3")  ~ "Behaviour change techniques",
str_detect(item,  "D2.4.2.B.4")  ~ "Intervention provider",
str_detect(item,  "D2.4.2.B.5")  ~ "Intervention setting",
str_detect(item,  "D3.1.1.A")  ~ "ISO certification",
str_detect(item,  "D3.1.1.B")  ~ "Scientific evaluation",
str_detect(item,  "D3.1.1.C")  ~ "Development standards",
str_detect(item,  "D3.1.1.D")  ~ "Technological standards",
str_detect(item,  "D3.1.2")  ~ "Research-related quality",
str_detect(item,  "D3.1.3")  ~ "Policy-related quality",
str_detect(item,  "D3.1.4")  ~ "Use-related quality",
str_detect(item,  "D3.2.1.")  ~ "Implementation outcomes",
str_detect(item,  "D3.2.2.")  ~ "Implementation strategies",
TRUE ~ NA_character_) %>%
# If you want to change the order of the labels on the graphics,
# then you should just reorder the following:
factor(., levels = revRatings))
# Sort Data
lastdayokdataREPlong_lab = lastdayokdataREPlong_lab %>%
arrange(Question, Outcome)
tab.3j_cap <- table_nums(name="tab_3j", caption = "Summary statistics definition ratings REP")
#### Panel plot ####
# Get Summary Statistics
summary_stats_PanelREP_def = get_summary(data = lastdaysomedataREPlong_lab, question = Question, outcome = Outcome)
kable_styling(knitr::kable(summary_stats_PanelREP_def[, c("Question", "Outcome", "median", "LowerIPR", "UpperIPR", "IPRCP", "AssymIndex", "IPRAS", "IPR",  "DisagIndex", "Disagreement")], caption = tab.3j_cap),
bootstrap_options = c("striped", "hover", "condensed", "responsive"))
tab.3k_cap <- table_nums(name="tab_3k", caption = "Summary statistics descriptor group ratings REP")
#### Panel plot ####
# Get Summary Statistics
summary_stats_PanelREP = get_summary(data = lastdayokdataREPlong_lab, question = Question, outcome = Outcome)
# Create Panel B Graphic
plot_Panel1REP = graphic_panel(summary = summary_stats_PanelREP)
# Save Panel A Graphic
save_graphic(file = "PanelB_Round1_REPRatings.png", graphic = plot_Panel1REP)
#show the descriptives table - here can exclude some columns by taking out their names from the c() in the first row below
kable_styling(knitr::kable(summary_stats_PanelREP[, c("Question", "Outcome", "median", "LowerIPR", "UpperIPR", "IPRCP", "AssymIndex", "IPRAS", "IPR",  "DisagIndex", "Disagreement")], caption = tab.3k_cap),
bootstrap_options = c("striped", "hover", "condensed", "responsive"))
View(summary_stats_Panel)
TableClarity <- summary_stats_Panel[summary_stats_Panel$Outcome =="Clarity", c("median", "LowerIPR", "UpperIPR", "IPR", "IPRAS", "DisagIndex")]
View(TableClarity)
TableClarity <- round(TableClarity, 2)
save(TableClarity)
save(TableClarity, 'tableclarity.csv')
write.csv(TableClarity, 'tableclarity.csv')
TableClarity <- rev(round(summary_stats_Panel[summary_stats_Panel$Outcome =="Clarity", c("median", "LowerIPR", "UpperIPR", "IPR", "IPRAS", "DisagIndex")], 2))
View(TableClarity)
TableClarity <- rev(rownames(summary_stats_Panel), round(summary_stats_Panel[summary_stats_Panel$Outcome =="Clarity", c("median", "LowerIPR", "UpperIPR", "IPR", "IPRAS", "DisagIndex")], 2))
TableClarity <- rev(rownames(round(summary_stats_Panel[summary_stats_Panel$Outcome =="Clarity", c("median", "LowerIPR", "UpperIPR", "IPR", "IPRAS", "DisagIndex")], 2)))
rev?
?rev
TableClarity <- t(round(summary_stats_Panel[summary_stats_Panel$Outcome =="Clarity", c("median", "LowerIPR", "UpperIPR", "IPR", "IPRAS", "DisagIndex")], 2))
TableClarity <- t(rev(t(round(summary_stats_Panel[summary_stats_Panel$Outcome =="Clarity", c("median", "LowerIPR", "UpperIPR", "IPR", "IPRAS", "DisagIndex")], 2))))
TableClarity <- round(summary_stats_Panel[summary_stats_Panel$Outcome =="Clarity", c("median", "LowerIPR", "UpperIPR", "IPR", "IPRAS", "DisagIndex")], 2)
?sort
TableClarity <- TableClarity[order(row.names(TableClarity)),]
TableClarity <- TableClarity[order(row.names(TableClarity), decreasing=TRUE),]
TableClarity <- round(summary_stats_Panel[summary_stats_Panel$Outcome =="Clarity", c("median", "LowerIPR", "UpperIPR", "IPR", "IPRAS", "DisagIndex")], 2)
TableClarity <- TableClarity[order(row.names(TableClarity), decreasing=TRUE),]
TableClarity <- round(summary_stats_Panel[summary_stats_Panel$Outcome =="Clarity", c("median", "LowerIPR", "UpperIPR", "IPR", "IPRAS", "DisagIndex")], 2)
TableClarity <- TableClarity[order(as.numeric(row.names(TableClarity)), decreasing=TRUE),]
write.csv(TableClarity, 'tableclarity.csv')
TableClarity$Perc <- paste(TableClarity$LowerIPR, "-", TableClarity$UpperIPR)
TableClarity <- TableClarity[,c("median", "Perc", "IPR", "IPRAS", "DisagIndex")]
TableClarity <- round(summary_stats_Panel[summary_stats_Panel$Outcome =="Clarity", c("median", "LowerIPR", "UpperIPR", "IPR", "IPRAS", "DisagIndex")], 2)
TableClarity <- TableClarity[order(as.numeric(row.names(TableClarity)), decreasing=TRUE),]
TableClarity$Perc <- paste(TableClarity$LowerIPR, "-", TableClarity$UpperIPR)
TableClarity <- TableClarity[,c("median", "Perc", "IPR", "IPRAS", "DisagIndex")]
write.csv(TableClarity, 'tableclarity.csv')
TableRelevance <- round(summary_stats_Panel[summary_stats_Panel$Outcome =="Relevance", c("median", "LowerIPR", "UpperIPR", "IPR", "IPRAS", "DisagIndex")], 2)
TableRelevance <- TableRelevance[order(as.numeric(row.names(TableRelevance)), decreasing=TRUE),]
TableRelevance$Perc <- paste(TableRelevance$LowerIPR, "-", TableRelevance$UpperIPR)
TableRelevance <- TableRelevance[,c("median", "Perc", "IPR", "IPRAS", "DisagIndex")]
write.csv(TableRelevance, 'tablerelevance.csv')
tab.3l_cap <- table_nums(name="tab_3l", caption = "Median descriptor groups ratings for all subgroups")
summary_stats_PanelALL <- data.frame(summary_stats_PanelREP[, c("Question", "Outcome", "median")], summary_stats_PanelHCP$median,
summary_stats_PanelPDM$median,  summary_stats_PanelPRP$median,  summary_stats_PanelHIT$median)
names(summary_stats_PanelALL) <- c("Question", "Outcome", "REP.median", "HCP.median", "PDM.median", "PRP.median", "HIT.median")
kable_styling(knitr::kable(summary_stats_PanelALL, caption = tab.3l_cap),
bootstrap_options = c("striped", "hover", "condensed", "responsive"))
ICCsubgroups <- irr::icc(summary_stats_PanelALL[,3:7], model = "twoway",
type = "consistency", unit = "average")
ICCsubgroupsRel <- irr::icc(summary_stats_PanelALL[summary_stats_PanelALL$Outcome == "Relevance",3:7], model = "twoway",
type = "consistency", unit = "average")
ICCsubgroupsClar <- irr::icc(summary_stats_PanelALL[summary_stats_PanelALL$Outcome == "Clarity",3:7], model = "twoway",
type = "consistency", unit = "average")
lastdayokdata$group <- "hcp"
lastdayokdata$group[lastdayokdata$res.ed.nr == 1] <- "res.ed"
lastdayokdata$group[lastdayokdata$healthIT.nr == 1] <- "healthIT"
lastdayokdata$group[lastdayokdata$policy.nr == 1] <- "policy"
lastdayokdata$group[lastdayokdata$patient.nr == 1] <- "patient"
table(lastdayokdata$group, exclude=NULL)
lastdayokdatalong$group <- "hcp"
lastdayokdatalong$group[lastdayokdatalong$res.ed.nr == 1] <- "res.ed"
lastdayokdatalong$group[lastdayokdatalong$healthIT.nr == 1] <- "healthIT"
lastdayokdatalong$group[lastdayokdatalong$policy.nr == 1] <- "policy"
lastdayokdatalong$group[lastdayokdatalong$patient.nr == 1] <- "patient"
table(lastdayokdatalong$group, exclude=NULL)/42
lastdayokdatalong$group <- as.factor(lastdayokdatalong$group)
# for one item
model <- lmer(rating ~ (1 | group), data=lastdayokdatalong[lastdayokdatalong$item == names(table(lastdayokdatalong$item)[1]),])
sjstats::icc(model)
names(table(lastdayokdatalong$item))
for( n in 1: length(names(table(lastdayokdatalong$item))))
{
model <- lmer(rating ~ (1 | group), data=lastdayokdatalong[lastdayokdatalong$item == names(table(lastdayokdatalong$item)[n]),], na.action = "na.exclude");
cat( "\n", names(table(lastdayokdatalong$item)[n]), ":\n" );
print(sjstats::icc(model));
}
nrow(somedata)
names(lastdaydata)
names(lastdayokdata)
VarSD2
VarRatings
# adapt to have longdata on Delphi questions with Outcome variable relevance = 1, clarity = 2 and Question as 1 - 20
lastdayokdatadeflong <- gather(lastdayokdata[,c(VarSD2, VarRatings)], item, rating, VarRatings, factor_key=TRUE)
# adapt to have longdata on Delphi questions with Outcome variable relevance = 1, clarity = 2 and Question as 1 - 20
lastdayokdatadeflong <- gather(lastdayokdata[,c(VarSD2, VarRatings)], item, rating, all_of(VarRatings), factor_key=TRUE)
names(lastdayokdatadeflong)
View(lastdayokdatadeflong)
for( n in 1: length(names(table(lastdayokdatalong$item))))
{
model <- lmer(rating ~ (1 | group), data=lastdayokdatalong[lastdayokdatalong$item == names(table(lastdayokdatalong$item)[n]),], na.action = "na.exclude");
cat( "\n", names(table(lastdayokdatalong$item)[n]), ":\n" );
print(sjstats::icc(model));
}
for( n in 1: length(names(table(lastdayokdatalong$item))))
{
model <- lmer(rating ~ (1 | group), data=lastdayokdatalong[lastdayokdatalong$item == names(table(lastdayokdatalong$item)[n]),], na.action = "na.exclude");
cat( "\n", names(table(lastdayokdatalong$item)[n]), ":\n" );
print(performance::icc(model));
}
data$day.nr <- car::recode(data$date,
'"11.01"=1;
"11.02"= 2;
"11.03"= 3;
"11.04"= 4;
"11.05"= 5;
"11.06"= 6;
"11.07"= 7;
"11.08"= 8;
"11.09"= 9;
"11.10"= 10;
"11.11"= 11;
"11.12"= 12;
"11.13"= 13;
"11.14"= 14;
"11.15"= 15;
"11.16"= 16;
"11.17"= 17;
"11.18"= 18;
"11.19"= 19;
"11.20"= 20;
"11.21"= 21;
"11.22"= 22;
"11.23"= 23;
"11.24"= 24;
"11.25"= 25;
"11.26"= 26;
"11.27"= 27;
"11.28"= 28;
"11.29"= 29;
"11.30"= 30;
"12.01"= 31;
"12.02"= 32;
"12.03"= 33;
"12.04"= 34;
"12.05"= 35;
"12.06"= 36;
"12.07"= 37;
"12.08"= 38;
"12.09"= 39;
"12.10"= 40;
"12.11"= 41;
"12.12"= 42;
"12.13"= 43;
"12.14"= 44;
"12.15"= 45;
"12.16"= 46;
"12.17"= 47;
"12.18"= 48;
"12.19"= 49;
"12.20"= 50;
"12.21"= 51;
"12.22"= 52;
"12.23"= 53;
"12.24"= 54;
"12.25"= 55;
"12.26"= 56;
"12.27"= 57;
"12.28"= 58;
"12.29"= 59;
"12.30"= 60;
"12.31"= 61;
"01.01"= 62;
"01.02"= 63;
"01.03"= 64;
"01.04"= 65;
"01.05"= 66;
"01.06"= 67;
"01.07"= 68;
"01.08"= 69;
"01.09"= 70;
"01.10"= 71;
"01.11"= 72;
"01.12"= 73;
"01.13"= 74;
"01.14"= 75;
"01.15"= 76;
"01.16"= 77;
"01.17"= 78')
#  keep all with at least 1 rating in a separate dataset & exclude test items
somedata <- data[data$Q1.Gender != "" & data$Q2.Age != "" & !is.na(data$DefinitionAgreement), -c(2:5)]
nrow(somedata)
md.pattern(somedata[,VarSD1], rotate.names = TRUE)
md.pattern(somedata[,VarSD1], rotate.names = TRUE)
md.pattern(somedata[,VarRatings], rotate.names = TRUE)
apply(somedata[,VarRatings],2,pMiss)
table(apply(somedata[,VarRatings],1,pMiss), exclude=NULL)
# select those with less than 25% missing and sociodemographics, for sample description
percmiss <- apply(somedata[,VarRatings],1,pMiss)
str(percmiss)
names(percmiss)[percmiss <= 25]
okdata <- somedata[names(percmiss)[percmiss <= 25], ]
md.pattern(somedata[,VarRatings], rotate.names = TRUE)
nrow(okdata)
# adapt to have longdata on Delphi questions with Outcome variable relevance = 1, clarity = 2 and Question as 1 - 20
okdatalong <- gather(okdata[,c(VarSD1, VarRatings, "Replier.Id", "day.nr")], item, rating, all_of(VarRatings), factor_key=TRUE)
okdatalonggr <- merge(okdatalong,lastdayokdata[,c("Replier.Id", "group") ],by="Replier.Id")
okdatalonggr$halfs[okdatalonggr$day.nr >= max(okdatalonggr$day.nr)/2 ] <- 2
# visualisation of all scores across weeks (spaghetti plots per question, lines colored by stakeholder group)
p <- ggplot(data = okdatalonggr, aes(x = day.nr, y = rating, group = Replier.Id))
p + theme_bw() +   scale_y_continuous(limits=c(1,9), breaks = seq(0, 9, by =1 )) + ggtitle ("Stability of ratings of individual respondents per question, color-coder per stakeholder group") + geom_line(aes(col = group)) + facet_wrap(. ~ item, nrow=11, ncol=4)
summarybydate = okdatalonggr %>%
# group data
dplyr::group_by(day.nr, item, group) %>%
# get summaries by group
dplyr::summarize(median = median(rating, na.rm=T),
Quar1 = quantile(rating, probs=.25, na.rm=T),
Quar3 = quantile(rating, probs=.75, na.rm=T))
summarybydate = okdatalonggr %>%
# group data
dplyr::group_by(day.nr, item, group) %>%
# get summaries by group
dplyr::summarize(median = median(rating, na.rm=T),
Quar1 = quantile(rating, probs=.25, na.rm=T),
Quar3 = quantile(rating, probs=.75, na.rm=T))
# visualisation of all scores across weeks (spaghetti plots per question)
p <- ggplot(data = summarybydate, aes(x = day.nr, y = median, group = item))
# visualisation of all scores across weeks (spaghetti plots per question)
p <- ggplot(data = summarybydate, aes(x = day.nr, y = median, group = item))
p + theme_bw() +   scale_y_continuous(limits=c(1,9), breaks = seq(0, 9, by =1 )) + ggtitle ("Stability of median ratings per question, displayed separately for each stakeholder group") + geom_line() + facet_wrap(. ~ group, nrow=1)
summarybydate = okdatalonggr %>%
# group data
dplyr::group_by(day.nr, item, group) %>%
# get summaries by group
dplyr::summarize(median = median(rating, na.rm=T),
Quar1 = quantile(rating, probs=.25, na.rm=T),
Quar3 = quantile(rating, probs=.75, na.rm=T))
summarybydate = okdatalonggr %>%
# group data
dplyr::group_by(day.nr, item, group) %>%
# get summaries by group
dplyr::summarize(median = median(rating, na.rm=T),
Quar1 = quantile(rating, probs=.25, na.rm=T),
Quar3 = quantile(rating, probs=.75, na.rm=T))
summarylastdayCQVsub = lastdayokdatalong %>%
# group data
dplyr::group_by(item, group) %>%
# get summaries by group
dplyr::summarize(median = median(rating, na.rm=T),
Quar1 = quantile(rating, probs=.25, na.rm=T),
Quar3 = quantile(rating, probs=.75, na.rm=T))
summarylastdayCQVsub = lastdayokdatalong %>%
# group data
dplyr::group_by(item, group) %>%
# get summaries by group
dplyr::summarize(median = median(rating, na.rm=T),
Quar1 = quantile(rating, probs=.25, na.rm=T),
Quar3 = quantile(rating, probs=.75, na.rm=T))
# CQV = (Q3-Q1)/(Q1+Q3)*100
summarylastdayCQVsub$CQVsub <- round(((summarylastdayCQVsub$Quar3 - summarylastdayCQVsub$Quar1)/(summarylastdayCQVsub$Quar3 + summarylastdayCQVsub$Quar1)*100), 2)
summarylastdayCQV = lastdayokdatalong %>%
# group data
dplyr::group_by(item) %>%
# get summaries by group
dplyr::summarize(median = median(rating, na.rm=T),
Quar1 = quantile(rating, probs=.25, na.rm=T),
Quar3 = quantile(rating, probs=.75, na.rm=T))
# CQV = (Q3-Q1)/(Q1+Q3)*100
summarylastdayCQV$CQVtotal <- round(((summarylastdayCQV$Quar3 - summarylastdayCQV$Quar1)/(summarylastdayCQV$Quar3 + summarylastdayCQV$Quar1)*100), 2)
# put group values in CQVtotal table (wide & merge)
summarylastdayCQVsubwide <-  spread(summarylastdayCQVsub, group, CQVsub)
summarylastdayCQVsubwide <- summarylastdayCQVsub[, c("item","group" , "CQVsub")] %>%
pivot_wider(names_from = group,values_from=CQVsub)
summarylastdayCQVall <- merge(summarylastdayCQV[, c("item", "CQVtotal")], summarylastdayCQVsubwide[,c("item"  ,"hcp"  ,    "healthIT" ,"patient" , "policy" ,  "res.ed") ],by="item")
tab.CQV_cap <- table_nums(name="tab_1", caption = "CQV values at closing of survey")
#show the descriptives table
kable_styling(knitr::kable(summarylastdayCQVall, caption = tab.CQV_cap),
bootstrap_options = c("striped", "hover", "condensed", "responsive"))
View(summarybydate)
summarybydate = okdatalonggr %>%
# group data
dplyr::group_by(day.nr, item, group) %>%
# get summaries by group
dplyr::summarize(median = median(rating, na.rm=T),
Quar1 = quantile(rating, probs=.25, na.rm=T),
Quar3 = quantile(rating, probs=.75, na.rm=T))
summarylastdayCQVsub = lastdayokdatadeflong %>%
# group data
dplyr::group_by(item, group) %>%
# get summaries by group
dplyr::summarize(median = median(rating, na.rm=T),
Quar1 = quantile(rating, probs=.25, na.rm=T),
Quar3 = quantile(rating, probs=.75, na.rm=T))
summarybydate = okdatalonggr %>%
# group data
dplyr::group_by(day.nr, item, group) %>%
# get summaries by group
dplyr::summarize(median = median(rating, na.rm=T),
Quar1 = quantile(rating, probs=.25, na.rm=T),
Quar3 = quantile(rating, probs=.75, na.rm=T))
# visualisation of all scores across weeks (spaghetti plots per question)
p <- ggplot(data = summarybydate, aes(x = day.nr, y = median, group = item))
p + theme_bw() +   scale_y_continuous(limits=c(1,9), breaks = seq(0, 9, by =1 )) + ggtitle ("Stability of median ratings per question, displayed separately for each stakeholder group") + geom_line() + facet_wrap(. ~ group, nrow=1)
names(okdatalonggr)
table(okdatalonggr$item)
names(summarybydate)
table(summarybydate$item)
table(lastdayokdatadeflong$item)
summarylastdayCQVsub = lastdayokdatadeflong %>%
# group data
dplyr::group_by(item, group) %>%
# get summaries by group
dplyr::summarize(median = median(rating, na.rm=T),
Quar1 = quantile(rating, probs=.25, na.rm=T),
Quar3 = quantile(rating, probs=.75, na.rm=T))
names(lastdayokdatadeflong)
names(lastdayokdatalong)
lastdayokdatadeflong$group <- "hcp"
lastdayokdatadeflong$group[lastdayokdatadeflong$res.ed.nr == 1] <- "res.ed"
lastdayokdatadeflong$group[lastdayokdatadeflong$healthIT.nr == 1] <- "healthIT"
lastdayokdatadeflong$group[lastdayokdatadeflong$policy.nr == 1] <- "policy"
lastdayokdatadeflong$group[lastdayokdatadeflong$patient.nr == 1] <- "patient"
table(lastdayokdatadeflong$group, exclude=NULL)/42
lastdayokdatadeflong$group <- as.factor(lastdayokdatadeflong$group)
summarylastdayCQVsub = lastdayokdatadeflong %>%
# group data
dplyr::group_by(item, group) %>%
# get summaries by group
dplyr::summarize(median = median(rating, na.rm=T),
Quar1 = quantile(rating, probs=.25, na.rm=T),
Quar3 = quantile(rating, probs=.75, na.rm=T))
# CQV = (Q3-Q1)/(Q1+Q3)*100
summarylastdayCQVsub$CQVsub <- round(((summarylastdayCQVsub$Quar3 - summarylastdayCQVsub$Quar1)/(summarylastdayCQVsub$Quar3 + summarylastdayCQVsub$Quar1)*100), 2)
summarylastdayCQV = lastdayokdatalong %>%
# group data
dplyr::group_by(item) %>%
# get summaries by group
dplyr::summarize(median = median(rating, na.rm=T),
Quar1 = quantile(rating, probs=.25, na.rm=T),
Quar3 = quantile(rating, probs=.75, na.rm=T))
summarylastdayCQV = lastdayokdatadeflong %>%
# group data
dplyr::group_by(item) %>%
# get summaries by group
dplyr::summarize(median = median(rating, na.rm=T),
Quar1 = quantile(rating, probs=.25, na.rm=T),
Quar3 = quantile(rating, probs=.75, na.rm=T))
# CQV = (Q3-Q1)/(Q1+Q3)*100
summarylastdayCQV$CQVtotal <- round(((summarylastdayCQV$Quar3 - summarylastdayCQV$Quar1)/(summarylastdayCQV$Quar3 + summarylastdayCQV$Quar1)*100), 2)
# put group values in CQVtotal table (wide & merge)
summarylastdayCQVsubwide <-  spread(summarylastdayCQVsub, group, CQVsub)
summarylastdayCQVsubwide <- summarylastdayCQVsub[, c("item","group" , "CQVsub")] %>%
pivot_wider(names_from = group,values_from=CQVsub)
summarylastdayCQVall <- merge(summarylastdayCQV[, c("item", "CQVtotal")], summarylastdayCQVsubwide[,c("item"  ,"hcp"  ,    "healthIT" ,"patient" , "policy" ,  "res.ed") ],by="item")
#show the descriptives table
kable_styling(knitr::kable(summarylastdayCQVall, caption = tab.CQV_cap),
bootstrap_options = c("striped", "hover", "condensed", "responsive"))
# CQV = (Q3-Q1)/(Q1+Q3)*100
summarylastdayCQV$CQVtotal <- round(((summarylastdayCQV$Quar3 - summarylastdayCQV$Quar1)/(summarylastdayCQV$Quar3 + summarylastdayCQV$Quar1)*100), 2)
# put group values in CQVtotal table (wide & merge)
summarylastdayCQVsubwide <-  spread(summarylastdayCQVsub, group, CQVsub)
summarylastdayCQVsubwide <- summarylastdayCQVsub[, c("item","group" , "CQVsub")] %>%
pivot_wider(names_from = group,values_from=CQVsub)
summarylastdayCQVall <- merge(summarylastdayCQV[, c("item", "CQVtotal")], summarylastdayCQVsubwide[,c("item"  ,"hcp"  ,    "healthIT" ,"patient" , "policy" ,  "res.ed") ],by="item")
tab.CQV_cap <- table_nums(name="tab_4", caption = "CQV values at closing of survey")
#show the descriptives table
kable_styling(knitr::kable(summarylastdayCQVall, caption = tab.CQV_cap),
bootstrap_options = c("striped", "hover", "condensed", "responsive"))
for( n in 1: length(names(table(lastdayokdatalong$item))))
{
model <- lmer(rating ~ (1 | group), data=lastdayokdatalong[lastdayokdatalong$item == names(table(lastdayokdatalong$item)[n]),], na.action = "na.exclude");
cat( "\n", names(table(lastdayokdatalong$item)[n]), ":\n" );
print(performance::icc(model));
}
?performance:check.singularity
?performance::check.singularity
??performance::check.singularity
library(performance)
for( n in 1: length(names(table(lastdayokdatalong$item))))
{
model <- lmer(rating ~ (1 | group), data=lastdayokdatalong[lastdayokdatalong$item == names(table(lastdayokdatalong$item)[n]),], na.action = "na.exclude");
cat( "\n", names(table(lastdayokdatalong$item)[n]), ":\n" );
print(check.singularity(model));
print(performance::icc(model));
}
for( n in 1: length(names(table(lastdayokdatalong$item))))
{
model <- lmer(rating ~ (1 | group), data=lastdayokdatalong[lastdayokdatalong$item == names(table(lastdayokdatalong$item)[n]),], na.action = "na.exclude");
cat( "\n", names(table(lastdayokdatalong$item)[n]), ":\n" );
print(performance::check_singularity(model));
print(performance::icc(model));
}
for( n in 1: length(names(table(lastdayokdatalong$item))))
{
model <- lmer(rating ~ (1 | group), data=lastdayokdatalong[lastdayokdatalong$item == names(table(lastdayokdatalong$item)[n]),], na.action = "na.exclude");
cat( "\n", names(table(lastdayokdatalong$item)[n]), ":\n" );
cat("Checking singularity:", print(performance::check_singularity(model)));
print(performance::icc(model));
}
for( n in 1: length(names(table(lastdayokdatalong$item))))
{
model <- lmer(rating ~ (1 | group), data=lastdayokdatalong[lastdayokdatalong$item == names(table(lastdayokdatalong$item)[n]),], na.action = "na.exclude");
cat( "\n", names(table(lastdayokdatalong$item)[n]), ":\n" );
cat("Checking singularity:", print(performance::check_singularity(model)), ":\n" );
print(performance::icc(model));
}
for( n in 1: length(names(table(lastdayokdatalong$item))))
{
model <- lmer(rating ~ (1 | group), data=lastdayokdatalong[lastdayokdatalong$item == names(table(lastdayokdatalong$item)[n]),], na.action = "na.exclude");
cat( "\n", names(table(lastdayokdatalong$item)[n]), ":\n" );
cat("Checking singularity:", performance::check_singularity(model), "\n" );
print(performance::icc(model));
}
