@@ -345,6 +345,59 @@ blockedCV <- function(data, options = list(),
345
345
covInPres <- covInPres [! covInPres %in% biasFormlabels ]
346
346
covInPres <- covInPres [! covInPres %in% grepl(' _biasField' , covInPres )]
347
347
348
+ if (sum(grepl(' _spatial' , covInPres )) > 1 ) {
349
+
350
+ spatIn <- covInPres [grepl(' _spatial' , covInPres )]
351
+ if (paste0(predictName ,' _spatial' ) %in% spatIn ) covInPres [! covInPres %in% paste0(dataToUse [! dataToUse %in% predictName ],' _spatial' )]
352
+ else {
353
+ if (any(unlist(data $ .__enclos_env__ $ private $ Family )[names(data $ .__enclos_env__ $ private $ Family ) %in% dataToUse ] %in% c(' poisson' , ' binomial' ))) {
354
+
355
+ keepSpat <- unlist(data $ .__enclos_env__ $ private $ Family )[names(data $ .__enclos_env__ $ private $ Family ) %in% dataToUse ] %in% c(' poisson' , ' binomial' )
356
+ keepSpat <- names(unlist(data $ .__enclos_env__ $ private $ Family )[names(data $ .__enclos_env__ $ private $ Family ) %in% dataToUse ])[keepSpat ][1 ]
357
+ covInPres <- covInPres [! covInPres %in% paste0(dataToUse [! dataToUse %in% keepSpat ],' _spatial' )]
358
+
359
+ } else {
360
+
361
+ keepSpat <- names(unlist(data $ .__enclos_env__ $ private $ Family )[names(data $ .__enclos_env__ $ private $ Family ) %in% dataToUse ])[1 ]
362
+ covInPres <- covInPres [! covInPres %in% paste0(dataToUse [! dataToUse %in% keepSpat ],' _spatial' )]
363
+
364
+ }
365
+
366
+ }
367
+
368
+ }
369
+
370
+ if (sum(grepl(' _intercept' , covInPres )) > 1 ) {
371
+
372
+ intInt <- covInPres [grepl(' _intercept' , covInPres )]
373
+ if (paste0(predictName ,' _intercept' ) %in% intInt ) covInPres [! covInPres %in% paste0(dataToUse [! dataToUse %in% predictName ],' _intercept' )]
374
+ else {
375
+ if (any(unlist(data $ .__enclos_env__ $ private $ Family )[names(data $ .__enclos_env__ $ private $ Family ) %in% dataToUse ] %in% c(' poisson' , ' binomial' ))) {
376
+
377
+ keepInt <- unlist(data $ .__enclos_env__ $ private $ Family )[names(data $ .__enclos_env__ $ private $ Family ) %in% dataToUse ] %in% c(' poisson' , ' binomial' )
378
+ keepInt <- names(unlist(data $ .__enclos_env__ $ private $ Family )[names(data $ .__enclos_env__ $ private $ Family ) %in% dataToUse ])[keepInt ][1 ]
379
+ covInPres <- covInPres [! covInPres %in% paste0(dataToUse [! dataToUse %in% keepInt ],' _intercept' )]
380
+
381
+ } else {
382
+
383
+ keepInt <- names(unlist(data $ .__enclos_env__ $ private $ Family )[names(data $ .__enclos_env__ $ private $ Family ) %in% dataToUse ])[1 ]
384
+ covInPres <- covInPres [! covInPres %in% paste0(dataToUse [! dataToUse %in% keepInt ],' _intercept' )]
385
+
386
+ }
387
+
388
+ }
389
+
390
+ }
391
+ # #grepl(_spatial, covInPres) <- if bigger than 1 <- then keep only predict and PA/Counts BUT KEEP shared_spatial
392
+ # #grepl(_intercept, covInPres) <- then keep only predict and PA/Counts
393
+
394
+ # if not shared spatial
395
+ # Select predData intercept
396
+ # Else if not in, select first non PO
397
+ # Else select PO
398
+
399
+ # Same for intercept
400
+
348
401
if (! is.null(data $ .__enclos_env__ $ private $ speciesName )) {
349
402
350
403
likeSpec <- unique(testLike [[pd ]]$ data [[paste0(data $ .__enclos_env__ $ private $ speciesName , ' INDEX_VAR' )]])
@@ -377,6 +430,7 @@ blockedCV <- function(data, options = list(),
377
430
}
378
431
379
432
}
433
+
380
434
# if bias
381
435
382
436
# covInPres <- intersect(oldIn[[pd]], formula_terms)
0 commit comments