Find the equation y=mx + c of the least square line that best fits the data from example 1:
This line is called least-squares line and the coefficients m and c are called regression coefficients.
Solution :
First form your matrix A, then solve the linear system .
i) Enter the data matrix D as:
D=[5/2 3 3/2 1; 1 1 1 1 ; 2 9/2 2 1 ]'
Note that A = D(:,[1 2]) and b= D(:,3)
ii) Find the augmented matrix of the system by typing
AG= [ ( D(:,[1 2]) )' *( D(:,[1 2]) ) ( D(:,[1 2]) )'*( D(:,3) ) ]
Then find the rref of the agumented matrix by typing
RAG=rref(AG)
This should give you m= -7/5 and c= 17/40 .