normmixp               package:Bolstad               R Documentation

_B_a_y_e_s_i_a_n _i_n_f_e_r_e_n_c_e _o_n _a _n_o_r_m_a_l _m_e_a_n _w_i_t_h _a _m_i_x_t_u_r_e _o_f _n_o_r_m_a_l _p_r_i_o_r_s

_D_e_s_c_r_i_p_t_i_o_n:

     Evaluates and plots the posterior density for mu, the mean of a
     normal distribution, with a mixture of normal priors on mu

_U_s_a_g_e:

     normmixp(x, sigma.x, prior0, prior1, p = 0.5, n.mu = 100, ret = FALSE)

_A_r_g_u_m_e_n_t_s:

       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

    n.mu: the number of possible mu values in the prior

       p: the mixing proportion for the two component normal priors

     ret: if true then the likelihood and posterior are returned as a
          list.

_V_a_l_u_e:

     If ret is true, then 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

_S_e_e _A_l_s_o:

     'binomixp' 'normdp' 'normgcp'

_E_x_a_m_p_l_e_s:

     ## 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)

