Error in X.p[which(!is.na(y)), , drop = FALSE] : subscript out of bounds

9 views
Skip to first unread message

Justin Biggerstaff

unread,
Apr 30, 2026, 12:17:23 PM (11 days ago) Apr 30
to spOccupancy and spAbundance users
Hello all,

I am having this error when I am trying to run a single-species, multi-season model. To my knowledge (based on comparisons to the vignette), my data formatting looks correct. I have three seasons, with three replicates per season, and 74 sites that were surveyed across these seasons. 
List of 4 $ y : int [1:74, 1:3, 1:3] 0 0 0 0 0 0 0 0 1 0 ... $ occ.covs:List of 34 ..$ TreeHeight22: num [1:74] 27.1 28 18.4 20.7 21.6 ... ..$ TreeHeight45: num [1:74] 25.4 26.9 18.9 21.8 23 ... ..$ TreeHeight68: num [1:74] 24.9 26.1 19.4 23.5 23 ... ..$ WetlandPro22: num [1:74] 0 0.0443 0 0 0 ... ..$ WetlandPro45: num [1:74] 0.00133 0.02903 0.01529 0 0 ... ..$ WetlandPro68: num [1:74] 0.0152 0.0322 0.0246 0 0.0117 ... ..$ StreamDen22 : num [1:74] 0 2.2872 0 0.0515 0 ... ..$ StreamDen45 : num [1:74] 0 1.68 0 0.29 0 ... ..$ StreamDen68 : num [1:74] 0.271 1.665 0 0.32 0.193 ... ..$ Art_ADT22 : int [1:74] 105000 8900 32000 74000 71000 160000 71000 120000 87000 29000 ... ..$ Art_ADT45 : int [1:74] 105000 107000 32000 74000 71000 160000 84000 132000 87000 29000 ... ..$ Art_ADT68 : int [1:74] 105000 107000 32000 74000 71000 160000 84000 132000 87000 29000 ... ..$ All_ADT22 : int [1:74] 105000 8900 32000 74000 71000 160000 71000 120000 87000 29000 ... ..$ All_ADT45 : int [1:74] 105000 107000 32000 74000 71000 160000 84000 132000 87000 29000 ... ..$ All_ADT68 : int [1:74] 105000 107000 32000 74000 71000 160000 84000 132000 87000 29000 ... ..$ OpenWater22 : num [1:74] 0 0.000943 0 0 0 ... ..$ OpenWater45 : num [1:74] 0 0.0031 0 0.00709 0 ... ..$ OpenWater68 : num [1:74] 0 0.00202 0 0.00462 0 ... ..$ LocDen_22 : num [1:74] 6.394 8.416 1.08 5.555 0.822 ... ..$ LocDen_45 : num [1:74] 6.151 9.092 1.453 3.968 0.332 ... ..$ LocDen_68 : num [1:74] 6.394 8.416 1.08 5.555 0.822 ... ..$ ForPro_22 : num [1:74] 0.389 0.464 0.706 0.22 0.596 ... ..$ ForPro_45 : num [1:74] 0.426 0.33 0.701 0.236 0.714 ... ..$ ForPro_68 : num [1:74] 0.428 0.296 0.741 0.305 0.735 ... ..$ EdDen22 : num [1:74] 25.9 31.1 23.1 24.5 21.9 ... ..$ EdDen45 : num [1:74] 28.3 29 19.1 25.1 20 ... ..$ EdDen68 : num [1:74] 29.6 26.1 16.2 25.4 18.9 ... ..$ ArtDen22 : num [1:74] 13.4 9.94 10.45 10.21 13.24 ... ..$ ArtDen45 : num [1:74] 15.19 9.37 10.99 11.66 15.36 ... ..$ ArtDen68 : num [1:74] 13.4 9.94 10.45 10.21 13.24 ... ..$ AllDen22 : num [1:74] 17.37 15.19 6.72 17.04 18.57 ... ..$ AllDen45 : num [1:74] 21.3 18.5 12.4 16 16.2 ... ..$ AllDen68 : num [1:74] 19.8 18.4 11.5 16.3 14.4 ... ..$ season : num [1:74, 1:3] 1 1 1 1 1 1 1 1 1 1 ... $ det.covs:List of 7 ..$ Temp : num [1:74, 1:3, 1:3] 23.4 11.3 9.4 13.9 13.3 15.2 23.7 23.5 13.5 7.1 ... ..$ Wind : int [1:74, 1:3, 1:3] 0 0 2 0 0 1 1 1 1 0 ... ..$ Cloud: int [1:74, 1:3, 1:3] 70 0 0 0 0 0 80 90 60 0 ... ..$ Date : int [1:74, 1:3, 1:3] 90 86 86 80 85 70 88 88 78 62 ... ..$ Time : int [1:74, 1:3, 1:3] 58 154 278 281 60 174 71 246 183 111 ... ..$ Noise: int [1:74, 1:3, 1:3] 1 1 1 1 1 1 1 1 1 1 ... ..$ Rain : int [1:74, 1:3, 1:3] 0 0 0 0 0 0 0 0 0 0 ... $ coords : chr [1:74, 1:2] "1698972" "1619551" "1629582" "1679108" ... ..- attr(*, "dimnames")=List of 2 .. ..$ : NULL .. ..$ : chr [1:2] "Easting" "Northing"

I am trying to run a tPGOcc model, with a very basic null occupancy and global detection model to determine which detection covariates may be important. Would anyone know how to fix this issue? 

Justin Biggerstaff

unread,
Apr 30, 2026, 1:29:28 PM (11 days ago) Apr 30
to spOccupancy and spAbundance users
Nevermind, I fixed my issue. I looked into my datafile and saw that some detection covariates got shifted in data entry resulting in a survey where detection data was present for a survey that did not occur. After correcting this, the model ran. Leaving this post up just in case anyone in the future runs into the same problem. 
Reply all
Reply to author
Forward
0 new messages