I am relatively new to R and obviously not very experienced. However, I used multilevel modeling to identify influences of voice on sleep parameters. E.g. TST in this snippet is total sleep time, intensity is voice intensity (in this case as mean).
I manage to get a scatterplot, depending on participant number as I want to. However, I now want to include regression lines for my model, that show the intercept and slope for the model vs for the null-model (excluding my independent variable).
Yet, no matter what I try, I do not seem to be able to display the regression lines based on intercept and slope, even after entering their values manually!
Here's my code for the calculation and my calculation and for the plot.
Model:
library(lme4)
TST_RE_Intensity.model = lmer(Intensity_mean ~ TST_re + Day + (1+ TST_re|Participant_ID) + ( 1|Filename), data=my.df, REML = FALSE)
TST_RE_Intensity.null = lmer(Intensity_mean ~ Day + (1+ TST_re|Participant_ID) + (1|Filename), data=my.df, REML = FALSE)
Plot:
library(ggplot2)
p <- ggplot(my.df, aes(x=my.df$TST_re, y=my.df$Intensity_mean, colour=my.df$Participant_ID))+
theme(legend.position = "none")+
geom_point(shape=20) +
geom_abline(aes(intercept=64, slope = - 0.0167, size= 1.5)+
geom_abline(aes(intercept=61, slope = - 0.0162, size=1.5)+
scale_size_manual(values = c(0.3, 0.3))+
scale_y_log10(name="Log10(TST)", limits=c(40,80)) +
scale_x_log10(name="Log10(Intensity)")
I do not get any error messages but also never get to see any lines. I tried to follow instructions of the ggplot2 manual like this one, but end up short
p + geom_abline(intercept = 37, slope = -5)
Is there a way to just plot a line "manually"?
Thanks in advance!!