Hello,
Please help me on that!
I am trying to plot a quadratic (i.e. 2nd-degree polynomial) regression line.
The code I use is kind of:
qfit <- lm(y ~ poly (x,2))
p <- plot_ly() %>%
… %>%
add_lines (x=x, y=fitted(qfit)) %>%
This gives me that
However, this just links the predicted values (I have 12 of them because I have 12 data points) by straight lines. Instead, what I want is a quadratic fit line between them.
When I try something different, by using
add_trace(x=x, y=~fitted(qfit), type=“scatter”, mode=“lines”, line=list(shape=“spline”))
I get this graph which seems even worse
Does anyone have any advice on how to get what I want?
Thank you in advance,
Giannis