I am trying to implement Fisher Scoring on simulated i.i.d. Poisson data, but I am getting a stack overflow error. I did some simple prints from the function and found that the guess value is not changing after the first iteration.
fs_pois <- function(data, true, guess) {
if (abs(guess-true) < 0.01) return(guess)
else return(fs_pois(data, true, guess + (mean(data)*exp(-guess))-1))
}
data <- rpois(100,lambda=0.34)
fs_pois(data, 0.34, 0.36)
produces
Error: C stack usage 7970416 is too close to the limit
Does anyone know what is going on? Much appreciated