Search code examples
rhyperlinkglm

glm model structure in R


During my course I've encountered multiple ways to structure generalized linear models:

fit=glm(ploidy~.,family=binomial,data=diploiddata)

fit2=glm(cbind(germinated,not_germinated)~genotype*extract,
family=binomial(link=logit),data=data)

I know that the cbind argument is used when the data is in the wide format and fit2 is an example of when the dataframe is in the long format. But what is the difference in

family=binomial 

and

family=binomial(link=logit)

And how would I need to interpret that difference mathematically?


Solution

  • Actually there is no difference.If you go through the documentation, you can find that in case of binonmial the default implementation is of logistic regression. But if you are looking for a probit or cloglog , then you need to specifically specify the link. For example for probit it can be like:

    glm( formula, family=binomial(link=probit))
    

    Similarly, below are other families with their default link.

    Family  Default Link Function
    binomial    (link = "logit")
    gaussian    (link = "identity")
    Gamma   (link = "inverse")
    inverse.gaussian    (link = "1/mu^2")
    poisson (link = "log")
    quasi   (link = "identity", variance = "constant")
    quasibinomial   (link = "logit")
    quasipoisson    (link = "log")
    

    Other Reference : Quick-R Reference