I have an R function called Likelihood
that works well when observations
in my code is seq(1, 30)
. However, I can't understand why observations = seq(1, 50)
it starts to give all ZEROS. I appreciate ideas regarding how to overcome this problem?
Here is my R code:
observations = seq(1, 60)
n = length(observations)
x_bar = mean(observations)
SIGMA = 2
SE = SIGMA / sqrt(n)
x.min = x_bar - 4*SE
x.max = x_bar + 4*SE
Likelihood = function(x) sapply(lapply(x, dnorm, x = observations, SIGMA), prod) # Natural Log??
curve(Likelihood, from = x.min, to = x.max, col = 'red', lwd = 3)