We could try even harder, but code that is almost never used tends to get
broken whilst no one is testing it. So if you want to pursue it I think
we need a comprehensive test suite.
- well, I guess, but I wouldn't have thought that zeros in data modelled
using `gaussian("log")' is such a rare occurance is it? [Or did you mean
that `gaussian("log")' is almost never used, and should hence be kept
simple].
I meant initialization code for this case would rarely get used, as I
suppose those people who do this are used to providing starting values
(or there are few or no such people).
I suppose there are arguments both ways...
best,
Simon
The current offending code from `gaussian' is:
initialize = expression({
n <- rep.int(1, nobs)
if (is.null(etastart) && is.null(start) && is.null(mustart) &&
((family$link == "inverse" && any(y == 0)) ||
(family$link == "log" && any(y <= 0)))) stop(
"cannot find valid starting values: please specify some")
mustart <- y
})
A possible replacement would be ...
initialize = expression({
n <- rep.int(1, nobs)
if (is.null(etastart) && is.null(start) && is.null(mustart) &&
((family$link == "inverse" && all(y == 0)) ||
(family$link == "log" && all(y <= 0)))) stop(
"cannot find valid starting values: please specify some")
mustart <- y
if (family$link=="log") {
iy <- y<=0
if (sum(iy)) mustart[iy] <- min(y[!iy])*.5
} else if (family$link=="inverse") {
iy <- y==0
if (sum(iy)) mustart[iy] <- min(abs(y[!iy]))*.5
}
})
best,
Simon
- Simon Wood, Mathematical Sciences, University of Bath, Bath BA2 7AY
- +44 (0)1225 386603 www.maths.bath.ac.uk/~sw283/