Hi, it is my first topic in this forum.
I’m trying to calculate the posterior mean with likelihood and prior distribution conjugate.
i have generated the data from N(23,10), and so i know the true standard deviation of the generator process. this sample is generated with R
i have set the prior distribution of theta like N(0,100) and the likelihood like N(\theta,10). the stan script is here.
the theory to calculate the posterior variance said that
$$\sigma_{pos}=( \frac{1}{\sigma_0}+ \frac{N}{\sigma} )^{-1}$$
i have done a script in R to calculate this, but the variance of generated sample theta is different by the theoretical variance calculated with formula
Can anyone help me to understand why the variance are different?
thanks for your help
Variance.R (1.3 KB)
Modello.Stan (198 Bytes)