Dear Benoit,
From a purely technical point of view, when such a problem arises, you
can try to change the code of the function with the function edit().
That is, to type:
mcp <- edit(mcp)
at the prompt and look for the lines of code that you want to remove. In
this case, you just have to remove:
if (min(table(id)) < 5)
stop("At least 5 relocations are required to fit an home range")
Therefore, copy-paste the following function in R, to remove this
constraint:
mcp <- function (xy, id, percent = 95)
{
if (length(id) != nrow(xy))
stop("xy and id should be of the same length")
if (percent > 100) {
warning("The MCP is estimated using all relocations (percent>100)")
percent <- 100
}
id <- id[!is.na(xy[, 1])]
id <- id[!is.na(xy[, 2])]
xy <- xy[!is.na(xy[, 1]), ]
xy <- xy[!is.na(xy[, 2]), ]
id <- factor(id)
r <- split(xy, id)
est.cdg <- function(xy) apply(xy, 2, mean)
cdg <- lapply(r, est.cdg)
levid <- levels(id)
X <- 0
Y <- 0
ID <- "0"
for (i in 1:nlevels(id)) {
k <- levid[i]
df.t <- r[[levid[i]]]
cdg.t <- cdg[[levid[i]]]
dist.cdg <- function(xyt) {
d <- sqrt(((xyt[1] - cdg.t[1])^2) + ((xyt[2] - cdg.t[2])^2))
return(d)
}
di <- apply(df.t, 1, dist.cdg)
key <- c(1:length(di))
acons <- key[di <= quantile(di, percent/100)]
xy.t <- df.t[acons, ]
coords.t <- chull(xy.t[, 1], xy.t[, 2])
xy.bord <- xy.t[coords.t, ]
X <- c(X, xy.bord[, 1])
Y <- c(Y, xy.bord[, 2])
ID <- c(ID, rep(as.character(levid[i]), nrow(xy.bord)))
}
ID <- as.data.frame(ID)
res <- cbind.data.frame(ID, X, Y)
res <- res[-1, ]
res[, 1] <- factor(res[, 1])
names(res) <- c("ID", "X", "Y")
res <- as.area(res)
return(res)
}
HTH,
Clément Calenge
On 12/06/2011 02:45 PM, es...@mnhn.fr wrote:
Dear AniMove list
I would like to calculate an area using 100%MCP based on at least 3
geolocalized points (eg traps); Unfortunately, there is an error
message in ?adehabitat? indicating that MCP cannot be calculated with
less than 5 coordinates (which is ? of course - obviously fine for the
vast majority of home range analyses).
However, my main aim is to investigate if core area sizes obtained
from radio-tracked small rodents (22 chipmunks) on a short time scale
(ie a month) could be predicted from the area formed by the polygon of
traps where individuals have been caught and released during the
tracking study. The underlying hypothesis is: does the trapping data
reflect ? or not ? the area most intensely used by these rodents.
Any help would be appreciated for a poor lonesome rodent-trapper that
is not used to get deeper into the cabalistic codes of R functions ;))
Amicalement
Benoit Pisanu
Muséum National d'Histoire Naturelle
Département Ecologie et Gestion de la Biodiversité
Conservation des espèces, restauration et suivi des populations
UMR 7204 MNHN-CNRS-P6
61, rue Buffon, Case postale 53
75231 PARIS cedex 05
Tel : 01 40 79 32 69
_______________________________________________
AniMov mailing list
AniMov@faunalia.it
http://lists.faunalia.it/cgi-bin/mailman/listinfo/animov
--
Clément CALENGE
Cellule d'appui à l'analyse de données
Direction des Etudes et de la Recherche
Office national de la chasse et de la faune sauvage
Saint Benoist - 78610 Auffargis
tel. (33) 01.30.46.54.14
_______________________________________________
AniMov mailing list
AniMov@faunalia.it
http://lists.faunalia.it/cgi-bin/mailman/listinfo/animov