2
$\begingroup$

This might be a rather simple question on Bayesian statistics.

Consider the case of inference on properties of a normal distribution $N(µ,σ²)$.

If we assume the standard non-informative prior on σ² $1/σ²$, the resulting posterior distribution $$ p(µ,σ²|y) ∝ (\frac{1}{σ²}) ^{\frac{N+1}{2}} exp(-\frac{Ns^{2}_{y}}{2σ²})\frac{1}{σ²}exp(-\frac{(y-\bar{y})²}{2σ²/N}) $$

is said to have a closed form because it factors in the product of an inverted Gamma distribution for σ² and a conditional normal distribution for µ. This means that we can directly draw from the posterior distribution of σ² via drawing from the inverted gamma distribution, and then draw from the posterior distribution of µ via drawing from the normal distribution.

This can be done with the following R code (plus relying on some summary statistics):

S <- sum((data - mean(data))^2) 
n <- length(data) 
Sigma2 <- S/rchisq(5000,n-1) 
mu <- rnorm(5000,mean=mean(data),sd=sqrt(sigma2)/sqrt(n))

There is not even a need for normalizing.

So far so good.

Now consider the case of a different form of the likelihood function:

$$ p(y|µ,σ²) = (\frac{1}{2πσ²})^{N/2} exp(-\frac{Ns^{2}_{y}}{2σ²}) exp(-\frac{(y-\bar{y}+0.5)²}{2σ²/N}) - (\frac{1}{2πσ²})^{N/2} exp(-\frac{Ns^{2}_{y}}{2σ²}) exp(-\frac{(y-\bar{y}-0.5)²}{2σ²/N}) $$

that is, the probability that a true value falls within the rounding interval that results in the observation.

The posterior density in now proportional to the difference of two productis of inverted Gamma and conditional normal distributions. Can I still use the same approach for drawing from the posterior distribution, or is that impossible because the resulting posterior distribution is not a product of well-known distributions anymore?

$\endgroup$
1
  • $\begingroup$ That probably isn't the distribution you mean... you probably mean the difference between the values of the cumulative distribution $P(y|\mu, \sigma^2)$ at the endpoints of whichever interval "$y$" falls into. That likelihood function is no longer a function of $\bar{y}$ and $s^2_y$, due to the rounding of the data. $\endgroup$
    – jbowman
    Commented Sep 23, 2013 at 19:49

2 Answers 2

1
$\begingroup$

Let us assume the unobserved observations $y_i$ fall into intervals $[a_i, b_i)$, and that the observed observations (sorry, couldn't resist) are the pairs of $[a_i, b_i)$. In that case, the likelihood function for a single observation is:

$l(\mu, \sigma^2 | a, b) = \frac{1}{\sigma} \int_a^b \exp\{-\frac{1}{2\sigma^2}(y-\mu)^2\}\text{d}y$

You can't use the same approach as before, unfortunately. However, that doesn't mean there aren't any approaches which work.

One such approach is MCMC, as you can explicitly calculate the likelihood function w/o much trouble in, for example, R. I've attached some code that implements a simple sampler:

# Generate underlying data
y <- rnorm(1000)
a <- floor(y*10)/10     # Intervals are of the form (0.1, 0.2), (0.2, 0.3), ...
b <- ceiling(y*10)/10   # We ignore the computer's ability to generate, e.g., 1.0 exactly.

# Now for the algorithm
log_lf <- function(mu, sigma, a, b) {
  sum(log(pnorm(b, mu, sigma) - pnorm(a, mu, sigma)))
}

mu_current <- log_sigma_current <- 0
log_lf_current <- log_lf(mu_current, exp(log_sigma_current), a, b)

mu_mcmc <- sigma_mcmc <- rep(0,1000)

for (i in 1:1000) {  # No thinning or any attempt to optimize
  mu_proposed <- mu_current + rnorm(1,0,0.1)
  log_sigma_proposed <- log_sigma_current + rnorm(1,0,0.1)
  log_lf_proposed <- log_lf(mu_proposed, exp(log_sigma_proposed), a, b)

  # With uniform priors on mu and log(sigma), no priors to take into account
  # With symmetric proposal distributions, don't need to take the proposal
  # distribution into account when calculating alpha (it cancels)
  alpha <- exp(log_lf_proposed - log_lf_current)
  if (runif(1) < alpha) {
    mu_mcmc[i] <- mu_proposed
    sigma_mcmc[i] <- exp(log_sigma_proposed)
    mu_current <- mu_proposed
    log_sigma_current <- log_sigma_proposed
    log_lf_current <- log_lf_proposed
  } else {
    mu_mcmc[i] <- mu_current
    sigma_mcmc[i] <- exp(log_sigma_current)
  }
}

and the results...

> summary(mu_mcmc)
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
-0.068810 -0.007038  0.022150  0.015570  0.034990  0.106300 
> summary(sigma_mcmc)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 0.9539  0.9915  1.0070  1.0070  1.0220  1.0790 

Pretty good, but, then again, the sample size was large (1000) and the rounding not that great (intervals of length 0.1).

$\endgroup$
2
$\begingroup$

You can use the same sampling strategy. Draw a parameter (say, $\mu$) from the marginal distribution $p(\mu|y)$, and then draw a value of $\sigma^2$ from the conditional distribution $p(\sigma^2|\mu,y)$. This exploits the identity that $p(\mu, \sigma|y)=p(\mu|\sigma^2,y)p(\sigma^2|y)=p(\sigma^2|\mu,y)p(\mu|y)$.

$\endgroup$
7
  • $\begingroup$ Thank you for your answer. But what is the marginal distribution p(µ|y) and the conditional distribution p(σ²|µ,y) in my case? In the normal(continuos) case, it is p(σ²|y) ~S/χ(n-1) and p(µ|y,σ²) ~N($\bar{y}$,σ²/$\sqrt{N}$). This is because the posterior is the product of those distribution. I do not have the product of two distributions anymore, so what are my marginal and conditional distributions for µ and σ²? $\endgroup$
    – mzuba
    Commented Jun 25, 2013 at 20:39
  • $\begingroup$ You have two options. One would be to evaluate the posterior over a grid of pairwise combinations of $\sigma$ and $\mu$ and set the total probability in that region of the parameter space to one. Then the marginal probability of $\sigma$ (say) is just numerically summed over $\mu$ (and normalized to sum to unity). Alternatively, you can use an MCMC or similar algorithm to sample from the posterior directly. In the case of 2 parameters only, it is more intuitive for me to just do the computations directly, so I would recommend the first option. $\endgroup$
    – Sycorax
    Commented Jun 25, 2013 at 20:55
  • $\begingroup$ Also, if you've found my answers helpful, you can mark the question as accepted (click the check mark next to my answer). $\endgroup$
    – Sycorax
    Commented Jun 25, 2013 at 20:58
  • $\begingroup$ DJE, to me it seems your comment contradicts your answer. If I can draw from the marginal distribution p(σ²|y) or p(µ|y) and then from the conditional distribution p(µ|σ²,y) or p(σ²|µ,y), then I do not need to evaluate the posterior function on a grid or use MCMC in order to obtain draws from the posterior distribution. $\endgroup$
    – mzuba
    Commented Jun 26, 2013 at 8:53
  • $\begingroup$ You reversed the if-then statement. If you have evaluated the posterior over a grid, then you can draw from the marginal distributions easily. This procedure is described in more detail in Gelman's Bayesian Data Analysis, which I have found quite helpful. Alternatively, you may be able to make headway by integrating over a parameter to obtain the marginal for the other parameter. Of course, the computation answer performs this process indirectly and works for intractable integrals, so I find computation more helpful in general. $\endgroup$
    – Sycorax
    Commented Jun 26, 2013 at 12:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.