Description Usage Arguments Value See Also Examples
Evaluates and plots the posterior density for mu, the mean of a normal distribution, with a mixture of normal priors on mu
1 2 3 4 5 6 7 8 9 10 |
x |
a vector of observations from a normal distribution with unknown mean and known std. deviation. |
sigma.x |
the population std. deviation of the observations. |
prior0 |
the vector of length 2 which contains the means and standard deviation of your precise prior. |
prior1 |
the vector of length 2 which contains the means and standard deviation of your vague prior. |
p |
the mixing proportion for the two component normal priors. |
mu |
a vector of prior possibilities for the mean. If it is |
n.mu |
the number of possible mu values in the prior. |
... |
additional arguments that are passed to |
A list will be returned with the following components:
mu |
the vector of possible mu values used in the prior |
prior |
the associated probability mass for the values in mu |
likelihood |
the scaled likelihood function for mu given x and sigma.x |
posterior |
the posterior probability of mu given x and sigma.x |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ## generate a sample of 20 observations from a N(-0.5, 1) population
x = rnorm(20, -0.5, 1)
## find the posterior density with a N(0, 1) prior on mu - a 50:50 mix of
## two N(0, 1) densities
normmixp(x, 1, c(0, 1), c(0, 1))
## find the posterior density with 50:50 mix of a N(0.5, 3) prior and a
## N(0, 1) prior on mu
normmixp(x, 1, c(0.5, 3), c(0, 1))
## Find the posterior density for mu, given a random sample of 4
## observations from N(mu, 1), y = [2.99, 5.56, 2.83, 3.47],
## and a 80:20 mix of a N(3, 2) prior and a N(0, 100) prior for mu
x = c(2.99, 5.56, 2.83, 3.47)
normmixp(x, 1, c(3, 2), c(0, 100), 0.8)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.