[AniMov] Incremental core area analysis

Damiano G. Preatoni prea at uninsubria.it
Tue Aug 19 16:18:55 CEST 2008


In un messaggio del Tuesday 19 August 2008, albr at uesc.br ha scritto:
> Hi fellows,
>
> I am following the "AniMove How To" tutorial
> and I cannot download the procedure Incremental_Kernel_Analysis.R.
> Maybe the link is old.
>
> I'm really interested in this specific step of the analysis, so if
> someone could give me a little help on this, I will be grateful.

Here is a draft version of an R script that implements the procedure you've 
cited...

Hope This Helps



-- 
Non sono un atleta.  Ho pessimi riflessi.  Una volta sono stato
investito da un'auto spinta da due tizi.
		-- Woody Allen
-----------------------------------------------------------
Damiano G. Preatoni, PhD

Unità di Analisi e Gestione delle Risorse Ambientali
Dipartimento Ambiente-Salute-Sicurezza
Università degli Studi dell'Insubria
Via J.H. Dunant, 3 - 21100 Varese (ITALY)

tel +39 0332421538 fax +39 0332421446
http://biocenosi.dipbsf.uninsubria.it/
ICQ: 78690321 jabber: prea at jabber.org skype: prea.net
-----------------------------------------------------------
Please consider the environment before printing this email
Please do not send attachments in proprietary formats
http://www.gnu.org/philosophy/no-word-attachments.html
Use the UNI CEI Standard ISO/IEC 26300:2006
-----------------------------------------------------------
O< stop html mail - http://www.asciiribbon.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://www.faunalia.com/pipermail/animov/attachments/20080819/505606cb/attachment.pgp>
-------------- next part --------------
###############################################################################
# UAGRA R Scripts                                 Incremental_Kernel_Analysis.R
###############################################################################
# Incremental Kernel Analysis procedure
###############################################################################
#
# Version 1.1
#
# Author: Damiano G. Preatoni (prea at uinsubria.it)
#
# Description: estimates core areas accodring to Hanski et al. 2000.
#
# Usage: res <- corearea(loc, id, method = "kernel")
#
# Requires: adehabitat
#
# References:
# Hanski, I. K.; Stevens, P. C.; Ihalempia, P. & Selonen, V. (2000)
# Home-range size, movements, and nest-site use in the Siberian flyng squirrel,
# Pteromys volans Journal of Mammalogy, 2000, 81, 798-809 
#
###############################################################################
# created prea mer ago  1 11:26:45 CEST 2007
# updated prea mar ago  7 11:23:50 CEST 2007
# revision history:
#  1.1 - added clustering
#
#############################################################################
#    Copyright (C) 2007  Damiano G. Preatoni
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#############################################################################


if (!require(adehabitat)) {
  stop("This procedure requires adehabitat to be installed")
}

corearea <- function(xy, id = NULL, levels = seq(20,95,by = 5), method = "clusthr", unin = "m2", unout = "m2", plot = TRUE) {
  alpha <- 0.05
  ret <- list()
  if(!method %in% c("clusthr","mcp","kernel")) {
    stop("method should be either \"cluster\" or \"mcp\" or \"kernel\"") }
  if(method == "clusthr") {
    clust <- clusthr(xy, id)
    ret[['area']] <- clusthr.area(clust, percent = levels, unin = unin, unout = unout, plotit = FALSE)
    }
  if(method == "mcp") {
    ret[['area']] <- mcp.area(xy, id, percent = levels, unin = unin, unout = unout, plotit = FALSE)
    }
  if(method == "kernel") {
    ret[['area']] <- kernel.area(xy, id, h = "href", levels = levels, unin = unin, unout = unout)
    }
  print(is(ret[['area']]))
  level.areas <- stack(as.data.frame(t(ret[['area']])))
  names(level.areas) <- c('area','coropleth')
  level.areas$coropleth <- ordered(level.areas$coropleth,levels=levels) # as factor!
  ret[['aov']] <- aov(area ~ coropleth, data = level.areas)
  # if coropleth factor is significant go on, else stop here
  if (!summary(ret[['aov']])[[1]][,5][1] <= alpha) {
    warning("No significant differences among coropleth areas.", call. = FALSE)
  }
  else {
    # do TukeyHSD
    ret[['tukey']] <- TukeyHSD(ret[['aov']],"coropleth",ordered = TRUE)
    # pick only consecutive pairs of coropleths
    n <- length(levels)
    i <- 1
    t <- vector()
    for(j in 1:n) {
      t[j] <- i
      i <- (i+n-j)
    }
    p <- ret[['tukey']]$coropleth[t[1:length(t)-1],4]
    if (length(p[p <= alpha]) == 0) {
      warning("No significant differences between consecutive coropleths found.", call. = FALSE)
    }
    else {
      val <- as.numeric(strsplit(names(p[p <= alpha]),"-")[[1]])
      cat("Tukey multiple comparison of means between consecutive levels\n\n")
      print(ret[['tukey']]$coropleth[t[1:length(t)-1],])
      cat("\n\nSignificant differences are present between levels",val[2],"and",val[1],"%\n")
      if (plot) {
        #@TODO(prea) make the plot using average +- standard deviation
        ret[['plot']] <- boxplot(area ~ coropleth,data=level.areas,xlab='% UD Coropleth',ylab=paste('Area (',unout, ")"))
        abline(v = match(val[2],levels),col="red")
      }
    }
  }
  invisible(ret)

}


More information about the AniMov mailing list