Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Urgent]- How to compute normal posterior distribution for Bayesian Analysis

    Hi everyone,

    I am a new user to STATA, and after reading the manuals and information online, I am still not clear on how to get the normal posterior distribution using the Bayesian analysis function.

    I have a normal prior and likelihood distribution with known mean and std. I wish to compute the same parameters (mean and std) for the posterior distribution. Under the STATA menu-- Statistics--Bayesian Analysis--General estimation and regression--Syntex---Univeriate Distribution, However, I can not find a normal distribution shown from the drop list.

    My question is, is there a way for me to add-in a normal distribution into the likelihood drop list? Or is my above working procedures not right? Please let me know if there is another way to perform posterior distributions and correct me if my understanding is wrong.

    Thanks alot!

  • #2
    Please read and act on the FAQ Advice, as all members here are asked to do before posting.

    https://www.statalist.org/forums/help#crossposting explains our policy on cross-posting, which is that you are asked to tell us about it.
    This was cross-posted at https://stats.stackexchange.com/ques...r-distribution -- although it seems doomed there to closure.

    https://www.statalist.org/forums/help#technical
    Claims of urgency are deprecated here. They won't get you better, more or faster answers. It's even my experience that claims of urgency lead some long-term members to pass quickly by, and so act against you.

    https://www.statalist.org/forums/help#spelling is there partly to tell us who fails to do as we ask.

    All that said, I am not an expert on Bayesian statistics, but this seems confused to me. A normal posterior will be the result of a normal prior and of data in some circumstances. It's not something you ask for in advance. It's the job of the machinery to tell you what the posterior is.
    Last edited by Nick Cox; 13 Jan 2019, 08:30.

    Comment


    • #3
      Originally posted by jiahui Liu View Post
      is there a way for me to add-in a normal distribution into the likelihood drop list? Or is my above working procedures not right? Please let me know if there is another way to perform posterior distributions and correct me if my understanding is wrong.
      I don't use the menu, but to me Stata's Bayesian syntax (and I assume its menu system as well) is geared toward regression models. So, you're better off thinking of your likelihood in terms of a common regression model that corresponds to it.

      I don't quite follow you with "I have a normal prior and likelihood distribution with known mean and std.", but you could look into something like the following (sorry it's command line syntax--I'm sure that it's there in the corresponding menu system).
      Code:
      version 15.1
      
      clear *
      
      set seed `=strreverse("1478552")'
      
      quietly sysuse auto
      
      *
      * Begin here
      *
      
      // First way (easiest: a linear regression with only a constant term)
      
      bayes, normalprior(`=sqrt(10)'): regress mpg
      
      
      // Analogue (same priors and likelihod) using -bayesmh-
      
      bayesmh mpg, likelihood(normal({sigma2})) ///
          prior({mpg:_cons}, normal(0, 10)) ///
          prior({sigma2}, igamma(0.01, 0.01))
      
      
      exit

      Comment


      • #4
        Originally posted by Joseph Coveney View Post
        I don't use the menu, but to me Stata's Bayesian syntax (and I assume its menu system as well) is geared toward regression models. So, you're better off thinking of your likelihood in terms of a common regression model that corresponds to it.

        I don't quite follow you with "I have a normal prior and likelihood distribution with known mean and std.", but you could look into something like the following (sorry it's command line syntax--I'm sure that it's there in the corresponding menu system).
        Code:
        version 15.1
        
        clear *
        
        set seed `=strreverse("1478552")'
        
        quietly sysuse auto
        
        *
        * Begin here
        *
        
        // First way (easiest: a linear regression with only a constant term)
        
        bayes, normalprior(`=sqrt(10)'): regress mpg
        
        
        // Analogue (same priors and likelihod) using -bayesmh-
        
        bayesmh mpg, likelihood(normal({sigma2})) ///
        prior({mpg:_cons}, normal(0, 10)) ///
        prior({sigma2}, igamma(0.01, 0.01))
        
        
        exit
        Hi Joseph,

        Thank you for the reply. May I just clarify a few things regarding the command that you posted?

        Suppose that I have a prior distribution that follows normal distribution with mean and standard deviation (x, y). Also, I have a likelihood distribution follows normal distribution that have mean and standard deviation (n,m). May I know how to input these 4 numbers into your command?

        Thank you!

        Comment


        • #5
          In your subsequent post on this topic I wrote

          My guess as to what you want to do in the original topic is
          • you have prior distribution for the parameter(s) (mean, or perhaps mean and standard deviation) of a normally distributed random variable
          • you have data drawn from that distribution
          • you wish to use the data to to update your prior distribution, prodicing your posterior distribution for the parameter(s).
          Joseph Coveney's post #3 advises you how to use Stata's Bayes commands to do that, and as he said, those commands are not geared toward what you apparently hope to do but can be made to do it in the way he suggests.
          You post above now makes it clear that in fact you do not have data, you have four numbers, where two of them are the parameters of the prior distribution and two are parameters of the likelihood function.

          This is not a problem in data analysis - your data has already been analyzed and summarized as the mean and standard deviation of the likelihood function. Using the parameters of the likelihood function to update the prior distribution to yield the posterior distribution is not a problem that Stata provides a direct solution for, and I'm not sure how one could create an indirect solution like the one Joseph describes.

          Luckily it is a problem that can be solved with a four-function calculator and a formula. I've never seen a problem stated this way outside of the problem sets in a textbook (or an exam based on material in a textbook) so I would refer you to whatever textbook you have learned Bayesian statistics from to refresh your memory on how the conjugate prior distribution for a mean of a normal distribution can be combined with the mean and standard deviation of the likelihood function calculated from the data to yield a posterior distribution for the mean of the normal distribution.

          It will be similar to the formula given in https://en.wikipedia.org/wiki/Bayesian_probability but will have enough explanation with it, I hope, so that you can understand how to use it with your numbers. The Wikipedia material linked is rather sparse on explaining what each of the symbols in the formula means.

          Comment

          Working...
          X