[R-sig-eco] relative habitat use in R
Gonzalez-Mirelis, Genoveva
genovev@@gonz@|ez-m|re||@ @end|ng |rom h|@no
Fri Feb 18 16:04:44 CET 2022
Dear list,
I am trying to calculate Relative Habitat Use as per this paper [https://doi.org/10.1016/j.ecolind.2021.108521], except that my species are sessile, marine invertebrates (including sponges, corals, etc.), and my habitats are rather biotopes. I guess my first question is whether it is legitimate to stretch the interpretation of RHU to this use case? I am trying to quantify the strength of the association of a bunch of species to each of my biotopes.
Another thing I am unsure about is what kind of effect I should expect from the fact that my abundance data are densities, rather than counts at each site?
Lastly, I generally wonder whether I have made any mistake in my calculations. My code is below. Many thanks in advance.
Genoveva
## code start
speciesdata <- data.frame(SampID = c(1:20), Species1 = c(0.2530517,
0.0000000,
0.0000000,
0.0000000,
0.0000000,
0.0000000,
0.0000000,
0.0000000,
0.0000000,
3.8468904,
1.0991115,
0.9617226,
0.0000000,
0.0000000,
0.0000000,
0.0000000,
0.0000000,
0.0000000,
0.0000000,
0.0000000),
biotope = factor(c(rep("A",5), rep("B",7), rep("C",6), rep("B",2))))
# for each species:
# rhu = (n[i]/p[i])/((N-n[i])/(P-p[i]))
# n[i] = no. of individuals in habitat[i]. Would have to use sum of density
# p[i] = no. of sites in habitat[i]
# N = total no. of individuals
# P = total no. of sites
# I still need to set a min acceptable n_i and p_i!!!
sp <- "Species1"
N <- speciesdata %>%
select(sp)%>%
sum # sum all densities
P <- dim(speciesdata)[1]
lev <- levels(speciesdata$biotope)
res <- setNames(data.frame(matrix(ncol = 1, nrow = length(lev))), sp) # empty data frame to store result
#for(n in 1:length(sp)){
for(i in 1:length(lev)){
n_i <- speciesdata %>%
filter(biotope==lev[i])%>%
select(sp)%>%
sum
p_i <- speciesdata %>%
filter(biotope==lev[i])%>%
dim(.)%>%
first
rhu = (n_i/p_i)/((N-n_i)/(P-p_i))
res[i,1]<-rhu
}
#}
res
# So I can conclude that Species1 is strongly associated to biotope B
## code end
[[alternative HTML version deleted]]
More information about the R-sig-ecology
mailing list