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