I’m having trouble running my stan model I think its because of the R update. I was able to revert to a previous version on my desktop my laptop is having issues with that. I read on there that I need to pass data to stan before running the code. However, I’m not exactly sure how to do that. I’m still learning R and I understand what that means or what to do. Heres the section with the model, I need help with the code to pass data to stan.
--------------------------------------------------
define STAN model
--------------------------------------------------
model <- "
data {
int<lower=0> n;
int<lower=0> k_binary;
int<lower=0> k_ordered;
int<lower=0> y[n,k_binary+k_ordered];
}
parameters {
real alpha[k_binary];
real<lower=0> beta[k_binary+k_ordered];
ordered[2] cut_points;
vector[n] theta;
}
transformed parameters {
}
model {
// priors
theta ~ normal(0,1); //priors on latent variable
alpha ~ normal(0,1); //priors for the intercepts (these are variances not precision)
beta ~ normal(0,1); // priors for the slope. This is truncated so that the lowest possible value is 0
// likelihood (link the parameters to the item values)
for(j in 1:k_binary){
y[,j] ~ bernoulli_logit(alpha[j] + beta[j] * theta);
}
for(j in 1:k_ordered){
y[,k_binary+j] ~ ordered_logistic(beta[k_binary+j] * theta, cut_points);
}
}
"