Manual calculation of McKelvey & Zavoina Pseudo $R^2.$ I would like to calculate McKelvey & Zavoina pseudo $R^2$ manually for poisson regression. I based my calculations on the formula found here i.e.
$$ R^2 =\frac{\sigma^2(\hat y) }{\sigma^2(\hat y)+ \frac{\pi^2}3}$$
Let's consider the following model:
set.seed(42)
y <- c(1, 2, 3, 2, 1, 4, 5, 6, 7, 1, 2, 3)
x <- rnorm(length(y))
z <- runif(length(y))

mod <- glm(y ~ x + z, family = poisson)

And my calculation of pseudo $R^2$ is then:
var(predict(mod)) / (var(predict(mod)) + pi^2 / 3)
0.02075299

However, if we calculate this $R^2$ using performance library, we obtain:
performance::r2_mckelvey(mod)
0.1853505 

Do you know, what the source of this discrepancy is?

At least according to the documentation for the R package performance, that formula for McKelvey and Zavoina pseudo r-squared is only for binomial logistic regression with the logit link. ( rdrr.io/cran/performance/man/r2_mckelvey.html ).
I don't have access to the original paper by McKelvey and Zavoina to see what formula they use for Poisson regression models.
Also note that the webpage you cited is titled "Psuedo r-squared for logistic regression".
