Dear Stan community,
I have a problem where I have missing data for one of the regressors. Hence, I fit the model by splitting the data into two parts, one with a design matrix with K predictors and a second one with K+1 predictors. I am trying to run the model but I am having problems combining the linear predictors and inputting into bernoulli_logit, see code below:
data {
int<lower=0> N; // number of data items
int<lower=0> K; // number of predictors
matrix[N, K] X; // predictor matrix
int<lower=0> M; // number of data items
int<lower=0> L; // number of data items
matrix[M, L] Z; // predictor matrix
int<lower=0> S; // number of predictors
vector[S] y; // outcome vector
vector[L] mu; // prior mean
vector<lower=0>[L] sig; // prior sd
}
parameters {
vector[K] beta; // coefficients for predictors
real<lower=0> sigma; // error scale
}
model {
vector[S] ydata;
ydata = append_row(X * beta[1:K], Z * beta);
beta ~ normal(mu,sig); // prior distribution of beta
y ~ bernoulli_logit(ydata); // likelihood
}
This yields the error message:
Error in stanc(file = file, model_code = model_code, model_name = model_name, :
0Semantic error in ‘string’, line 22, column 2 to column 29:
Ill-typed arguments to ‘~’ statement. No distribution ‘bernoulli_logit’ was found with the correct signature.
Is there a way to plug this row bind into the likelihood?