47 views

Skip to first unread message

May 27, 2017, 9:40:53 PM5/27/17

to Stan users mailing list

Hi,

I have just started using rstanarm

I need help with this problem.

I have a parameter with mean 4.7 and standard deviation 4.3 from noisy data . Assuming true effect size is 0.3. i want to estimate this parameter with a normal and cauchy prior with location at zero and scale of 0.3 . How can I code this example in rstanarm

Problem is taken from this paper..

This is what I have tried so far..

Y = rnorm(100,4.7,4.3) # simulate a parameter with mean 4.7, sd 4.3 from noisy data

A = data.frame(Y) # convert to data frame

#Assuming true effect size to be 0.3 , can be represented as normal and Cauchy priors .With location 0 and scale 0.3

Fit1 = stan_glm( Y~1, data=A, family=gaussian(),prior_intercept= normal(0,0.3) )

Fit2 = stan_glm( Y~1, data=A, family=gaussian(),prior_intercept= cauchy(0,0.3) )

However summary of these estimates are way off

Where am I going wrong ?

May 27, 2017, 9:43:40 PM5/27/17

to Stan users mailing list

From gelman's paper

"

case, with a sufficiently diffuse prior distribution, the posterior distribution would be approximately normal with mean 4.7% and standard error 4.3%, which would imply about an 86% probability that the true effect is positive. In general, the more concentrated the prior distribution around 0 (expressing a presumption based on the sex-ratio literature that the true effect is likely to be small), the closer the posterior probability will be to 50%.

The idea that any effects are likely to be small can be represented by using a Cauchy distribution with center 0 and scale 0.3%. This distribution implies that the true difference in the proportion of girl births, comparing beautiful and ugly parents, is most likely to be near zero, with a 50% chance of being in the range [−0.3%, 0.3%], a 90% chance of being in the range [−1%, 1%], and a 94% chance of being less than 3 percentage points in absolute value. We center the prior distribution at zero because, ahead of time, we have no reason to believe that the effect will be in one direction rather than the other.

We combine the prior distribution with the normal likelihood for the regression coefficient on the standardized beauty coefficient (that is, the likelihood corresponding to the normal distribution with mean 4.7% and standard deviation 4.3%). The resulting posterior distribution gives a probability of only 58% that the difference is positive—that beautiful parents actually have more daughters—and even if the effect is positive, there is a 78% chance it is less than 1 percentage point.

"

May 27, 2017, 11:57:27 PM5/27/17

to Stan users mailing list

On Saturday, May 27, 2017 at 9:40:53 PM UTC-4, anupam singh wrote:

Where am I going wrong ?

You presumably want prior_intercept = normal(location = 0, scale = 0.3, autoscale = FALSE) to put it in raw units. Still, I am not seeing what is wrong with the estimates. If that is your prior, and you have only 100 weak observations, then you should get a posterior median somewhere between the prior and the MLE.

Reply all

Reply to author

Forward

0 new messages

Search

Clear search

Close search

Google apps

Main menu