# Logistical Exposure Link Function # See Shaffer, T. 2004. A unifying approach to analyzing nest success. # Auk 121(2): 526-540. library(MASS) logexp <- function(days = 1) { linkfun <- function(mu) qlogis(mu^(1/days)) linkinv <- function(eta) plogis(eta)^days mu.eta <- function(eta) days * plogis(eta)^(days-1) * .Call("logit_mu_eta", eta, PACKAGE = "stats") valideta <- function(eta) TRUE link <- paste("logexp(", days, ")", sep="") structure(list(linkfun = linkfun, linkinv = linkinv, mu.eta = mu.eta, valideta = valideta, name = link), class = "link-glm") } #Example using chat data from Shaffer(2004). nestdata<-read.table("http://data.prbo.org/tools/NestSurvival/chat.txt") chat.glm.logexp<-glm(survive/trials~parastat+nest_ht*patsize,family=binomial(logexp(days=nestdata$expos)),data=nestdata) # if you have MASS installed library(MASS) chat.step<-stepAIC(chat.glm.logexp,scope=list(upper=~parastat+nest_ht*patsize,lower=~1)) chat.step$anova summary(chat.step) #Not run: # note this compares to following results from SAS : # Criteria For Assessing Goodness Of Fit # # Criterion DF Value Value/DF # Deviance 289 193.9987 0.6713 # Scaled Deviance 289 193.9987 0.6713 # Pearson Chi-Square 289 537.8609 1.8611 # Scaled Pearson X2 289 537.8609 1.8611 # Log Likelihood -96.9994 # Algorithm converged. # Analysis Of Parameter Estimates # # Standard Wald 95% Chi- #Parameter DF Estimate Error Limits Square Pr > ChiSq ##Intercept 1 2.6973 0.2769 2.1546 3.2399 94.92 <.0001 #parastat0 1 -1.0350 0.5201 -2.0544 -0.0155 3.96 0.0466 #parastat1 0 0.0000 0.0000 0.0000 0.0000 . . #patsizelarge 1 1.0844 0.5094 0.0861 2.0827 4.53 0.0333 #patsizesmall 0 0.0000 0.0000 0.0000 0.0000 . . #Scale 0 1.0000 0.0000 1.0000 1.0000 # #NOTE: The scale parameter was held fixed.