From a bootstrapping model I have 1000 sets of coefficients for this regression model:
y = b0 + b1x + b2(x^2)
What is the function call to plot a quadratic line if I already have the coefficients? I.E. I do not want to "fit" a linear model to my data.
I tried adding lines via a for loop to my ggplot object:
for (i in 1:1000) {
reg_line <- stat_function(fun=function(x) quad$coefficients[1] +
quad$coefficients[i,2]*x + quad$coefficients[i,3]*(x**2))
reg_lines <- reg_lines + reg_line}
That didn't work - it seems to only add the last line in the loop.
The reason I want to add 1000 regression lines to my plot is because it is for a homework problem - I am well aware this is not a common use case.
+ geom_abline(slope = , intercept = )
? - Hughgeom_abline
for quadratic, but are you able to use it to add 1000 straight lines on to your plot, or does it too only add the last one? To get a better response you should probalbly include a minimal reproducible example so that when we run your code we get the same result. Right now you've only given an excerpt. - Hugh