Consider the following sample:
$(x_1, y_1) = (1, 1)$, $(x_2, y_2) = (2, 5)$, $(x_3, y_3) = (3, 8)$, $(x_4, y_4) = (4, 18)$.
Suppose you predict $y$ based on $x$ with a linear model $y = a + bx$ so that the mean squared error of the model is minimised.
What is $a$ and $b$?
And how can I calculate the RMSE and $R^2$ of this model?
RMSE(Root mean square error) is calculated by $$\sqrt{\frac{1}{n}\sum_{i=1}^{n}(y_i-\hat{y}_i)^2}$$ where $y_i$ is the true value of the data, and $\hat{y}_i$ is your "prediction". In your case, there are total of $N=4$ data, and each data $x_1, x_2, x_3, x_4$ has one attribute $y_1, y_2, y_3, y_4$ associated to them(resp.). You would like to predict the data by using a linear model, so that $\hat{y}_i=a+bx_i$. Then, $$\hat{y}_1=a+bx_1=a+b$$ $$\hat{y}_2=a+bx_2=a+2b$$ $$\hat{y}_3=a+bx_3=a+3b$$ $$\hat{y}_4=a+bx_4=a+4b$$ If you plug in the values of $y_i$ and $\hat{y}_i$, you will get some expression of the RMSE with respect to $a$ and $b$. Using your favorite method(Lagrange multipliers, matching squares, etc), you can find the minimum and for which values of $a, b$ the minimum is attained. Can you take it from here?