Dear all,
I want to model bird counts in line-transects, accounting for visit-specific detection variables (e.g. time of the survey, wind, cloud, disturbance..) and site-specific environmental variables (e.g. elevation, slope, solar radiation, NDVI..).
I carried out 3 visits at each transect (within late April and late June 2023), recording the abundance of my target species, let's say chaffinch.
The overall goal is to estimate the effect of my environemental covariates on the abundance of my target species, accounting for uneven detection probabilities, hence I think pcount() is what I need.
Now, the key point is that some siteCovs (namely, NDVI and solar radiation) DO VARY across the three visits: as the season progresses, they both increase at each site. To account for this, I calculated their values at the exact date of each visit (e.g. NDVI_1, NDVI_2, and NDVI_3 ..basically, as if they were obsCovs).
And indeed they can easily be included as obsCovs, yet this would allow me to test their effect as detection variables (i.e. on the detection of chaffinches), rather than on their abundance (which is what I want).
So here is my question: How can I include NDVI and solar radiation as siteCovs in the unmarkedFrame?
Per each of these two variables, I guess that unmarkedFramePCount() should build a single column in the siteCovs section, to be used in the abundance formula in pcount(). (see script below)
Is there any way to do so?:)
Disclaimer: I'm new to unmarked (and this group too), so sorry if my question is silly!
Disclaimer2: I couldn't attach the script, so I paste it here below.
Any help or suggestion is very welcome!
Thanks a lot in advance and best regards,
Corrado Alessandrini
[ EXAMPLE SCRIPT ]
library(unmarked)
set.seed(16)
## 50 transects, visited 3 times each
df <- data.frame( transectID = c(1:50),
n_birds_1 = rpois(50, lambda = 0.7), ## number of birds detected at each visit
n_birds_2 = rpois(50, lambda = 0.9),
n_birds_3 = rpois(50, lambda = 0.9),
## (visit-specific) detection variables [obsCovs]
time_1 = rnorm(50, 6, 1),
time_2 = rnorm(50, 6, 1),
time_3 = rnorm(50, 6, 1),
wind_1 = rpois(50, 1),
wind_2 = rpois(50, 1.2),
wind_3 = rpois(50, 2),
## (constant) site variables [siteCovs]
elevation = rnorm(50, 1000, 300),
slope = rnorm(50, 45, 10),
## VISIT-SPECIFIC siteCovs <------------------ !!!
NDVI_1 = rnorm(50, 5000, 500),
NDVI_2 = rnorm(50, 6000, 700),
NDVI_3 = rnorm(50, 5500, 800)
)
df
## building unmarkedFrame
bird.udf <- with(df,{
unmarkedFramePCount(
y = cbind(n_birds_1,n_birds_2,n_birds_3), ## response variable
## (constant) site covs
siteCovs = data.frame(elevation, slope
,NDVI_1
,NDVI_2
,NDVI_3
),
## (visit-specific) detection variables
obsCovs = list(time = cbind(time_1,time_2,time_3),
wind = cbind(wind_1,wind_2,wind_3),
NDVI = cbind(NDVI_1,NDVI_2,NDVI_3)
)
)})
summary(bird.udf)
## in siteCovs, NDVI is not a single variable,
## so, when modelling, it returns an error
mod1 = pcount( ~ scale(time) + wind
~ scale(elevation) + scale(slope) + scale(NDVI),
mixture="P", K=30,
bird.udf)
## "Error: Variable(s) NDVI not found in siteCovs"
#5: stop(paste("Variable(s)", paste(miss_vars, collapse = ", "),
# "not found in siteCovs"), call. = FALSE)
#4: .local(umf, ...)
#3: getDesign(data, formula)
#2: getDesign(data, formula)
#1: pcount(~scale(time) + wind ~ scale(elevation) + scale(slope) +
# scale(NDVI), mixture = "P", K = 30, bird.udf)
## adding NDVI as "cbind(NDVI_1,NDVI_2,NDVI_3)" in siteCovs still fails in producing a single column
bird.udf2 <- with(df,{
unmarkedFramePCount(
y = cbind(n_birds_1,n_birds_2,n_birds_3), ## response variable
## (constant) site covs
siteCovs = data.frame(elevation, slope
,NDVI = cbind(NDVI_1,NDVI_2,NDVI_3)
),
## (visit-specific) detection variables
obsCovs = list(time = cbind(time_1,time_2,time_3),
wind = cbind(wind_1,wind_2,wind_3),
NDVI = cbind(NDVI_1,NDVI_2,NDVI_3)
)
)})
summary(bird.udf2) ## see, multiple columns for NDVI in siteCovs
## hence, same error is returned
mod1 = pcount( ~ scale(time) + wind
~ scale(elevation) + scale(slope) + scale(NDVI),
mixture="P", K=30,
bird.udf2)
## of course, placing NDVI in the detection formula DOES WORK,
## but it is not what I need, since I want to model the effect of NDVI on the ABUNDANCE (not on the detection) of my target species
mod1 = pcount( ~ scale(time) + wind + scale(NDVI)
~ scale(elevation) + scale(slope),
mixture="P", K=30,
bird.udf)
summary(mod1)
## I think that using NDVI_1, NDVI_2, and NDVI_3 as three separate siteCovariates, e.g.
mod2 = pcount( ~ scale(time) + wind
~ scale(elevation) + scale(slope) + scale(NDVI_1) + scale(NDVI_2) + scale(NDVI_3),
mixture="P", K=30,
bird.udf)
summary(mod2)
## is not an option
## thanks a lot for going through this!!!
## CA - 11 June 2025