spAbundance model fitting

39 views
Skip to first unread message

Zachary Spicer

unread,
Feb 10, 2025, 3:29:33 PMFeb 10
to spOccupancy and spAbundance users
Hi all, 
I am working on multi-species abundance models for 5 plethodontid species in spAbundance. My data set is comprised of 64 sites each with paired independent transects approximately 10m apart (128 total study areas). Each site was visited at least 3 times and around 90 were visited a 4th time in one season. I have 5 focal species, the most abundant of which is over 1,300 indviduals, the next most abundant has 580, the rest range from 135-250 individuals. My study area spans an area approximately 60km x 100km in the blue ridge mountains. 
I can get the Negative binomial Nmix model to converge, but I am hoping to be able to use the spatial N mixture model. When I run  sfMsNMix using the default parameters laid out in the Nmix vignette the model is far from converging.
I am about to begin the process of model fitting, but I thought it might be a good idea to get some insight on whether this is a fool's errand. I know these complex models are very data hungry. Is there a way to determine if the sfMsNmix model is too complex for my data before I go down the rabbit hole of working on priors and more iterations to get model convergence. I have pasted my sfMsNmix results below if that is helpful.

Thanks, 
Zac

Call:
sfMsNMix(abund.formula = abund.formula, det.formula = det.formula,
    data = data.Nmix, inits = ms.inits, priors = ms.priors,
    tuning = ms.tuning, n.neighbors = 15, n.factors = n.factors,
    n.batch = 1600, batch.length = 25, n.omp.threads = 1, verbose = TRUE,
    n.report = 400, n.burn = 20000, n.thin = 20, n.chains = 3)

Samples per Chain: 40000
Burn-in: 20000
Thinning Rate: 20
Number of Chains: 3
Total Posterior Samples: 3000
Run Time (min): 33.1083

----------------------------------------
Community Level
----------------------------------------
Abundance Means (log scale):
                                                Mean     SD    2.5%     50%   97.5%
(Intercept)                            2.2357 0.4664  1.2997  2.2477  3.0591
scale(elev)                            1.1569 0.8721 -0.7132  1.1960  2.7778
I(scale(elev)^2)                      -2.0228 0.6687 -3.1955 -2.0921 -0.5040
scale(NDVI)                            0.1743 0.2168 -0.2705  0.1784  0.6117
scale(sol_rad)                        -0.3076 0.1842 -0.6670 -0.3068  0.0677
scale(distance_to_stream)             -0.4764 0.2939 -1.0513 -0.4813  0.1147
scale(elev):scale(distance_to_stream)  0.4572 0.3009 -0.1774  0.4787  0.9974
                                        Rhat  ESS
(Intercept)                           1.2898   56
scale(elev)                           1.0774 1889
I(scale(elev)^2)                      1.1241  406
scale(NDVI)                           1.1621  337
scale(sol_rad)                        1.0042  410
scale(distance_to_stream)             1.2308  166
scale(elev):scale(distance_to_stream) 1.0337  136

Abundance Variances (log scale):
                                                Mean      SD   2.5%    50%   97.5%
(Intercept)                           0.8106  2.2663 0.0503 0.2995  4.3226
scale(elev)                           6.9361 31.7475 0.6292 3.7506 27.5210
I(scale(elev)^2)                      2.3157  3.3848 0.3020 1.3785 11.0255
scale(NDVI)                           0.2076  0.3428 0.0337 0.1280  0.8570
scale(sol_rad)                        0.1569  0.2785 0.0250 0.0955  0.6447
scale(distance_to_stream)             0.3764  1.2891 0.0547 0.2072  1.5229
scale(elev):scale(distance_to_stream) 0.3383  0.6351 0.0342 0.1706  1.6767
                                        Rhat  ESS
(Intercept)                           2.8545  110
scale(elev)                           1.6855 1097
I(scale(elev)^2)                      1.0703 2011
scale(NDVI)                           1.0497 3000
scale(sol_rad)                        1.1115 3000
scale(distance_to_stream)             1.1845 3000
scale(elev):scale(distance_to_stream) 1.2103  282

Detection Means (logit scale):
                          Mean     SD    2.5%     50%   97.5%   Rhat  ESS
(Intercept)            -3.0694 0.5182 -3.9089 -3.1361 -1.8233 1.1351   90
scale(day)              0.2786 0.2271 -0.1546  0.2767  0.7366 1.0021 3000
I(scale(day)^2)        -0.2821 0.1665 -0.6250 -0.2782  0.0367 1.0044 2507
scale(atemp)            0.2043 0.2353 -0.2667  0.2044  0.6539 1.0291 1538
scale(gtemp)           -0.2200 0.2270 -0.6663 -0.2245  0.2341 1.0060 2830
scale(hum)              0.6656 0.2079  0.2576  0.6596  1.0860 1.0938 1631
scale(sal.precip_24h)  -0.1231 0.1703 -0.4613 -0.1209  0.2040 1.0002 2462
scale(sal.precip_3day) -0.0021 0.2026 -0.4090  0.0009  0.4112 1.0138 2312
scale(sal.avg_temp)     0.0928 0.1883 -0.2762  0.0914  0.4686 1.0620 1676
scale(sal.dry_days)    -0.1666 0.2028 -0.5796 -0.1632  0.2528 1.0037 2776
Detection Variances (logit scale):
                         Mean     SD   2.5%    50%  97.5%   Rhat  ESS
(Intercept)            1.0038 1.8353 0.0760 0.5278 5.1931 1.0565  655
scale(day)             0.2727 0.4058 0.0439 0.1620 1.1514 1.0340 3000
I(scale(day)^2)        0.1196 0.1803 0.0214 0.0731 0.4995 1.0760 2591
scale(atemp)           0.2096 0.3380 0.0317 0.1228 0.8643 1.0195 2841
scale(gtemp)           0.2395 0.3504 0.0353 0.1465 1.0140 1.0249 3000
scale(hum)             0.2094 0.4421 0.0315 0.1186 0.8248 1.0497 3000
scale(sal.precip_24h)  0.1202 0.1825 0.0218 0.0751 0.5028 1.0103 3000
scale(sal.precip_3day) 0.1695 0.2385 0.0277 0.1022 0.7326 1.0221 3000
scale(sal.avg_temp)    0.1512 0.2566 0.0251 0.0879 0.6318 1.0795 3000
scale(sal.dry_days)    0.1893 0.2714 0.0309 0.1149 0.7876 1.0090 3000

----------------------------------------
Species Level
----------------------------------------
Abundance (log scale):
                                             Mean     SD    2.5%     50%
(Intercept)-cyl                            2.7520 0.7872  1.7474  2.5440
(Intercept)-mon                            2.5644 0.5138  1.4730  2.7389
(Intercept)-ore                            2.2067 0.3308  1.4622  2.2515
(Intercept)-wil                            1.9682 0.5110  1.0095  1.9149
(Intercept)-yon                            2.2842 0.4629  1.3544  2.2946
scale(elev)-cyl                           -0.5582 0.5634 -1.6120 -0.6146
scale(elev)-mon                            3.7423 1.1682  2.2286  3.3064
scale(elev)-ore                            3.0557 0.4530  2.0734  3.0542
scale(elev)-wil                            0.7029 0.3779 -0.0366  0.7013
scale(elev)-yon                            0.7645 0.3936  0.0116  0.7453
I(scale(elev)^2)-cyl                      -3.4200 0.5355 -4.6695 -3.3846
I(scale(elev)^2)-mon                      -1.9940 0.6129 -3.1687 -1.8278
I(scale(elev)^2)-ore                      -1.4842 0.3059 -1.9437 -1.5160
I(scale(elev)^2)-wil                      -1.2739 0.3791 -2.1047 -1.2536
I(scale(elev)^2)-yon                      -3.3259 0.4879 -4.2719 -3.3144
scale(NDVI)-cyl                            0.2027 0.1617 -0.1502  0.2074
scale(NDVI)-mon                           -0.0652 0.1351 -0.3096 -0.0696
scale(NDVI)-ore                            0.3104 0.1909 -0.1251  0.3122
scale(NDVI)-wil                            0.0151 0.2207 -0.4478  0.0258
scale(NDVI)-yon                            0.4244 0.1364  0.1737  0.4232
scale(sol_rad)-cyl                        -0.3300 0.1071 -0.5426 -0.3317
scale(sol_rad)-mon                        -0.1709 0.1513 -0.4532 -0.1599
scale(sol_rad)-ore                        -0.3191 0.1820 -0.6749 -0.3200
scale(sol_rad)-wil                        -0.2175 0.1747 -0.5540 -0.2189
scale(sol_rad)-yon                        -0.4947 0.1230 -0.7265 -0.4955
scale(distance_to_stream)-cyl             -0.4561 0.1706 -0.7819 -0.4561
scale(distance_to_stream)-mon             -0.6901 0.2946 -1.1937 -0.6813
scale(distance_to_stream)-ore             -0.7399 0.3214 -1.3609 -0.7120
scale(distance_to_stream)-wil             -0.5604 0.2737 -1.1234 -0.5657
scale(distance_to_stream)-yon              0.0020 0.1774 -0.3384 -0.0005
scale(elev):scale(distance_to_stream)-cyl  0.7750 0.3612  0.1641  0.7441
scale(elev):scale(distance_to_stream)-mon  0.4700 0.2176  0.0375  0.4941
scale(elev):scale(distance_to_stream)-ore  0.4659 0.3803 -0.5585  0.5011
scale(elev):scale(distance_to_stream)-wil  0.2405 0.3630 -0.5774  0.2732
scale(elev):scale(distance_to_stream)-yon  0.3881 0.3107 -0.2614  0.4017
                                            97.5%    Rhat ESS
(Intercept)-cyl                            4.6624  5.3984   7
(Intercept)-mon                            3.2500  2.9131   5
(Intercept)-ore                            2.7427  1.6625  17
(Intercept)-wil                            3.1767  1.8864  29
(Intercept)-yon                            3.2285  1.0836  40
scale(elev)-cyl                            0.5055  4.5339  23
scale(elev)-mon                            5.6788 13.1529   2
scale(elev)-ore                            3.9103  3.7523  12
scale(elev)-wil                            1.4233  1.5305  48
scale(elev)-yon                            1.5401  1.4529 175
I(scale(elev)^2)-cyl                      -2.4651  1.9087  49
I(scale(elev)^2)-mon                      -1.1626  5.5500   2
I(scale(elev)^2)-ore                      -0.7170  1.1363  10
I(scale(elev)^2)-wil                      -0.6160  1.3861  66
I(scale(elev)^2)-yon                      -2.4489  1.0880 312
scale(NDVI)-cyl                            0.4961  1.3512  78
scale(NDVI)-mon                            0.2146  2.0668  29
scale(NDVI)-ore                            0.6663  1.2783  42
scale(NDVI)-wil                            0.4010  1.3030  83
scale(NDVI)-yon                            0.7023  1.1812 190
scale(sol_rad)-cyl                        -0.1091  1.1798 173
scale(sol_rad)-mon                         0.1470  1.6420  22
scale(sol_rad)-ore                         0.0234  1.5342  69
scale(sol_rad)-wil                         0.1391  1.2850  90
scale(sol_rad)-yon                        -0.2326  1.3280 112
scale(distance_to_stream)-cyl             -0.1240  1.2235  78
scale(distance_to_stream)-mon             -0.0301  2.6950   8
scale(distance_to_stream)-ore             -0.1743  2.2875  13
scale(distance_to_stream)-wil             -0.0097  1.0321  60
scale(distance_to_stream)-yon              0.3684  1.2429  92
scale(elev):scale(distance_to_stream)-cyl  1.5721  1.3447  61
scale(elev):scale(distance_to_stream)-mon  0.8645  1.0158  21
scale(elev):scale(distance_to_stream)-ore  1.0578  1.6840   8
scale(elev):scale(distance_to_stream)-wil  0.8853  1.2935  66
scale(elev):scale(distance_to_stream)-yon  0.9791  1.0272 234

Detection (logit scale):
                              Mean     SD    2.5%     50%   97.5%   Rhat  ESS
(Intercept)-cyl            -2.9532 0.8317 -4.9480 -2.7589 -1.8511 4.6203    8
(Intercept)-mon            -3.5718 0.3818 -4.2885 -3.4990 -2.8809 3.6977    4
(Intercept)-ore            -3.6660 0.4323 -4.5719 -3.6285 -2.9487 4.9604    8
(Intercept)-wil            -3.4031 0.4829 -4.4107 -3.3917 -2.4732 1.5670   27
(Intercept)-yon            -2.7512 0.4892 -3.7183 -2.7613 -1.7965 1.0816   43
scale(day)-cyl              0.6695 0.1598  0.3626  0.6647  0.9982 1.0025 1939
scale(day)-mon             -0.0795 0.0483 -0.1689 -0.0801  0.0178 1.0039 1543
scale(day)-ore              0.1517 0.0850 -0.0087  0.1519  0.3165 0.9999 2157
scale(day)-wil              0.4861 0.1445  0.2084  0.4854  0.7716 1.0009 1261
scale(day)-yon              0.1874 0.1467 -0.1067  0.1888  0.4791 1.0542 1779
I(scale(day)^2)-cyl        -0.2497 0.1176 -0.4880 -0.2473 -0.0268 1.0491  564
I(scale(day)^2)-mon        -0.2494 0.0625 -0.3715 -0.2496 -0.1260 1.0198  551
I(scale(day)^2)-ore        -0.2447 0.0991 -0.4419 -0.2444 -0.0537 1.0188  604
I(scale(day)^2)-wil        -0.3139 0.1420 -0.5996 -0.3111 -0.0344 1.0040  748
I(scale(day)^2)-yon        -0.3611 0.1432 -0.6556 -0.3567 -0.0898 1.1082  597
scale(atemp)-cyl            0.0089 0.2423 -0.4780  0.0096  0.4647 1.1158  694
scale(atemp)-mon            0.0781 0.1058 -0.1228  0.0799  0.2888 1.0457  252
scale(atemp)-ore            0.4068 0.1830  0.0513  0.4032  0.7765 1.1798  391
scale(atemp)-wil            0.3119 0.2513 -0.1590  0.3046  0.8316 1.0070  699
scale(atemp)-yon            0.2555 0.2504 -0.2373  0.2539  0.7469 1.0174 1708
scale(gtemp)-cyl           -0.0693 0.1781 -0.4077 -0.0729  0.2961 1.0014  708
scale(gtemp)-mon           -0.0726 0.0787 -0.2275 -0.0730  0.0789 1.0413  955
scale(gtemp)-ore           -0.0815 0.1449 -0.3621 -0.0824  0.2125 1.1765  676
scale(gtemp)-wil           -0.6422 0.2150 -1.0809 -0.6382 -0.2533 1.1419  764
scale(gtemp)-yon           -0.2835 0.1853 -0.6444 -0.2836  0.0795 1.0057 2380
scale(hum)-cyl              0.8939 0.1867  0.5364  0.8937  1.2527 2.3278   36
scale(hum)-mon              0.3837 0.0872  0.2163  0.3826  0.5539 1.0928  448
scale(hum)-ore              0.6918 0.1119  0.4833  0.6892  0.9208 1.1341  451
scale(hum)-wil              0.7927 0.1924  0.4338  0.7833  1.2045 1.0391  628
scale(hum)-yon              0.5904 0.1708  0.2621  0.5882  0.9273 1.0600  790
scale(sal.precip_24h)-cyl  -0.1740 0.1028 -0.3773 -0.1746  0.0224 1.0605  790
scale(sal.precip_24h)-mon  -0.1094 0.0951 -0.2939 -0.1093  0.0786 1.0084  461
scale(sal.precip_24h)-ore  -0.1339 0.1494 -0.4285 -0.1322  0.1565 1.2893  325
scale(sal.precip_24h)-wil  -0.0917 0.1563 -0.3989 -0.0927  0.2197 1.0172 1113
scale(sal.precip_24h)-yon  -0.1212 0.1508 -0.4236 -0.1208  0.1813 1.0069 1555
scale(sal.precip_3day)-cyl -0.0265 0.1353 -0.2893 -0.0265  0.2445 1.0133  833
scale(sal.precip_3day)-mon  0.0564 0.0948 -0.1257  0.0568  0.2458 1.0789  371
scale(sal.precip_3day)-ore  0.2050 0.1141 -0.0157  0.2021  0.4345 0.9999  602
scale(sal.precip_3day)-wil -0.0614 0.1971 -0.4725 -0.0603  0.3164 1.0411  765
scale(sal.precip_3day)-yon -0.1807 0.2022 -0.6036 -0.1737  0.1937 1.0419 1530
scale(sal.avg_temp)-cyl     0.0659 0.1866 -0.2935  0.0645  0.4419 1.3567  252
scale(sal.avg_temp)-mon     0.0636 0.0969 -0.1313  0.0637  0.2515 1.0253  573
scale(sal.avg_temp)-ore     0.0005 0.1237 -0.2367 -0.0002  0.2359 1.0161  573
scale(sal.avg_temp)-wil     0.2319 0.2112 -0.1573  0.2257  0.6895 1.0861  505
scale(sal.avg_temp)-yon     0.1089 0.1952 -0.2668  0.1078  0.5121 1.0321  984
scale(sal.dry_days)-cyl    -0.4136 0.1581 -0.7265 -0.4122 -0.1074 1.0429 1259
scale(sal.dry_days)-mon    -0.2696 0.0785 -0.4281 -0.2678 -0.1219 1.0497  779
scale(sal.dry_days)-ore     0.0403 0.1071 -0.1734  0.0420  0.2459 1.0490 1428
scale(sal.dry_days)-wil    -0.1746 0.1864 -0.5429 -0.1738  0.1841 1.0629  935
scale(sal.dry_days)-yon    -0.0361 0.2101 -0.4581 -0.0351  0.3786 1.0104 1722

----------------------------------------
Spatial Covariance
----------------------------------------
        Mean     SD  2.5%    50%  97.5%    Rhat ESS
phi-1 0.0024 0.0032 2e-04 0.0006 0.0111 16.5100   7
phi-2 0.0019 0.0020 1e-04 0.0012 0.0069  7.8297   9
phi-3 0.0046 0.0050 5e-04 0.0030 0.0176  3.0529  62

Jeffrey Doser

unread,
Feb 11, 2025, 4:55:56 PMFeb 11
to spOccupancy and spAbundance users
Hi Zac,

The spatial N-mixture models can be pretty tricky to get to converge, especially the multi-species ones that, as you mention, are quite complex and data hungry. The multi-species ones in particular may require some fine-tuning of the priors and in particular the initial values to get things to converge. 64 sites is a fairly modest number of locations for fitting spatial models, so it may be difficult to get them to converge and/or there may be large amounts of uncertainty in the estimates. What I would suggest doing is first trying to get some single-species spatial N-mixture models to fit. Those will run faster than the multi-species model, and will give you a sense of whether it's feasible given your data set. You very well may have to do fine-tuning of the priors and/or initial values in order to get those to converge, but it's probably easier to test around with it using a single-species model relative to a multi-species model. This vignette (even though it's in the context of occupancy models in spOccupancy) has some suggestions on things you can try to play around with. You do have a good amount of replication and it doesn't sound like you have any extremely rare species, so both of those bode well for trying to fit a spatial model.

Jeff
Reply all
Reply to author
Forward
0 new messages