I want to run a Gaussian GLM with a log link and an offset. The following problems arise:
y <- c(1,1,0,0)
t <- c(5,3,2,4)
No problem:
exp(coef(glm(y~1 + offset(log(t)), family=poisson)))
with family=gaussian
, starting values need to be specified, it works here:
exp(coef(glm(y~1, family=gaussian(link=log), start=0)))
but does not work here:
exp(coef(glm(y~1 + offset(log(t)), family=gaussian(link=log), start=0)))
Error in eval(expr, envir, enclos) : cannot find valid starting values: please specify some"
Does anyone see what's wrong (hopefully just in my coding) ?
I looks like start
isn't being recognised when offset
is present. You are trying to take the log of 0 in the y
values which is -Inf
. glm
obviously cannot deal with this when looking for a solution without being given some help by start
. A small perturbation in your y
values will permit a solution.
exp(coef(glm(I(y+.Machine$double.eps)~1 + offset(log(t)), family=gaussian(link=log))))
(Intercept)
0.1481481