I am trying to plot trendlines based off different models onto a plot so I can then plot which is the best model (based off AIC). The trendline from the logarithmic model of the data, however, does not fall on the datapoints. I think it is maybe to do with the fact the y axis is natural log of the values and not just the raw values but do not know how to fix that!
Any ideas how to correct this issue? My code is below!
p1<- ggplot(dat, aes(x = T_C_1, y = lnCH4_ug_m2_h))
p2 <- p1 + geom_point(data = dat, color='grey60') + ggtitle('All Data') +
xlab('Temperature (?C)') + theme_bw() +
ylab(expression(ln~CH[4]~(mu*g~m^-2~h^-1))) +
#geom_smooth(method='lm', color = 'black', aes(color = "Linear Model - First Order"), size = 1, linetype = 2, se=FALSE) +
#geom_smooth(method='lm', color = 'black', aes(color = "Polynomial Model 3"),formula = y~poly(x,3), size = 1, linetype = 2, se=FALSE) +
#geom_smooth(method='lm', color = 'black', aes(color = "Linear Model - Second Order"), formula = (y ~ x^2), size = 1, linetype = 2, se=FALSE) +
#geom_smooth(method='lm', color = 'black', aes(color = "Exp Model"),formula = y~exp(x), size = 1, linetype = 2, se=FALSE) +
#geom_smooth(method='lm', color = 'black', aes(color = "Nat Log Model"),formula = log(y+34)~x, size = 1, linetype = 2, se=FALSE) +
geom_smooth(method='lm', color = 'black', aes(color = "Log Model"),formula = log10(y+34)~x, size = 1, linetype = 2, se=FALSE) +
#geom_smooth(method='lm', color = 'black', aes(color = "Polynomial Model 2"),formula = y~poly(x,2), size = 1, linetype = 1, se=FALSE) +
guides(color = guide_legend("Model Type")) +
#scale_y_continuous(limits = c(-100, 8)) + scale_x_continuous(limits = c(0, 0.3)) +
theme(axis.line = element_line(colour = "black"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank())
p2