I am trying to fit a 3rd order polynomial on ggplot2 using stat_smoth but would like to force the regression line through a know x-intercept (35 for the following reproducible example).
Example:
x<-c(1,2,3,5,10,12,15,20,22,25,30,33,37)
y<-c(1000,800,100,10,1,0.3,0.25,0.2,0.1,0.1,0.03,0.05,0.03)
myformula<-y ~ poly(x,3)
ggplot(df, aes(x,y)) + stat_smooth(method = lm, formula = myformula) + geom_point() +
stat_smooth(method = lm, formula = myformula) +
stat_poly_eq(formula = myformula, eq.with.lhs = "italic(psi)~`=`~",
eq.x.rhs = "~italic(theta)",
aes(label = paste(..eq.label.., ..rr.label..,
sep = "~~~~")), label.x=0.15, parse = TRUE)+
xlim(0, 40)+ ylim(0, 2000)+
scale_y_log10(breaks = c(0, 0.1,10,1000), labels= c(0,0.1, 10,1000))
How can a get the best-fit regression line and equation when the x-intercept is 35? Also, how can I make the line touch the x-axis?