With the following model, is it possible to recover the parameter `a[2]`

from the first model by using only the data and the `b`

parameters from the second linear predictor? If so, please could you provide an outline of an implementation of how you going about doing so?

```
data{
int N;
real y[N];
real trt[N];
real sex[N];
}
parameters{
vector[2] a;
vector[3] b;
real<lower=0> sd_e1;
real<lower=0> sd_e2;
}
transformed parameters{
}
model{
vector[N] mu1;
vector[N] mu2;
target += exponential_lpdf(sd_e1 | 1);
target += exponential_lpdf(sd_e2 | 1);
target += normal_lpdf(a | 0, 5);
target += normal_lpdf(b | 0, 5);
for(i in 1:N){
mu1[i] = a[1] + a[2] * trt[i];
mu2[i] = b[1] + b[2] * trt[i] + b[3] * sex[i];
}
target += normal_lpdf(y | mu1, sd_e1);
target += normal_lpdf(y | mu2, sd_e2);
}
```

Data generation

```
set.seed(1)
N <- 100
b <- c(0, 2, -3)
trt <- rbinom(N, 1, 0.5)
sex <- rbinom(N, 1, 0.5)
mu <- b[1] + b[2]*trt + b[3]*sex
y <- rnorm(N, mu, 1)
y
```

Running model:

```
mod1 <- rstan::stan_model(
file = "linreg1.stan",
auto_write = TRUE)
ld <- list(N = N, y = y, x1 = trt, x2 = sex)
l1 <- rstan::sampling(mod1,
data = ld,
chains = 1,
thin = 1,
iter = 2000,
warmup = 1000,
refresh = 1000)
print(l1)
```

Output:

```
mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff Rhat
a[1] -1.59 0.01 0.28 -2.12 -1.78 -1.58 -1.40 -1.06 822 1
a[2] 1.87 0.01 0.40 1.08 1.60 1.87 2.15 2.66 809 1
b[1] 0.15 0.01 0.17 -0.18 0.04 0.14 0.26 0.49 612 1
b[2] 1.74 0.01 0.18 1.37 1.62 1.75 1.88 2.09 852 1
b[3] -3.11 0.01 0.19 -3.51 -3.24 -3.10 -2.98 -2.73 681 1
sd_e1 1.84 0.00 0.13 1.62 1.74 1.84 1.93 2.11 990 1
sd_e2 0.97 0.00 0.07 0.84 0.92 0.96 1.01 1.12 904 1
lp__ -356.64 0.10 2.03 -361.56 -357.72 -356.23 -355.15 -353.80 387 1
```

linreg1.stan (584 Bytes)