0

I am new to using rJags. I have a jags model in R (version 4.3.0 (2023-04-21 ucrt)) using rjags (rjags_4-14).

I am trying to add a random intercept of "creek" (Clean in the data below) to my model. When using the code below, I get the error:

Error in jags.model(file = model.file, data = data, inits = inits, n.chains = n.chains, : RUNTIME ERROR: Compilation error on line 33. Dimension mismatch in subset expression of Hobs

I know it's something to do with my data expression, and

Hobs

specifically, but I am not sure how to solve myself. I know I will likley need to do the same thing for

Sobs

I have looked at the multiple other posts about this and can't make heads or tails about what I need to do in my specific case. I am guessing I somehow need to make them a matrix but I don't completely understand.

jags_data = list(
  nyrs = nrow(dat), 
  Hobs = dat$EST.1.100m, ##response variable
  Sobs = dat$Redds.100m,
  tauS = 1/0.3^2,
  tauH = 1/0.5^2,
  # number of observations for each group which is used to 
  # create the creek-specific random effect.
  n_creeks1 = max(n_creeks)
  )


jags_model = function() {
  # priors for fixed effects
  #alpha ~ dunif(1, 20)
  beta ~ dunif(0,1)
  sigmaR ~ dunif(0,3)
  tauR <- 1/sigmaR^2
  
  #priors for random effects
  mu_int~dnorm(0, 0.0001) # Mean hyperparameter for random intercepts
  sigma_int~dunif(0, 100) # SD hyperparameter for random intercepts
  tau_int <- 1/(sigma_int*sigma_int)
  
  for (i in 1:n_creeks1) {
    alpha[i]~dnorm(mu_int, tau_int) # Random intercepts
  }

  for (y in 1:1) {
    for (j in 1:n_creeks1) {
      Rmean[y,j] <- log(alpha[y,j])/beta 
      R[y,j] ~ dlnorm(log(Rmean[y,j]), tauR)
    }
  }

  for (y in 2:nyrs) {
    for (j in 1:n_creeks1) {
    Rmean[y,j] <- alpha[j] * S[y-1] * exp(-beta * S[y-1])
    R[y,j] ~ dlnorm(log(Rmean[y,j]), tauR)
    }
  }
 
  for (y in 1:nyrs) {
    for (j in 1:n_creeks1) {
      U[y,j] ~ dbeta(1,1)          
      H[y,j] <- R[y,j] * U[y,j]        
      S[y,j] <- R[y,j] * (1 - U[y,j]) 
    }
  }

  for (y in 1:nyrs) {
    for (j in 1:n_creeks1) {
    Sobs[y,j] ~ dlnorm(log(S[y,j]), tauS)
    Hobs[y,j] ~ dlnorm(log(H[y,j]), tauH)
    }
  }
 




jags_file_ranef = "model_ranef.txt"
write_model(jags_model, jags_file_ranef)


jags_inits = function(nc) {
  inits = list()
  for (c in 1:nc) {
    inits[[c]] = list(
      alpha = runif(n_creeks1, 4, 8),
      beta = runif(1, 0.1, 0.5),
      sigmaR = runif(1, 0.2, 0.5),
      U = with(jags_data, rbeta(nyrs, 100 * Hobs/(Hobs+Sobs), 100 * (1 - Hobs/(Hobs+Sobs)))),
      R = with(jags_data, rlnorm(nyrs, log(Hobs + Sobs), 0.1))
    )
  }
  return(inits)
}

jags_params = c(
  "alpha", "beta", "sigmaR",
  "R", "S", "H", "U")


jags_dims = c(
  ni = 50000,  # number of post-burn-in samples per chain
  nb = 20000,  # number of burn-in samples
  nt = 10,     # thinning rate
  nc = 2      # number of chains
)

with(as.list(jags_dims), ni/nt * nc)


post = jagsUI::jags.basic(
  data = jags_data,
  model.file = jags_file_ranef,
  inits = jags_inits(jags_dims["nc"]),
  parameters.to.save = jags_params,
  n.adapt = 1000,
  n.iter = sum(jags_dims[c("ni", "nb")]),
  n.thin = jags_dims["nt"],
  n.burnin = jags_dims["nb"],
  n.chains = jags_dims["nc"],
  parallel = F
)




Data:

dput(dat)
structure(list(EST.1.100m = c(50.03436426, 29.6619718333333, 
21.3333333333333, 17.5644444466667, 10.9090909066667, 1.33333333333333, 
3.926589776, 9.74298464, 12.6666666666667, 25.6666666666667, 
18.73469388, 16.11965812, 28.6349206333333, 58.4074074066667, 
36.7659574466667, 30.1363636333333, 32.37777778, 10, 13.93939394, 
32.6210045666667, 46.7801418466667, 44.12658228, 36.9047619066667, 
37.5257731933333, 19.53488372, 23.8095238066667, 4.8, 1.10168078533333, 
12.6, 50.08695652, 7.33333333333333, 7.33333333333333, 18.5365853666667, 
20, 52.52252252, 10.2941176466667, 18.7659574466667, 15.97222222, 
2.35121559666667, 9.91256651333333, 7.06542329333333, 2.66666666666667, 
2.35121559666667, 9.33333333333333, 14.6363636333333, 10.3703703733333, 
1.33333333333333, 3.33333333333333, 2.66666666666667, 8.22925458666667, 
16.6962962933333, 10.98039216, 23.5294117666667, 3.54166666666667, 
9.53333333333333, 21.10638298, 21.3333333333333, 15.05376344, 
29.7721519, 19.25, 25.2470588266667, 29.5909090933333, 21.09722222, 
26.57777778, 10.98039216, 30.68992248, 22.2189054733333, 24.9263157866667, 
16.4833333333333, 19.0188679266667, 37.5, 20.73429952, 39.79288026, 
20.1165048533333, 30.3003663, 21.81818182, 21.3918128666667, 
19.6756756733333, 20.6666666666667, 2.836471968, 13.0888888866667, 
12.6666666666667, 8.15514054, 10, 4.41666666666667, 6.96, 8.5106383, 
21.3333333333333, 32.4133333333333, 14.875, 10.7916666666667, 
8.08080808, 10.2702702733333, 25.14285714, 7.56989247333333, 
14.9787234066667, 15.44827586, 19.1020408133333, 7.55555555333333, 
7.33333333333333, 7.98039216, 18.60465116, 16.1333333333333, 
2.66666666666667, 6.66666666666667, 4.66666666666667, 5.33333333333333, 
24, 20.6666666666667, 30.4411764733333, 23.2962962933333, 63.05084746, 
20.6666666666667, 58.5347985333333, 49.18996416, 35.4430379733333, 
48.32982456, 57.1358024666667, 26.1333333333333, 59.9925925933333, 
77.0833333333333, 65.3195876266667, 62.58064516, 52.5821596266667, 
105, 32.3037974666667, 17.90804598, 25.31073446, 9.52, 24.92307692, 
9.33333333333333, 20.3333333333333, 13, 11, 27.90277778, 15.3333333333333, 
25.1700680266667, 14.31884058, 16.6666666666667, 16, 41.95767196, 
24.5333333333333, 13.8461538466667, 13.0666666666667, 15.3333333333333, 
11.3333333333333, 20.5050505066667, 18.75, 9.33333333333333, 
14.71264368, 83.8666666666667, 50.9390681, 27.2333333333333, 
50.30420712, 57.11442786, 75.8137254666667, 46.8841607533333, 
64.5882352933333, 3.401360544, 62.84126984, 12.4, 57.92063492, 
1.50617283933333, 57.7073170733333, 5.33333333333333, 20.5333333333333, 
25.7627118666667, 23.4347826066667, 19.7727272733333, 16.1, 27.1515151533333, 
45.6038647333333, 3.33333333333333, 0.666666666666667, 5.33333333333333, 
6.588235294, 33.25170068, 32.3076923066667, 3.33333333333333, 
4.24036956666667, 6, 5.30975916533333, 9.62962962666667, 4.66666666666667, 
21.77777778, 11.6875, 3.33333333333333, 5.650301078, 12.5714285733333, 
1.33333333333333, 6, 3.33333333333333, 24.6153846133333, 15.3333333333333, 
2.21329558933333, 36.8609271533333, 25.3255813933333, 30.0487804866667, 
4.925925926, 4.48697225266667, 2.66666666666667, 10, 8.04597701333333, 
11.3333333333333, 10, 12, 2.78260869533333, 2.66666666666667, 
8.28571428666667, 21.2105263133333, 8.35555555333333, 27.3684210533333, 
30.5217391333333, 17.9523809533333, 13.8730158733333, 2.66666666666667, 
24.48979592, 35.7894736866667, 0.666666666666667, 16.6666666666667, 
35.23497268, 5.33333333333333, 17.0542635666667, 9.33333333333333, 
6, 12.3529411733333, 1.33333333333333, 14.6031746, 2.66666666666667, 
7.33333333333333, 31.1538461533333, 13.2173913066667, 7.43589743333333, 
14.6666666666667, 15.3333333333333, 20.8333333333333, 25.1234567933333, 
25.81560284, 15.3333333333333, 19.54285714, 10.7466666666667, 
9.33333333333333, 8, 16, 19.9689922466667, 10, 15.12, 2.19047619066667, 
12.0888888866667, 19.3333333333333, 2.823529412, 13.3333333333333, 
9.16594128, 19.8333333333333, 22.6285714266667, 10.9090909066667, 
16.2095238066667, 29.2307692333333, 15.5833333333333, 14.98245614, 
40.18079096, 36.8547008533333, 31.9444444466667, 9.89333333333333, 
4.336925954, 69.5338346, 13.87755102, 14.9333333333333, 26.08955224, 
47.37078652, 22.8194444466667, 25.5163398666667, 3.43434343466667, 
11.6097561, 15.5555555533333, 10.4347826066667, 18.12121212, 
17.3333333333333, 16.7272727266667, 51.24919094, 19.1489361733333, 
27.9545454533333, 9.82222222, 13.5714285733333, 9.62962962666667, 
6.02898550733333, 20.45410628, 3.97987201733333, 39.3734939733333, 
2.73873873866667, 8.04828215333333, 20.8627451, 22.5333333333333, 
34.5570776266667, 15.05376344, 9.04901960666667, 35.4020618533333, 
60.5984252, 58.4806201533333, 40.3045267466667, 2.89493785933333, 
40.0650406533333, 9.33333333333333, 24.1935483866667), Redds.100m = c(0.328478152507479, 
0.342164742195291, 0.437970870009972, 0.218985435004986, 0.0273731793756233, 
0.150552486565928, 0.191612255629363, 0.0821195381268698, 0.177925665941551, 
0.410597690634349, 0.465344049385595, 0.437970870009972, 0.301104973131856, 
0.16423907625374, 0.16423907625374, 0.150552486565928, 0.205298845317174, 
0.50640381844903, 0.547463587512465, 0.287418383444044, 0.314791562819667, 
0.109492717502493, 0.123179307190305, 0.0821195381268698, 0.109492717502493, 
0.287418383444044, 0.0547463587512465, 0.218985435004986, 0.218985435004986, 
0.0547463587512465, 0.191612255629363, 0.396911100946537, 0.863015604357746, 
0.500549050527492, 0.586850610963267, 0.172603120871549, 0.103561872522929, 
0.224384057133014, 0.241644369220169, 0.120822184610084, 0.0517809362614647, 
0.0517809362614647, 0.0517809362614647, 0.0690412483486196, 0.0690412483486196, 
0.0517809362614647, 0.0690412483486196, 0.103561872522929, 0.189863432958704, 
0.396987178004563, 0.0690412483486196, 0.155342808784394, 0.0690412483486196, 
0.0863015604357746, 0.138082496697239, 0.0863015604357746, 0.466028426353183, 
3.39926568550944, 2.48548458725422, 3.56374628319538, 2.86927264852141, 
3.39926568550944, 4.73338608896207, 3.01547762424225, 2.77789453869589, 
3.07030449013756, 2.90582389245162, 3.25306070978861, 3.41754130747455, 
3.19823384389329, 2.44893334332401, 2.11997214795212, 1.66308159882451, 
1.55342786703388, 1.53515224506878, 1.37067164738284, 1.40722289131305, 
0.731024878604181, 0.511717415022927, 0.639646768778658, 0.603095524848449, 
0.440137939230155, 0.34952130468277, 0.401302238709847, 0.854385411446771, 
0.414247472216616, 1.10034484807539, 0.919111578980617, 0.595480741311386, 
1.178016249116, 0.69904260936554, 1.03561868054154, 0.86733064495354, 
0.841440177940002, 0.802604477419694, 0.970892513007694, 0.893221111967079, 
0.932056812487387, 0.737878309885848, 0.168288035588, 0.34952130468277, 
0.245959436628616, 0.478973639750462, 0.168288035588, 0.297740370655693, 
0.323630837669231, 0.103561868054154, 0.257641729473153, 0.257641729473153, 
0.121243166810896, 0.242486333621791, 0.409195687986772, 0.363729500432687, 
0.621371229905839, 0.500128063094944, 0.681992813311287, 0.409195687986772, 
0.560749646500392, 0.439506479689496, 0.575905042351754, 0.363729500432687, 
0.46981727139222, 0.424351083838134, 0.212175541919067, 0.454661875540858, 
0.670915730816636, 0.867029559824575, 1.75470268059735, 1.9611382900794, 
1.45537104684839, 1.39344036400378, 1.36247502258148, 1.05282160835841, 
0.949603803617392, 1.20764831546994, 0.774133535557656, 1.40376214447788, 
1.40376214447788, 0.949603803617392, 1.03217804741021, 0.608985047972023, 
0.815420657454065, 0.433514779912288, 0.9908909255138, 1.20764831546994, 
0.712202852713044, 0.639950389394329, 0.660593950342533, 0.268366292326654, 
0.309653414223063, 0.533824052873351, 0.612118247294775, 0.47688282056686, 
0.704647749792823, 0.37011800999219, 0.348765047877256, 0.355882701915567, 
0.448412204413615, 0.170823696919472, 0.32029443172401, 0.121000118651293, 
0.0996471565363588, 0.149470734804538, 0.199294313072718, 0.0640588863448021, 
0.277588507494142, 0.249117891340897, 0.21352962114934, 0.355882701915567, 
0.284706161532454, 0.21352962114934, 0.15658838884285, 0.0711765403831134, 
0.0782941944214248, 0.149470734804538, 0.306059123647388, 0.384353318068812, 
0.37011800999219, 0.384353318068812, 0.448412204413615, 0.227764929225963, 
0.284706161532454, 0.277588507494142, 0.149470734804538, 0.232166955901328, 
0.104074842300595, 0.0320230284001831, 0.0240172713001374, 0.0480345426002747, 
0.0320230284001831, 0.0240172713001374, 0.0720518139004121, 0.0720518139004121, 
0.0480345426002747, 0.0480345426002747, 0.510716028127402, 0.638395035159252, 
0.297917683074318, 0.31210423941119, 0.368850464758679, 0.482342915453657, 
0.411410133769296, 0.297917683074318, 0.297917683074318, 0.226984901389956, 
0.43978324644304, 0.411410133769296, 0.62420847882238, 0.482342915453657, 
0.453969802779913, 0.759453644445437, 0.207123721212392, 0.184109974411015, 
0.115068734006884, 0.0920549872055075, 0.0230137468013769, 0.0230137468013769, 
0.0690412404041306, 0.0460274936027537, 0.0460274936027537, 0.43726118922616, 
0.0460274936027537, 0.230137468013769, 0.207123721212392, 0.0920549872055075, 
0.0230137468013769, 0.184109974411015, 0.0460274936027537, 0.322192455219276, 
0.36821994882203, 0.924831568663181, 0.13005443934326, 0.968183048444267, 
2.03751954971107, 0.85257910236137, 1.64735623168129, 1.76296017776419, 
1.22829192713079, 1.35834636647405, 1.48840080581731, 1.63290573842093, 
1.77741067102455, 0.85257910236137, 0.867029595621732, 0.520217757373039, 
0.563569237154126, 0.794777129319921, 0.794777129319921, 0.679173183237023, 
0.505767264112677, 0.260108878686519, 0.823678115840645, 0.346811838248693, 
0.173405919124346, 0.534668250633401, 0.317910851727968, 1.1160935143885, 
1.13192462806777, 0.941951263916538, 0.862795695520191, 0.0949866820756173, 
0.253297818868313, 0.221635591509774, 0.277044489387217, 0.134564466273791, 
0.316622273585391, 0.387862285142104, 0.569920092453704, 0.609497876651878, 
0.562004535614069, 0.269128932547582, 0.324537830425026, 0.308706716745756, 
0.443271183019547, 0.213720034670139, 0.284960046226852, 0.340368944104295, 
0.245382262028678, 0.229551148349409, 0.269128932547582, 0.245382262028678, 
0.213720034670139, 0.229551148349409, 0.284960046226852, 0.205804477830504, 
0.253297818868313, 0.528165513401734, 0.636905472043267, 0.217479917283067, 
0.0466028394178, 0.1398085182534, 0.0776713990296667, 0.155342798059333, 
0.0776713990296667, 0.730111150878867, 0.621371192237334, 0.481562673983934, 
0.217479917283067, 0.403891274954267, 0.2796170365068, 0.3262198759246, 
0.264082756700867, 0.217479917283067, 0.233014197089), Clean = c("Big CR", 
"Big CR", "Big CR", "Big CR", "Big CR", "Big CR", "Big CR", "Big CR", 
"Big CR", "Big CR", "Big CR", "Big CR", "Big CR", "Big CR", "Big CR", 
"Big CR", "Big CR", "Big CR", "Big CR", "Big CR", "Big CR", "Big CR", 
"Big CR", "Big CR", "Big CR", "Big CR", "Big CR", "Big CR", "Big CR", 
"Big CR", "Big CR", "Big CR", "Coal CR", "Coal CR", "Coal CR", 
"Coal CR", "Coal CR", "Coal CR", "Coal CR", "Coal CR", "Coal CR", 
"Coal CR", "Coal CR", "Coal CR", "Coal CR", "Coal CR", "Coal CR", 
"Coal CR", "Coal CR", "Coal CR", "Coal CR", "Coal CR", "Coal CR", 
"Coal CR", "Coal CR", "Coal CR", "Coal CR", "Elk CR", "Elk CR", 
"Elk CR", "Elk CR", "Elk CR", "Elk CR", "Elk CR", "Elk CR", "Elk CR", 
"Elk CR", "Elk CR", "Elk CR", "Elk CR", "Elk CR", "Elk CR", "Elk CR", 
"Elk CR", "Elk CR", "Elk CR", "Elk CR", "Elk CR", "Elk CR", "Elk CR", 
"Elk CR", "Goat CR", "Goat CR", "Goat CR", "Goat CR", "Goat CR", 
"Goat CR", "Goat CR", "Goat CR", "Goat CR", "Goat CR", "Goat CR", 
"Goat CR", "Goat CR", "Goat CR", "Goat CR", "Goat CR", "Goat CR", 
"Goat CR", "Goat CR", "Goat CR", "Goat CR", "Goat CR", "Goat CR", 
"Goat CR", "Goat CR", "Goat CR", "Granite CR", "Granite CR", 
"Granite CR", "Granite CR", "Granite CR", "Granite CR", "Granite CR", 
"Granite CR", "Granite CR", "Granite CR", "Granite CR", "Granite CR", 
"Granite CR", "Granite CR", "Granite CR", "Granite CR", "Granite CR", 
"Granite CR", "Lion CR", "Lion CR", "Lion CR", "Lion CR", "Lion CR", 
"Lion CR", "Lion CR", "Lion CR", "Lion CR", "Lion CR", "Lion CR", 
"Lion CR", "Lion CR", "Lion CR", "Lion CR", "Lion CR", "Lion CR", 
"Lion CR", "Lion CR", "Lion CR", "Lion CR", "Lion CR", "Lion CR", 
"Lion CR", "Lion CR", "Morrison CR", "Morrison CR", "Morrison CR", 
"Morrison CR", "Morrison CR", "Morrison CR", "Morrison CR", "Morrison CR", 
"Morrison CR", "Morrison CR", "Morrison CR", "Morrison CR", "Morrison CR", 
"Morrison CR", "Morrison CR", "Morrison CR", "Morrison CR", "Morrison CR", 
"Morrison CR", "Morrison CR", "Morrison CR", "Morrison CR", "Morrison CR", 
"Morrison CR", "Morrison CR", "Morrison CR", "Morrison CR", "Morrison CR", 
"Morrison CR", "Morrison CR", "Morrison CR", "Morrison CR", "Morrison CR", 
"Morrison CR", "NF Coal CR", "NF Coal CR", "NF Coal CR", "NF Coal CR", 
"NF Coal CR", "NF Coal CR", "NF Coal CR", "NF Coal CR", "NF Coal CR", 
"NF Coal CR", "NF Coal CR", "Ole CR", "Ole CR", "Ole CR", "Ole CR", 
"Ole CR", "Ole CR", "Ole CR", "Ole CR", "Ole CR", "Ole CR", "Ole CR", 
"Ole CR", "Ole CR", "Ole CR", "Ole CR", "SF Coal CR", "SF Coal CR", 
"SF Coal CR", "SF Coal CR", "SF Coal CR", "SF Coal CR", "SF Coal CR", 
"SF Coal CR", "SF Coal CR", "SF Coal CR", "SF Coal CR", "SF Coal CR", 
"SF Coal CR", "SF Coal CR", "SF Coal CR", "SF Coal CR", "SF Coal CR", 
"SF Coal CR", "SF Coal CR", "SF Coal CR", "Squeezer CR", "Squeezer CR", 
"Squeezer CR", "Squeezer CR", "Squeezer CR", "Squeezer CR", "Squeezer CR", 
"Squeezer CR", "Squeezer CR", "Squeezer CR", "Squeezer CR", "Squeezer CR", 
"Squeezer CR", "Squeezer CR", "Squeezer CR", "Squeezer CR", "Squeezer CR", 
"Squeezer CR", "Squeezer CR", "Squeezer CR", "Squeezer CR", "Squeezer CR", 
"Squeezer CR", "Squeezer CR", "Squeezer CR", "Squeezer CR", "Whale CR", 
"Whale CR", "Whale CR", "Whale CR", "Whale CR", "Whale CR", "Whale CR", 
"Whale CR", "Whale CR", "Whale CR", "Whale CR", "Whale CR", "Whale CR", 
"Whale CR", "Whale CR", "Whale CR", "Whale CR", "Whale CR", "Whale CR", 
"Whale CR", "Whale CR", "Whale CR", "Whale CR", "Whale CR", "Whale CR", 
"Whale CR", "Whale CR", "Whale CR", "Whale CR", "Whale CR", "Wounded Buck CR", 
"Wounded Buck CR", "Wounded Buck CR", "Wounded Buck CR", "Wounded Buck CR", 
"Wounded Buck CR", "Wounded Buck CR", "Wounded Buck CR", "Wounded Buck CR", 
"Wounded Buck CR", "Wounded Buck CR", "Wounded Buck CR", "Wounded Buck CR", 
"Wounded Buck CR", "Wounded Buck CR", "Wounded Buck CR", "Wounded Buck CR", 
"Wounded Buck CR"), Year = c(1989L, 1990L, 1991L, 1992L, 1993L, 
1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 
2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 
2012L, 2013L, 2015L, 2016L, 2017L, 2018L, 2020L, 2021L, 2022L, 
1989L, 1990L, 1991L, 1993L, 1994L, 1995L, 1998L, 1999L, 2000L, 
2003L, 2004L, 2005L, 2007L, 2008L, 2010L, 2011L, 2012L, 2013L, 
2014L, 2015L, 2017L, 2018L, 2019L, 2021L, 2022L, 1989L, 1990L, 
1994L, 1995L, 1997L, 1998L, 2001L, 2002L, 2003L, 2005L, 2006L, 
2007L, 2008L, 2009L, 2010L, 2012L, 2013L, 2014L, 2015L, 2016L, 
2018L, 2019L, 2021L, 2022L, 1989L, 1990L, 1991L, 1994L, 1995L, 
1997L, 1998L, 1999L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 
2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 2014L, 2016L, 
2017L, 2019L, 2021L, 2003L, 2004L, 2005L, 2006L, 2008L, 2009L, 
2010L, 2011L, 2012L, 2013L, 2014L, 2015L, 2016L, 2017L, 2018L, 
2019L, 2021L, 2022L, 1988L, 1989L, 1995L, 1997L, 1998L, 1999L, 
2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 
2010L, 2012L, 2013L, 2014L, 2015L, 2016L, 2017L, 2018L, 2019L, 
2021L, 1980L, 1982L, 1983L, 1985L, 1986L, 1987L, 1988L, 1989L, 
1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 
1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2006L, 2007L, 2010L, 
2013L, 2014L, 2015L, 2016L, 2017L, 2019L, 2020L, 2021L, 1989L, 
1990L, 1992L, 2000L, 2007L, 2008L, 2009L, 2012L, 2013L, 2014L, 
2019L, 1986L, 1987L, 1989L, 1998L, 1999L, 2000L, 2001L, 2002L, 
2003L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 1989L, 1990L, 
1991L, 1992L, 1997L, 2000L, 2003L, 2007L, 2008L, 2009L, 2010L, 
2011L, 2012L, 2013L, 2014L, 2015L, 2017L, 2018L, 2021L, 2022L, 
1987L, 1988L, 1989L, 1998L, 1999L, 2001L, 2002L, 2003L, 2004L, 
2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 
2014L, 2015L, 2016L, 2017L, 2018L, 2019L, 2021L, 2022L, 1983L, 
1987L, 1989L, 1990L, 1992L, 1994L, 1995L, 1996L, 1997L, 1998L, 
1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 
2008L, 2009L, 2010L, 2012L, 2013L, 2015L, 2016L, 2017L, 2018L, 
2019L, 2021L, 1995L, 1996L, 1997L, 2000L, 2001L, 2002L, 2003L, 
2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2017L, 2018L, 2020L, 
2021L, 2022L)), class = "data.frame", row.names = c(11L, 12L, 
13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 
26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 37L, 38L, 39L, 
40L, 42L, 43L, 44L, 55L, 56L, 57L, 59L, 60L, 61L, 64L, 65L, 66L, 
69L, 70L, 71L, 73L, 74L, 76L, 77L, 78L, 79L, 80L, 81L, 83L, 84L, 
85L, 87L, 88L, 96L, 97L, 101L, 102L, 104L, 105L, 108L, 109L, 
110L, 112L, 113L, 114L, 115L, 116L, 117L, 119L, 120L, 121L, 122L, 
123L, 125L, 126L, 128L, 129L, 137L, 138L, 139L, 142L, 143L, 145L, 
146L, 147L, 149L, 150L, 151L, 152L, 153L, 154L, 155L, 156L, 157L, 
158L, 159L, 160L, 161L, 162L, 164L, 165L, 167L, 169L, 195L, 196L, 
197L, 198L, 200L, 201L, 202L, 203L, 204L, 205L, 206L, 207L, 208L, 
209L, 210L, 211L, 213L, 214L, 221L, 222L, 228L, 230L, 231L, 232L, 
234L, 235L, 236L, 237L, 238L, 239L, 240L, 241L, 242L, 243L, 245L, 
246L, 247L, 248L, 249L, 250L, 251L, 252L, 254L, 263L, 265L, 266L, 
268L, 269L, 270L, 271L, 272L, 273L, 274L, 275L, 276L, 277L, 278L, 
279L, 280L, 281L, 282L, 283L, 284L, 285L, 286L, 287L, 289L, 290L, 
293L, 296L, 297L, 298L, 299L, 300L, 302L, 303L, 304L, 313L, 314L, 
316L, 324L, 331L, 332L, 333L, 335L, 336L, 337L, 342L, 352L, 353L, 
355L, 364L, 365L, 366L, 367L, 368L, 369L, 371L, 372L, 373L, 374L, 
375L, 376L, 395L, 396L, 397L, 398L, 403L, 406L, 409L, 413L, 414L, 
415L, 416L, 417L, 418L, 419L, 420L, 421L, 423L, 424L, 427L, 428L, 
434L, 435L, 436L, 445L, 446L, 448L, 449L, 450L, 451L, 452L, 453L, 
454L, 455L, 456L, 457L, 458L, 459L, 460L, 461L, 462L, 463L, 464L, 
465L, 466L, 468L, 469L, 481L, 485L, 487L, 488L, 490L, 492L, 493L, 
494L, 495L, 496L, 497L, 498L, 499L, 500L, 501L, 502L, 503L, 504L, 
505L, 506L, 507L, 508L, 510L, 511L, 513L, 514L, 515L, 516L, 517L, 
519L, 523L, 524L, 525L, 528L, 529L, 530L, 531L, 533L, 534L, 535L, 
536L, 537L, 538L, 545L, 546L, 548L, 549L, 550L))




vermicellion
  • 338
  • 2
  • 14
  • Your general diagnosis is correct. The problem is with the dimensionality of `Sobs` and `Hobs`. You start off by defining them as vectors (eg `Hobs = dat$EST.1.100m`) but then reference them as matrices (eg `Sobs[y,j] ~ dlnorm(log(S[y,j]), tauS)`). Unfortunately, you question is not reproducible as you've given us neither test data nor context - that is, a description of the model you're trying to fit. It's really up to you to work out the *correct* way of fixing the problem. JAGS models can be complex. That makes questions about them dificult to answer, even with complete information. – Limey Aug 03 '23 at 09:16
  • @Limey okay, I added the dataset. I am trying to fit a nonlinear model with random effects. – vermicellion Aug 03 '23 at 14:44

0 Answers0