[ede2d4]: / inst / stan / base0.stan

Download this file

43 lines (29 with data), 730 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// Gaussian prior on regression coeffs (linear regression)
//
data {
// number of unpenalized columns in model matrix
int U;
// number of observations
int N;
// design matrix
matrix[N, U] X;
// continuous response variable
vector[N] y;
// prior standard deviation for the unpenalised variables
real<lower=0> scale_u;
}
parameters {
// unpenalized regression parameters
vector[U] beta_u;
// residual standard deviation
real <lower=0> sigma;
}
model {
// unpenalized coefficients including intercept
beta_u ~ normal(0, scale_u);
// noninformative gamma priors on scale parameter are not advised
sigma ~ inv_gamma(1, 1);
// likelihood
y ~ normal_id_glm(X, 0, beta_u, sigma);
}