Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying prior parameters from code? #42

Open
AntonioMartini opened this issue Jul 4, 2016 · 2 comments
Open

Specifying prior parameters from code? #42

AntonioMartini opened this issue Jul 4, 2016 · 2 comments

Comments

@AntonioMartini
Copy link

Is there a way of specifying priors parameters from code/file? For example, in the code below, rather than writing dnorm(0,100) we may want to specify the prior mean and variance as a result of a calculation. Is there a way of feeding such computed prior parameters to the model?

`m3 <- map2stan(

  alist( 

    s ~ student_t( v+1, mu, sigma ),

    mu <-  k1*v1 + k2*v2 

    k1  ~ dnorm(0,100),        
    k2  ~ dnorm(0,100),        

    sigma ~ dcauchy(0,0.5),

    v ~ dexp(30)

  ), 
  data=db, 
  constraints=list(sigma="lower=0", v="lower=0"),
  chains=12, 
  cores=12,
  WAIC=FALSE )`


@rmcelreath
Copy link
Owner

This seems to work:

m <- map2stan(
    alist(
        k ~ dnorm( k_mu , k_sd )
    ),
    data=list(k_mu=c(0,0),k_sd=c(1,1)) )

It's a little awkward, since map2stan expects data to have more than one case, I had to insert two values into k_mu and k_sd in the data list. Stan did not seem to care.

In any event, the above is not tested or supported behavior. So be careful.

@AntonioMartini
Copy link
Author

Thanks that's very helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants