I am trying to calculate the $R^2$ value for a production constrained spatial interaction model, using Fotheringham and O'Kelly (1989) as my guide.
I get dramatically different values for R-Square, depending on whether I calculate it as r-square <- 1 - SSe/SSt
or r-square <- cor(x, y)^2
. Is this result expected? Of course, I may well be miscalculating this somewhere along the line.
I want to use r-square as a (flawed but nevertheless useful and widely understood) measure of goodness of fit, as recommended by Fotheringham & Knudsen (1987).
A reproducible example is below. I've saved my model output to a csv, to save space here.
predobs <- read.csv("http://dl.dropbox.com/u/66606821/pred_obs.csv")
sst <- sum((predobs$obs - mean(predobs$obs))^2)
sse <- sum((predobs$obs - predobs$pred)^2)
(r.square.1 <- 1 - (sse/sst))
(r.square.2 <- cor(predobs$obs, predobs$pred)^2)