Please use set.seed(422) and provide R code
Posted: Tue Apr 26, 2022 6:15 pm
Please use set.seed(422) and provide R code
Problem 2. For the following bivariate density of X and Y, f(x, y) a (*) weta-1 (1 – y)n-2+3–1, x = 0,1,...,n, 0 <y <1, suppose we are interested in estimating the mean of the marginal distribution f(x) of X. It can be shown that for fixed a, B, and n, the conditional densities are f(x[y) is Binomial(n,y) f(y|x) is Beta(x + a, n = x +B). 1. (20 pts) Use the Gibbs sampling to generate a random sample of size 10,000 from the target bivariate density with parameter values n = 16, a = 2, and B = 4. You can initialize first sample with (5, 0). (Hint: Use rbinom() function to generate sample from Binomial distribution and use rbeta() function to generate sample from Beta distribution.) 2. (5 pts) Now to estimate the mean of the marginal distribution f(x) of X, calculate the sample mean of X from the generated random sample. 3. (5 pts) As you may have already noticed, Gibbs sampling is actually not needed in this example, since f(x) can be obtained analytically from the joint density and it follows the beta-binomial distribution. However, Gibbs sampling becomes indispensable in situation where f(x) cannot be obtained analytically. The theoretical mean of the beta-binomial distribution is no antes. Compare the theoretical mean to the sample mean you obtained.
Problem 2. For the following bivariate density of X and Y, f(x, y) a (*) weta-1 (1 – y)n-2+3–1, x = 0,1,...,n, 0 <y <1, suppose we are interested in estimating the mean of the marginal distribution f(x) of X. It can be shown that for fixed a, B, and n, the conditional densities are f(x[y) is Binomial(n,y) f(y|x) is Beta(x + a, n = x +B). 1. (20 pts) Use the Gibbs sampling to generate a random sample of size 10,000 from the target bivariate density with parameter values n = 16, a = 2, and B = 4. You can initialize first sample with (5, 0). (Hint: Use rbinom() function to generate sample from Binomial distribution and use rbeta() function to generate sample from Beta distribution.) 2. (5 pts) Now to estimate the mean of the marginal distribution f(x) of X, calculate the sample mean of X from the generated random sample. 3. (5 pts) As you may have already noticed, Gibbs sampling is actually not needed in this example, since f(x) can be obtained analytically from the joint density and it follows the beta-binomial distribution. However, Gibbs sampling becomes indispensable in situation where f(x) cannot be obtained analytically. The theoretical mean of the beta-binomial distribution is no antes. Compare the theoretical mean to the sample mean you obtained.