Re: [R] Writing a new link for a GLM.

From: roger koenker <rkoenker_at_uiuc.edu>
Date: Fri, 13 Jun 2008 07:08:12 -0500

I wrote an R-news note about this sort of thing in 2006, you can navigate there via CRAN...

url:    www.econ.uiuc.edu/~roger            Roger Koenker
email    rkoenker_at_uiuc.edu            Department of Economics
vox:     217-333-4558                University of Illinois
fax:       217-244-6678                Champaign, IL 61820


On Jun 13, 2008, at 4:54 AM, Jan Graffelman wrote:

> Hi,
>
> I wish to write a new link function for a GLM. R's glm routine does
> not supply the "loglog" link. I modified the make.link function adding
> the code:
>
> }, loglog = {
> linkfun <- function(mu) -log(-log(mu))
> linkinv <- function(eta) exp(-exp(-eta))
> mu.eta <- function(eta) exp(-exp(-eta)-eta)
> valideta <- function(eta) all(eta != 0)
> }, stop(sQuote(link), " link not recognised"))
> structure(list(linkfun = linkfun, linkinv = linkinv, mu.eta =
> mu.eta,
> valideta = valideta, name = link), class = "link-glm")
> }
>
>
> and then call glm with argument
>
> glm(y~x1+x2+x3,family=binomial(link=make.link("loglog")),data=X)
>
> and that seems to work.
>
> Is this the way to include a new link function? Any other suggestions?
>
> Jan.
>
> --
> ------------------------------------------------------------------------
> |Jan Graffelman |tel:
> +34-93-4011739 |
> |Dpt. of Statistics & Operations Research|fax:
> +34-93-4016575 |
> |Universitat Politecnica de Catalunya |email: jan.graffelman_at_upc.edu
> |
> |Av. Diagonal 647, 6th floor |
> www: |
> |08028 Barcelona, Spain | http://www-eio.upc.es/~jan/
> |
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> 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.



R-help_at_r-project.org mailing list
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. Received on Fri 13 Jun 2008 - 15:03:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 13 Jun 2008 - 15:30:38 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive