[R] glm with family binomial and link identity

Martin Maechler m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Thu Apr 28 16:48:14 CEST 2022


TLDR:  No, there was no such change in R 4.2.0

>>>>> Ralf Goertz 
>>>>>     on Wed, 27 Apr 2022 10:27:33 +0200 writes:

    > Hi,
    > I just noticed that (with my version 4.2.0) it is no longer possible to
    > use glm with family=binomial(link=identity). Why is that? It was
    > possible with 4.0.x as a colleague of mine just confirmed. 

That's not correct I think:

I've now tried your example in R versions 3.5.x, 4.0.5, 4.1.3, and 4.2.0
and it gave the same error everywhere:

d <- data.frame(y  = c( 0, 1,  0, 1),
                trt= c( 0, 0,  1, 1),
                w  = c(97, 3, 90, 10))
r0 <- try(
    glm(y ~ trt, weights = w, data=d, family = binomial(link = identity)) 
)
## Error in binomial(link = identity) : 
##   link "identity" not available for binomial family; available links are ‘logit’, ‘probit’, ‘cloglog’, ‘cauchit’, ‘log’

And indeed, binomial() has started with

> head(binomial)
                                                                  
1 function (link = "logit")                                       
2 {                                                               
3     linktemp <- substitute(link)                                
4     if (!is.character(linktemp))                                
5         linktemp <- deparse(linktemp)                           
6     okLinks <- c("logit", "probit", "cloglog", "cauchit", "log")
> 

*forever*.

It is slightly interesting (to me at least) that if you use a string,
you can use all valid arguments for make.link() and not just
those that are declared "ok" by the code.

HOWEVER, this all has been documented for a long time,
in  ?family == ?binomial

  Note:

	 The ‘link’ and ‘variance’ arguments have rather awkward semantics
	 for back-compatibility.  The recommended way is to supply them as
	 quoted character strings, but they can also be supplied unquoted
	 (as names or expressions).  Additionally, they can be supplied as
	 a length-one character vector giving the name of one of the
	 options, or as a list (for ‘link’, of class ‘"link-glm"’).  The
	 restrictions apply only to links given as names: when given as a
	 character string all the links known to make.link are accepted.



 



    > After all it is useful to compute risk differences with factors.

at least it was neand

    > ______________________________________________
    > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
    > https://stat.ethz.ch/mailman/listinfo/r-help
    > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
    > and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list