[R] using loglog link in VGAM or creating loglog link for GLM

Gavin Simpson gavin.simpson at ucl.ac.uk
Sun Aug 23 11:14:22 CEST 2009


On Fri, 2009-08-21 at 18:27 -0400, Kendra Walker wrote:
> 
> I am trying to figure out how to apply a loglog link to a binomial  
> model (dichotomous response variable with far more zeros than ones).   
> I am aware that there are several relevant posts on this list, but I  
> am afraid I need a little more help.  The two suggested approaches  
> seem to be: 1) modify the make.link function in GLM, or 2) use the  
> loglog or cloglog functions in the VGAM package.  Below are my  
> questions for each.  Responses to either are much appreciated.

I was looking at different link functions for binomial glms recently for
the same reason as you (more zeros than ones). I did a bit of reading up
on the various link functions and IIRC, you can use the cloglog link on
your data, just turn your 0's into 1's and vice versa. This was stated
in the one or two references I looked at as to why only one of cloglog
and loglog links is often provided in software.

HTH

G

> 
> 1) Modifying the make.link function:
>   In his Sat, 24 Jan 2009 post, Re: [R] glm binomial loglog (NOT  
> cloglog) link, William Simpson suggested a loglog={} insertion that  
> seems reasonable.   Being new to R, however, I am going in circles  
> trying to figure out make this seemingly simple modification to the  
> code.   If anyone has the patience to step me through the process, or  
> refer me to the relevant information, I would be very grateful.
> 
> 2) Using the loglog function in VGAM:
> I tried fitting the model:  m<- vglm(Y~X,  
> family=binomialff(link="loglog"), data = d)  but I get the following  
> error? Error in lm.fit(X_vlm, z_vlm, ...) : NA/NaN/Inf in foreign  
> function call (arg 4) In addition: Warning message:In log(log(theta))  
> : NaNs produced?.
> If I run the same model using cloglog as the link, I get a result that  
> looks like the result I get using cloglog in GLM.  This is a bad fit  
> for my data, however, as I have many more zeros than ones.   The help  
> document for loglog states that NaNs are produced when theta is close  
> to 1 unless earg is used.  I am confused as to how to properly use the  
> earg parameter (and why I do not need it for cloglog despite having  
> many zeros), leading me to wonder whether the loglog link here is  
> really what I think it is (the compliment of cloglog).  Again, any  
> insights as to what I am missing would be appreciated.
> 
> Many thanks,
> 
> 
> Kendra Walker,
> School of Natural Resources and the Environment,
> University of Michigan
> 
> ______________________________________________
> 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.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%




More information about the R-help mailing list