Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. rsquared[list___, model_] :=
  2. 1 - SquaredEuclideanDistance[list[[;; , 2]],
  3. model /@ list[[;; , 1]]]/
  4. SquaredEuclideanDistance[list[[;; , 2]], Mean@list[[;; , 2]]]
  5.  
  6. data = {{0, 1}, {1, 2}, {2, 4}, {3, 9}};
  7. mass = LinearModelFit[data, x, x];
  8. rsquared[data, mass]
  9. (*0.889474*)
  10.  
  11. mass["RSquared"]
  12. (*0.889474*)
  13.  
  14. model[r_] := 2.6*r
  15. rsquared[data, model]
  16. (*0.888421*)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement