[R] Help with GLM starting values in user defined link function
Ken Knoblauch
ken.knoblauch at inserm.fr
Thu Oct 23 17:27:09 CEST 2014
<Andrew.Hoskins <at> csiro.au> writes:
> I'm trying to fit a binomial GLM with user defined
link
function (negative exponential), however I seem to
> be unable to find the correct starting values to
initialise such a model. I've tried taking starting
> values from a logistic and log models fit to the
same data and also tried to substitute the intercept
from
> the null model in as the starting value for this
model, however all continue to return the same error.
>
> Andrew
>
> ## Example fit of negative exponential binomial
GLM
>
> ## define link function
> negexp <- function()
> {
> linkfun <- function(mu) 1-exp(-mu)
> linkinv <- function(eta) -log(1-eta)
> mu.eta <- function(eta) 1/(1-eta)
> valideta <- function(eta) TRUE
> link <- paste0("negexp")
> structure(list(linkfun = linkfun, linkinv = linkinv,
> mu.eta = mu.eta, valideta = valideta,
name = link),
> class = "link-glm")
> }
>
---SNIP---
Take a look at the limits of eta for the extreme values
of mu and compare them with the linear predictor of
your link applied to say the fitted values of your logit
fit. It seems to suggest that two values fall outside
the range of valid eta, according to your linkfun:
c(62, 83). I got it to work
with these removed although there were lots of other
warnings that you might have to worry about.
Also, when choosing start values you might want
to base them on a fit with your link rather than
a different one. So, I got start values by trying
EV <- negexp()$linkfun(fitted(fit.logit))
LE.lm <- lm(EV ~ eco + geog, testDat)
Ec <- coef(LE.lm)
with these defined as in your mail (sorry I snipped
your code out).
So, I found
which(fitted(LE.lm) > (1 - exp(-1)))
62 83
62 83
and then
glm(y ~ eco + geog, family = binomial(negexp()),
data = testDat[-c(62, 83), ], start = Ec)
Coefficients:
(Intercept) eco geog
1.593e-01 2.085e-01 4.713e-06
Degrees of Freedom: 97 Total (i.e. Null); 95 Residual
Null Deviance: 134.4
Residual Deviance: 112.3 AIC: 118.3
There were 27 warnings (use warnings() to see them)
HTH
>
> Andrew Hoskins
> Postdoctoral reasearch fellow
> Ecosystem Sciences
> CSIRO
>
> E Andrew.Hoskins <at> csiro.au T +61 2 6246 5902
> Black Mountain Laboratories
> Clunies Ross Street, Acton, ACT 2601, Australia
> www.csiro.au
>
>
--
Kenneth Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.html
More information about the R-help
mailing list