Dear R-Users,
I wish to create a new family object based on the Binomial family. The only difference will be with the link function. Thus instead if using the 'logit(u)' link function, i plan to use '-log(i-u)'. 
So far, i have tried to write the function following that of the Binomial  and Negative Binomial families.
The major problem i have here is with the definition of the initial values. The definitions i have attempted so far don't yield convergence when implemented in a model. I still can't figure out how the initial values are defined. I don't know if  it is based on some property of the fitted model or the domain and /or range of the link function. I wish someone could help me provide a solution to this problem. I have appended the function i wrote. 
 

Add.haz<-function () {

    

    env <- new.env(parent = .GlobalEnv)

    assign(".nziek", nziek, envir = env)

    famname<-"Addhaza"

    link="addlink"

    linkfun<-function(mu) -log(1-mu)

    linkinv<-function(eta) 1-exp(-eta)

    variance<-function(mu) mu*(1-mu)

    validmu<-function(mu) all(mu > 0) && all(mu < 1)

            mu.eta<-function(mu) 1/(1-mu)

        dev.resids <- function(y, mu, wt) 2 * wt * (y * log(ifelse(y == 

        0, 1, y/mu)) + (1 - y) * log(ifelse(y == 1, 1, (1 - y)/(1 - 

        mu))))

    aic <- function(y, n, mu, wt, dev) {

        m <- if (any(n > 1)) 

            n

        else wt

        -2 * sum(ifelse(m > 0, (wt/m), 0) * dbinom(round(m * 

            y), round(m), mu, log = TRUE))

    }

    

    initialize<- expression({

            n<-rep(1,nobs)

            if (any(y < 0 | y > 1)) stop("y values must be 0 <= y <= 1")

                         mustart <- (weights * y + 0.5)/(weights + 1)

            m <- weights * y

            if (any(abs(m - round(m)) > 0.001)) warning("non-integer #successes in a binomial glm!")

   

   

})

 

    environment(variance) <- environment(validmu) <- environment(dev.resids) <- environment(aic) <- env

    

    structure(list(family = famname, link = link, linkfun = linkfun, 

        linkinv = linkinv, variance = variance, dev.resids = dev.resids, 

        aic = aic, mu.eta =mu.eta, initialize = initialize, 

        validmu = validmu), class = "family")
}
 
Thank you for your kind attention.
Emmanuel


EMMANUEL NJI ABATIH
Rues des deux Eglises 140
1210 St Josse-Ten-Node, Bruxelles, BELGIUM
MOBLIE: 0032486958988(anytime)
Fix: 0032 2642 5038(8am to 6pm)
http://www.iph.fgov.be/epidemio/epien
		
---------------------------------


	[[alternative HTML version deleted]]


