title: How to fix 'Error in sdata[[paste0("Y", usc(resp))]] : subscript out of bounds' in R, using brms package
body: <p>I'm trying to set up priors for my MLM using brms. I have ran my model with the priors I had set with no error messages and now would like to check them using pp_check. I get an the 'Error in sdata[[paste0("Y", usc(resp))]] : subscript out of bounds' error and couldn't find any tips as to why this is happening. Thanks!</p>
  
  <p>Edit: I have checked the structure of my fit and only the init variables are 0, which I think should be the case since I set the initialisation parameter to 0? Otherwise there is nothing problematic as I can see.</p>
  
  <p>I couldn't try anything since googling led to nothing.</p>
  
  <pre><code>library(brms)
  df &lt;- data.frame( subjno = as.factor(c('sub-01', 'sub-01','sub-01','sub-01','sub02','sub02','sub02','sub02')),
                L1 = c(0.898922096, -0.673393065, -2.240150247,-0.932520537, -0.472701111, -0.188825324,0.808675919, 0.293666248), 
                L2 = c(0.64888, 2.0891, -0.655322708, 0.007098555, -0.648887797, -0.249716343, -0.698128026,0.119511014), 
                W1 = c(0.5,0.5,-0.5,-0.5,0.5,-0.5,0.5,-0.5), W2 = c(0.5,-0.5,0.5,-0.5,0.5,0.5,-0.5,-0.5),
                t = as.factor(c(12,23,34,45,12,23,34,45)))
  
  ff_s = brmsformula(cbind(L1,L2) ~ W1 * W2 * t +  
                       (W1*W2* t|p|subjno)) 
  
  get_prior(formula = ff_s, family = gaussian(),
        data = df)
  
  pp_s &lt;- c(set_prior('normal(0,1)', class = "b"),  
      set_prior("normal(0,10)", class = "sd", resp = 'L1'), 
      set_prior("normal(0,10)", class = "sd", resp = 'L2'), 
      set_prior("normal(0,5)", class = "sigma",resp = 'L1'), 
      set_prior("normal(0,5)", class = "sigma",resp = 'L2'),
      set_prior("normal(0,10)", class = "Intercept", resp = 'L1'),
      set_prior("normal(0,10)", class = "Intercept", resp = 'L2'),
      set_prior("lkj(3)", class = "cor"))
  
  fit_s &lt;- brm(formula = ff_s, 
            data = df, family = gaussian(),
            prior = pp_s,
            chains = 6, cores = 3,
            iter = 2e3, warmup = 1e3,
            init = 0,
            sample_prior = "only")
  
  pp_check(fit_s)
  </code></pre>