I'm doing a dose-response plot where the dietary intake (x-axis) divides in two intervention groups (high protein vs. low protein) and y-axis shows the change in a bone outcome.
I want to do a linear regression line showing the association between intake and change in bone outcome, however, since the assumption of normal distribution is not true, I would like to do two separate lines — one for each group (high vs. low) — showing the association.
I have used the following code:
abline(lm(y ~ x:factor(Protein) + factor(Protein) -1, data = CC_compliance.long), col = "blue")
However, the plot only shows one line, which doesn't make any sense:
I'm thinking that it may have something to do with the code not being able to differentiate between Protein=1 and Protein=2. Can i define this in another way?
Dataset:
structure(list(Protein = c(1, 2, 2, 1, 2, 2, 2, 1, 1, 2), Change_bone = c(72.1, 132.2, 57.8, 55.6, 30.4, 49.1, 46.8, 24.6, 44.8, 96.4), Protein_intake = c(20.9, 11.2, 7.9, 17.5, 10, 1.5, 9.3, 20, 22.5, 10.4)), row.names = c(NA, -10L), class = c("tbl_df", "tbl", "data.frame"))