finding best function

Hi,
Im struggling with finding best fitting function defined as "y = ax " for data (x, y) = {(1,5), (2,4), (3,3), (4,2), (5,1)}.

I only managed to draw the plot, What function should I use?

df = data.frame(x = c(1,2,3,4,5), y = c(5,4,3,2,1))
plot(df$y ~ df$x)

The other question is why I cant use R2 = 1 −
RSS/TSS?

Thank you for your time.

df = data.frame(x = c(1,2,3,4,5), y = c(5,4,3,2,1))
model <- lm(y ~ 0 + x, data=df)
model

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