I am trying to implement Fisher Scoring on simulated i.i.d. Poisson data recursively, but I am getting a stack overflow error. I did some simple tests 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 7969872 is too close to the limit
Does anyone know what is going on?
Much appreciated
Edit: Changing the stack limit does not resolve the issue because the issue is with convergence and not memory. (I.e. the guess value is not changing).