Skip to main content

In the simple case of normally distributed data with unknown mean and variance, Jeffrey's prior is given by $$p(\mu, \sigma^2)=\frac{1}{\sigma^3}.$$$$p(\mu, \sigma^2)=\frac{1}{\sigma^2}.$$ How can I define such a prior in stan or rstanthe Stan language, i.e. how do I need to change the model statement below to obtain the desired result? (The model statement now is for the prior $p(\mu, \sigma^2)\propto 1.$

data {
 int<lower=0> n; // obs in group x
 real x[n];
}
parameters {
 real muX;
 real<lower=0> sigmaSquared;
 real postPred;
}
transformed parameters
{
 real<lower=0> sigmaX;
 sigmaX <- sqrt(sigmaSquared);
}
model {
 x ~ normal(muX, sigmaX);
 postPred ~ normal(muX, sigmaX);
}

In the simple case of normally distributed data with unknown mean and variance, Jeffrey's prior is given by $$p(\mu, \sigma^2)=\frac{1}{\sigma^3}.$$ How can I define such a prior in stan or rstan, i.e. how do I need to change the model statement below to obtain the desired result? (The model statement now is for the prior $p(\mu, \sigma^2)\propto 1.$

data {
 int<lower=0> n; // obs in group x
 real x[n];
}
parameters {
 real muX;
 real<lower=0> sigmaSquared;
 real postPred;
}
transformed parameters
{
 real<lower=0> sigmaX;
 sigmaX <- sqrt(sigmaSquared);
}
model {
 x ~ normal(muX, sigmaX);
 postPred ~ normal(muX, sigmaX);
}

In the simple case of normally distributed data with unknown mean and variance, Jeffrey's prior is given by $$p(\mu, \sigma^2)=\frac{1}{\sigma^2}.$$ How can I define such a prior in the Stan language, i.e. how do I need to change the model statement below to obtain the desired result? (The model statement now is for the prior $p(\mu, \sigma^2)\propto 1.$

data {
 int<lower=0> n; // obs in group x
 real x[n];
}
parameters {
 real muX;
 real<lower=0> sigmaSquared;
 real postPred;
}
transformed parameters
{
 real<lower=0> sigmaX;
 sigmaX <- sqrt(sigmaSquared);
}
model {
 x ~ normal(muX, sigmaX);
 postPred ~ normal(muX, sigmaX);
}
Source Link
Nussig
  • 500
  • 1
  • 4
  • 11

Define own noninformative prior in stan

In the simple case of normally distributed data with unknown mean and variance, Jeffrey's prior is given by $$p(\mu, \sigma^2)=\frac{1}{\sigma^3}.$$ How can I define such a prior in stan or rstan, i.e. how do I need to change the model statement below to obtain the desired result? (The model statement now is for the prior $p(\mu, \sigma^2)\propto 1.$

data {
 int<lower=0> n; // obs in group x
 real x[n];
}
parameters {
 real muX;
 real<lower=0> sigmaSquared;
 real postPred;
}
transformed parameters
{
 real<lower=0> sigmaX;
 sigmaX <- sqrt(sigmaSquared);
}
model {
 x ~ normal(muX, sigmaX);
 postPred ~ normal(muX, sigmaX);
}