Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rsquared[list___, model_] :=
- 1 - SquaredEuclideanDistance[list[[;; , 2]],
- model /@ list[[;; , 1]]]/
- SquaredEuclideanDistance[list[[;; , 2]], Mean@list[[;; , 2]]]
- data = {{0, 1}, {1, 2}, {2, 4}, {3, 9}};
- mass = LinearModelFit[data, x, x];
- rsquared[data, mass]
- (*0.889474*)
- mass["RSquared"]
- (*0.889474*)
- model[r_] := 2.6*r
- rsquared[data, model]
- (*0.888421*)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement