How to model Interaction term in Regression equation estimation using stan

Hi,

I am new to stan and currently am trying to estimate a Regression equation which has 2 variables X_1 and X_2 and interaction term between these two, X_1 is categorical variable with 2 levels and X_2 is Integer variable. Based on that, I created below model for stan. However it is failing to execute.

Could you please help me how to correctly define the model based on this?

data {
			int<lower = 0> n;
			vector[n] Y;
			vector[n] X1;
			vector[n] X2;
		}
		parameters {
			real beta0;
			real beta1;
			real beta2;
			real beta3;
			real<lower = 0> sigma;
		}
		model {
			Y     ~ normal(beta0 + beta1 * X1 + beta2 * X2 + beta3 * X1 : X2, sigma);
			beta0 ~ normal(25, 5);
			beta1 ~ normal(0, 37.52);
			beta2 ~ normal(0, 0.82);
			beta3 ~ normal(0, 0.55);
			sigma ~ exponential(0.13);
		}

Have you tried to change this,

to this,

Y ~ normal(beta0 + beta1 * X1 + beta2 * X2 + beta3 * X1 * X2, sigma);

1 Like