As of r87537, binomial()$linkinv no longer accepts integer arguments.

binomial()$linkinv(1.0)  ## 0.7310586
binomial()$linkinv(1L)

Error in binomial()$linkinv(1L) :
  REAL() can only be applied to a 'numeric', not a 'integer'

Since R is usually so permissive/sloppy with the distinction between integers and numeric/doubles, I'd argue that this is a bug ...

  (This came up because it happens to break lme4's tests.)

I haven't done the archaeology to figure out when this broke/exactly what change in the R code base broke it: it happened within the last month or so and it's certainly something upstream of the linkinv function itself, as (according to 'git blame') nothing in that function has changed in the last 4 years ... (if it were of interest I could 'git bisect' to figure it out but maybe someone will save me the trouble ...)

Thoughts, insights? Should I post this to r-bugzilla? Or suck it up and accept it as the new reality?

  cheers
   Ben Bolker

====
binomial()$linkinv is:

function (eta)
.Call(C_logit_linkinv, eta)
<environment: namespace:stats>

Here is the body of the function in C code:

https://github.com/r-devel/r-svn/blob/195ab0870a8131d01492f8f1d3a2ad514bc7e040/src/library/stats/src/family.c#L72C1-L89C2

SEXP logit_linkinv(SEXP eta)
{
    SEXP ans = PROTECT(shallow_duplicate(eta));
    int i, n = LENGTH(eta);
    double *rans = REAL(ans), *reta = REAL(eta);

    if (!n || !isReal(eta))
        error(_("Argument %s must be a nonempty numeric vector"), "eta");
    for (i = 0; i < n; i++) {
        double etai = reta[i], tmp;
        tmp = (etai < MTHRESH) ? DBL_EPSILON :
            ((etai > THRESH) ? INVEPS : exp(etai));
        rans[i] = x_d_opx(tmp);
    }
    UNPROTECT(1);
    return ans;
}

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to