3
$\begingroup$

I know that WinBugs uses precision as a parameter in dnorm instead of variance

 model {

    #Likelihood
        for(i in 1:N1){
            y1[i] ~dnorm(mu,tau)
        }

    sigma <- sqrt(1/tau)

    #Priors
    mu ~ dnorm(0,0.000001)
    tau~ dgamma(taumu, taus)
   }

My question is: if instead I want to specify the prior for sigma because I know its mean and variance would it be right to use the following model ?

  model {

    #Likelihood
        for(i in 1:N1){
            y1[i] ~dnorm(mu,tau)
        }

    tau <- sqrt(1/sigma)

    #Priors
    mu ~ dnorm(0,0.000001)
    sigma ~ dnorm(sigmamu, sigmas)
   }

Thanks in advance

$\endgroup$
7
  • 4
    $\begingroup$ you cannot put a normal prior on a positive quantity. $\endgroup$ – Xi'an Jan 14 '15 at 12:07
  • $\begingroup$ @Xi'an thanks I understand it but I have that the variance is normally distributed with mean sigmamu and std sigmas so how can I do to convert these information into precision? $\endgroup$ – user3706794 Jan 14 '15 at 12:15
  • 2
    $\begingroup$ If you know or set mean and variance for $\sigma$, then you can pick one and only one inverse gamma distribution with the same mean and variance. Or any other distribution on the positive real line with the same mean and variance. But you cannot "have that the variance is normally distributed" because this is impossible. $\endgroup$ – Xi'an Jan 14 '15 at 12:20
  • 1
    $\begingroup$ On the Wikipedia page about the inverse gamma, the connection between natural parameters and mean and variance is available. $\endgroup$ – Xi'an Jan 14 '15 at 12:26
  • 1
    $\begingroup$ @Xi'an thanks. So if I calculate the shape parameters from the known sigmamu and sigmas values these are the parameters of the inverse gamma for the precision and not the variance? $\endgroup$ – user3706794 Jan 14 '15 at 12:32
1
$\begingroup$

If "sigma <- sqrt(1/tau)" as indicated in the model on the top, then how is "tau <- sqrt(1/sigma)"?

$\sigma = 1/\sqrt\tau \implies \sigma^2 = 1/\tau \implies \tau = 1/\sigma^2$.

$\endgroup$
1
$\begingroup$

In the second model, tau <- sqrt(1/sigma) is wrong; it should be tau <- 1/sigma^2. You also cannot give a normal distribution to a non-negative random variable, so you will need to choose a different distribution for $\sigma$. If you simply want to keep the same form as Model 1 but set your prior mean and variance for $\sigma$ to known values, this can be accomplished by checking the appropriate moments for the gamma prior and using some algebra to get the desired moments.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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