I would like to make a similar plot as the following one: image 1
I used the following code for this plot (name model = model_11b):
plot_model(model_11b, type = "int", title = "Sedentary behaviour - Domains: Pre-Corona versus Lockdown",legend.title = "Domains",
legend.labels = c("a","b","b")) +
geom_line(linetype = "dashed") +
scale_color_discrete(labels = c("Leisure-time", "Work", "Transport"))+
labs(y= "Sedentary behaviour - Domains", x = "Measurement moment") +
scale_x_continuous(labels= c("Pre-Corona","Lockdown"), breaks = c(1,2))
INFO: The above model was made based on this dataset: dataset1
Model_11b has the following code:
model_11b <- glmer(SG_domeinen~1 + Meetmoment + SG_type_domein + Meetmoment:SG_type_domein + (1|T3_Nummer), data = dataset, family = Gamma(link = "log"), nAGQ = 2, control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=100000) ))
And the following packages were installed: library(lme4) library(lmerTest) library(haven) library(ggplot2) library(sjPlot)
The new plot I would like to make is a plot based on the following code: library(lme4) library(lmerTest) library(haven)
DATASET:
structure(list(T3_Nummer = structure(c(1, 1, 3, 3, 5, 5, 7, 7,
9, 9, 11, 11, 14, 14), format.spss = "F5.0"), Meetmoment = structure(c(1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("1",
"2"), class = "factor"), sedentair_gedrag_totaal_perweek = structure(c(1972.5,
5557.5, 2670, 5310, 3660, 4515, 3840, 4972.5, 1162.5, 3997.5,
4755, 3682.5, 2932.5, 3075), format.spss = "F8.2", display_width = 34L),
sedentair_gedrag_totaal_perweek_ud = structure(c(4.69642857142857,
13.2321428571429, 6.35714285714286, 12.6428571428571, 8.71428571428571,
10.75, 9.14285714285714, 11.8392857142857, 2.76785714285714,
9.51785714285714, 11.3214285714286, 8.76785714285714, 6.98214285714286,
7.32142857142857), format.spss = "F8.2", display_width = 34L),
total_SG = structure(c(4.69652857142857, 13.2322428571429,
6.35724285714286, 12.6429571428571, 8.71438571428571, 10.7501,
9.14295714285714, 11.8393857142857, 2.76795714285714, 9.51795714285714,
11.3215285714286, 8.76795714285714, 6.98224285714286, 7.32152857142857
), format.spss = "F8.2", display_width = 34L)), row.names = c(NA,
-14L), class = c("tbl_df", "tbl", "data.frame"))
Dataset2$Meetmoment <- factor(Dataset2$Meetmoment)
Dataset2$sedentair_gedrag_totaal_perweek_ud <- Dataset2$sedentair_gedrag_totaal_perweek/(7*60)
Dataset2$total_SG <- Dataset2$sedentair_gedrag_totaal_perweek_ud + 0.0001
model_20 <- glmer(total_SG~1 + Meetmoment + (1|T3_Nummer), data = Dataset2, family = Gamma(link = "log"))
I tried to make a plot of this model (library(ggplot2) & library(sjPlot) with the following code, but I don't get the plot I was looking for.
plot_model(model_20, type = "est", title = "Total sedentary behaviour: precorona versus lockdown")+
geom_line(linetype = "dashed") +
labs(y= "Total sedentary behaviour",x = "Measurement moment")
Can someone help me further with this please?