Given that the likelihood is Y|n~Binomial(n, theta) and the prior is n~Poisson(5), I tried to calculate the posterior distribution of sample size n with Y=0 and theta=0.2. My code is as follows:
Y <- 0
theta <- 0.2
n_grid <- seq(0,1,length=1000)
like <- dbinom(Y,n_grid,theta)
prior <- dpois(n_grid,5)
fy <- sum(like*prior)
post <- like*prior/fy
plot(n_grid,post,type="l")
I keep getting NaN results when computing the likelihood function and priors. Any help would be appreciated!