GJR GARCH model in Stan

Hey. I am new to Stan and starting in the small. I have with success and by the help of the manual estimated a GARCH model on a sample hypothetical sample.

Now I am trying to model a GJR (threshold) GARCH, however, I get the error message:
[[1]] Stan model ‘rstan_GARCH_GJR’ does not contain samples.

I got i to work, had had chosen wrong pars (from the old model). The beneath code runs fine.

I hope You can help. My code is:

data {
  int<lower=0> T;                               //number of observations 
  real r[T];                                    //return data
  real<lower=0> sigma1;                         //First sigma
}

parameters {
  real mu; 
  real<lower=0> omg;                            //Cannot be negative to ensure positive variance
  real<lower=0,upper=1> alpha;                  //Cannot be negative to ensure positive variance  
  real<lower=0> psi;                            //Cannot be negative to ensure positive variance
  real<lower=0> lam;                            //Cannot be negative to ensure positive variance
}

transformed parameters{
  real<lower=0> sigma[T];
  real<lower=0, upper=(1-alpha-psi/2)> bet;     //Upper limit to ensure stationarity
  sigma[1] = sigma1;
  bet = lam - alpha - psi/2 ;                   

  for (t in 2:T)
    sigma[t] = sqrt(omg + (alpha + psi*(step(r[t - 1] - mu)-1)*-1)*pow(r[t - 1] - mu,2) + bet*pow(sigma[t-1],2));
}

model {
  //Data distribution / model
  r~normal(mu, sigma);
  
  //prior distributions
  omg~beta(2, 10);
  alpha~beta(2, 20);
  psi~beta(2,20);
  lam~beta(25, 1.5);
  mu~normal(0, 2);}

Which is called from R using Rstan:

### test
library(ggplot2)
library(rstan)
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())

y <-  list(r = c(0.02, 0.03, 0.05, 0.02, 0.01, 0.02, 0.1), T = 7, sigma1 = 0.01, T_out = 8)

fit <- rstan::stan(file = "/rstan_GARCH_GJR.stan",
                   data = y, iter = 1000, chains = 1, cores = 4, pars = c("mu", "omg", "psi", "lam", "alpha")))

[edit: escaped code]

I’m not sure what you’re asking for help with. The last thing you said is that it runs fine.