Advertisement
Sri27119

linear regression

May 19th, 2024
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.25 KB | None | 0 0
  1. X = 1:6;
  2. Y = [1 22 50 62 97 110];
  3. plot(X,Y,'o');
  4. hold on;
  5. a = polyfit(X,Y,1);
  6. Y_H = polyval(a,X);
  7. plot(X, Y_H);
  8. legend('observed', 'predicted');
  9. xlabel('predictor');
  10. ylabel('respond variable');
  11. E = Y_H - Y;
  12. MSE = sqrt(mean(E.^2));
  13. display(MSE);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement