# Implementing McKelvey & Zavoina R2 for drc package in R

I'm implementing the McKelvey & Zavoina pseudo-R2 measure for use with the drc package and intend to open-source the solution and contribute to that project.

I can do standard R2 with
R2 <- 1-(modelFit(fit)$RSS[2]/sum((fit$data$response-mean(fit$data\$response))^2))
but obviously that's not appropriate for logistic regression.

This is the code I'm using at the moment.

Some setup:

library(drc)

standards<-structure(list(dose = c(12.698970004336, 12.698970004336, 12.397940008672,
12.397940008672, 12.0969100130081, 12.0969100130081, 11.7958800173441,
11.7958800173441, 11.4948500216801, 11.4948500216801, 11.1938200260161,
11.1938200260161, 10.8927900303521, 10.8927900303521, 10.5917600346881,
10.5917600346881), response = c(0.196, 0.201, 0.297, 0.293, 0.534, 0.529, 0.854,
1.079, 1.523, 1.534, 1.619, 1.529, 1.723, 1.734, 1.819, 1.829)),
.Names = c("dose", "response"), row.names = c(NA, -16L), class = "data.frame")

fit<-drm(response~dose, data=standards,fct=LL.4())


Then the McKelvey & Zavoina R2 algorithm:

MZystar <- predict(fit)
sse     <- sum((MZystar - mean(MZystar))^2)
s2      <- pi^2/3
R2MZ    <- sse/(s2 + sse)


But the values it's producing don't seem right.

-
ps: Tried to add the drc tag but don't have the rep. – ClearBlueWater Aug 28 '12 at 7:13
What exactly is your question, ClearBlue? Are you asking for some variant of "standard R2"? If so, then please explain what you need. Are you asking for a diagnosis of the "values it's producing"? Then please indicate what those values are and why they "don't seem right." – whuber Aug 28 '12 at 14:42
@whuber I thought I was clear that I was talking about the McKelbey&Zavoina Pseudo-R2 as per (tandfonline.com/doi/abs/10.1080/0022250X.1975.9989847). I would like some review of my implementation as scientific statistic measures isn't something I'm qualified in and I'm not brilliant with R either. The value doesn't seem right because it's a 0-1 scale and I'm getting values that seem low for the plotted fit. – ClearBlueWater Aug 29 '12 at 1:59