How can I force the intercept for a polynomial regression parabola and get the correct equation?

I need to get a graph for regression analysis for certain data. As that data must contain the point (0, 0), the regression polynomial graph must go through (0, 0). However whatever I have tried I could only manage to do that with abline but not for the second degree polynomial. Here's my code:

concentration = c(0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20)
absorbance = c(0, 80.33, 135.7, 207, 243.3, 303, 329, 370.3, 406, 431.7, 444.3)
albumin = data.frame(concentration = concentration, absorbance = absorbance)
modelForAlbumin = lm(formula = absorbance ~ concentration + 0, data = albumin)
modelForAlbumin
modelPoly = lm(formula = y ~ 0 + x + I(x^2), data = albumin)
modelPoly
ggplot(data = albumin, mapping = aes(x = concentration, y = absorbance)) +
  labs(x = "Kontnsentratsioon c", y = "Neelduvus N") +
  geom_point() +
  geom_line() +
  geom_abline(intercept = 0, slope = modelForAlbumin$coefficients[1], color = 3) +
  geom_smooth(method = "lm", formula = y ~ poly(x, 2), fill = "firebrick") +
  stat_regline_equation(aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~~")), formula = y ~ poly(x, 2) + x + 0)
library(basicTrendline)
trendline(concentration,absorbance,model="line3P",summary=TRUE,eDigit=4)

The first image displays the graphs correctly however the equation for y is totally incorrect. Why is that?

The second image also displays the graph correctly however I can't force the intercept there.

So how to create a graph that has the polynomial regression line with forced intercept and that the equation also corresponds to that id est it's in the form of y = a x ^ 2 + k x?

to have stat_regline report the same values as trendline, modify the formula to the one that trendline reports using, which is y ~ I(x^2) + x
however, to modify it to not have an intercept (i.e. go through 0,0) add -1 as a term on the right.
y ~ -1 + I(x^2) + x

Your solution really works. However, the value -1 doesn't seem logical. What does it mean? "intercept zero"? What if I want to force other points, another intercept, how can I do that?

You could try to use Weighted Least Squares to force the regression curve through the point (0,y0) by adding that point to your data set and give it a high weight compared with the other points in the weights argument of lm.
Or subtract y0 before doing the regression with -1.

This topic was automatically closed 7 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.