March 2019
Beginner to intermediate
448 pages
13h 14m
English
In this example, we will generate 1,000 Gaussian deviates with a mean equal to five and a standard deviation equal to three. We will assign a Gaussian prior to the mean parameter, and a gamma distribution to the standard deviation. The objective will be to characterize the marginal posterior densities for mu and sigma (mean and standard deviation of a Gaussian distribution):
library(rstan)values = list(y = rnorm(1000,5,3))model ="data {real y[1000];}parameters {real mu;real sigma;}model {mu ~ normal(0,10);sigma ~ normal(0,10);y ~ normal(mu,sigma);}"
Read now
Unlock full access