@@ -10,6 +10,8 @@ add_nmixture = function(model_file,
10
10
orig_trend_model <- orig_trend_model $ trend_model
11
11
}
12
12
13
+ model_data $ ytimes_array <- as.vector(model_data $ ytimes )
14
+
13
15
# ### Perform necessary checks on 'cap' (positive integers, no missing values) ####
14
16
if (! (exists(' cap' , where = data_train ))) {
15
17
stop(' Max abundances must be supplied as a variable named "cap" for N-mixture models' ,
@@ -224,7 +226,8 @@ add_nmixture = function(model_file,
224
226
# Update the data block
225
227
model_file [grep(' int<lower=0> n_nonmissing; // number of nonmissing observations' , model_file , fixed = TRUE )] <-
226
228
paste0(" int<lower=0> n_nonmissing; // number of nonmissing observations\n " ,
227
- " int<lower=0> cap[total_obs]; // upper limits of latent abundances\n " )
229
+ " int<lower=0> cap[total_obs]; // upper limits of latent abundances\n " ,
230
+ ' array[total_obs] int ytimes_array; // sorted ytimes\n ' )
228
231
model_file <- readLines(textConnection(model_file ), n = - 1 )
229
232
230
233
# Update the transformed parameters block
@@ -235,7 +238,7 @@ add_nmixture = function(model_file,
235
238
236
239
model_file [grep(' // latent process linear predictors' ,
237
240
model_file , fixed = TRUE )] <- paste0(' // detection probability\n ' ,
238
- ' p = X * b;\n\n ' ,
241
+ ' p = X[ytimes_array,] * b;\n\n ' ,
239
242
' // latent process linear predictors' )
240
243
model_file <- readLines(textConnection(model_file ), n = - 1 )
241
244
0 commit comments