Hello,

I’m trying to write a partial pooling linear regression model with respect to both the slope and intercept. I’ve worked from an example to produce a random intercept model, which I think works well, see below:

```
data {
int <lower = 1> N; // number of data points
int <lower = 1> D; // number of datasets
vector [N] y; // dependent variable
vector [N] x; // independent variable
int dataset [N]; // dataset identifier
}
parameters {
real alpha0;
real beta0;
vector [D] alpha1;
// vector [D] beta1;
real <lower = 0> sigma;
real <lower = 0> sigma_alpha1;
// real <lower = 0> sigma_beta1;
}
model {
vector [N] alpha = alpha0 + alpha1[dataset];
// vector [N] beta = beta0 + beta1[dataset];
y ~ normal(alpha + beta0 * x, sigma);
// Priors:
alpha1 ~ normal(0, sigma_alpha1);
// beta1 ~ normal(0, sigma_beta1);
}
```

I believe that the posterior estimate of \alpha_1 describes the optimal extent of pooling between intercepts in the different datasets, as indicated by the data.

I wanted to use the same approach for the intercept parameter, \beta. However, I am not able to run the model with those lines un-commented (and changing the model to: `y ~ normal(alpha + beta * x, sigma)`

, because I am not able to multiply the parameter vector \beta by the data vector x.

I have been unable to find a way of structuring a random slope stan model in the same way as for random intercepts. I’m not sure if this is because it is a fundamentally more difficult problem or because I’m not working in the right direction.

Any advice would be much appreciated.