3

i wanted to view the code behind the families in R, like for example:

make.link("logit")
make.link("identity")
make.link("probit")

Now is saw in the R - repsones that there were functions called, written in programming language C:

Examples:

.Call(C_logit_link, mu)
.Call(C_logit_linkinv, eta)
.Call(C_logit_mu_eta, eta)

And now in would like to access this specific code. Is there any way I can do that?

MrFlick
  • 195,160
  • 17
  • 277
  • 295

2 Answers2

2

Functions that call .Call are calling entry points in compiled code, so you will have to look at sources of the compiled code if you want to fully understand the function

For example what you are looking for is here

SEXP logit_link(SEXP mu)
{
    int i, n = LENGTH(mu);
    SEXP ans = PROTECT(duplicate(mu));
    double *rans = REAL(ans), *rmu=REAL(mu);

    if (!n || !isReal(mu))
    error(_("Argument %s must be a nonempty numeric vector"), "mu");
    for (i = 0; i < n; i++)
    rans[i] = log(x_d_omx(rmu[i]));
    UNPROTECT(1);
    return ans;
}

I recommend you to read this excellent answer here on How you can get any R function source code.

Community
  • 1
  • 1
agstudy
  • 119,832
  • 17
  • 199
  • 261
0

The main codebase is stored in a SVN repository. Information about that is available on the R project developer page

There are mirrors of the code base available on github to make it easier to search. https://github.com/wch/r-source/ for example. You'll see that those functions live at

/src/library/stats/src/family.c

The function names in the code don't have C_ prefix.

MrFlick
  • 195,160
  • 17
  • 277
  • 295