I'm using Firth and Turner's BradleyTerry2 package for paired comparisons but have run into a mysterious problem using the main fitting function BTm. Here is a minimal data setup from their own example:
data(citations, package = "BradleyTerry2")
citations.sf <- countsToBinomial(citations)
names(citations.sf)[1:2] <- c("journal1", "journal2")
So at the console the following works:
citeModel <- BTm(cbind(win1, win2), journal1, journal2, data = citations.sf)
but the following does not work
f1 <- function(x){ BTm(cbind(win1, win2), journal1, journal2, data=x) }
f1(citations.sf)
while this (statistically nonsensical but) structurally similar linear model example does work, just as I would expect:
f2 <- function(x){ lm(log(win1/win2) ~ journal1, data=x) }
f2(citations.sf)
The error with f1 is "Error in eval(substitute(expr), data, enclos = parent.frame()): invalid 'envir' argument". But this is not telling me anything I can understand.
Thoughts?