Cannot see geom_abline specifying lmodel2 generated regression lines in ggplot2.

My goal is to use ggplot in order to plot a Model II regression line. I have attempted to do this with geom_abline and the lmodel2 functions. I was able to successfully do this with two other plots, however, the third one, the one in question, does not display the regression lines on the plot at all, no matter what I do.

Here is a slightly modified version of the code that I am using.

mod <- lmodel2(formula = X ~ Y, data = DataSet, range.y = "relative", range.x = "relative", nperm = 99)
names(reg) <- c("method", "intercept", "slope", "angle", "p-value")
ggplot(DataSet, aes(x=X, y=Y)) + xlab("X") + ylab("Y") + geom_point(aes(col=Parameter1, shape=Parameter2, size=5)) +geom_abline(data = reg, aes(intercept = intercept, slope = slope), show.legend = TRUE) + stat_regline_equation(label.x = .1, label.y = 6) + stat_cor(label.x = .1, label.y = 5.5)

My slopes and intercepts are relatively small, but even taking that into consideration, I find it odd the regression lines are completely invisible. (The Y axis goes to 7, while the X axis goes to .5). I am unsure what is going on and would appreciate any help. Thank you.

I have never used the lmodel2 function but I notice that your formula is X ~ Y. Since you are plotting X on the x axis, it should be Y ~ X.

What a silly thing for me to miss! Thank you so much for pointing that out, it seems to work now.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.