Compositional analysis: how to do it in R studio using the compana function (adehabitatHS package)?

I have to perform a compositional analysis in R studio with the function "compana" (available in the adehabitatHS package) but i have no idea how to proceed.
My database is formed by GPS data of 60 individuals of a raptor species, and i have to study the selection of 2 habitat categories (Protected Areas and Non Protected Areas) in their wintering sites. For my study, I have also to group my individuals into age classes (juveniles vs adults) and wintering continent (Europe vs Africa).
My question is: How can I proceed to start my compositional analysis?
I uploaded the adehabitatHS package, and tried to start the analysis with the compana function (database <- compana(used, avail, test = c("randomisation", "parametric"), rnv = 0.01, nrep = 500, alpha = 0.1) but the session crashes every time i try to run the command.
Are there any other preliminary operations that need to be done before starting the compositional analysis?
I apologize if i made some mistakes in writing, but currently i'm not very familiar with R and this kind of statistical analysis, so I hope that someone can help me to understand better this situation.
Thank you very much in advance to those who will answer.

See the FAQ: How to do a minimal reproducible example reprex for beginners for a more specific answer.

See if you can run the examples from help(compana)


suppressPackageStartupMessages({
  library(adehabitatHS)
})
## The examples presented here
## are the same as those presented in
## the paper of Aebischer et al. (1993)


#############################
## Pheasant dataset: first
## example in Aebischer et al.

data(pheasant)

## Second order habitat selection
## Selection of home range within the
## study area (example of parametric test)
pheana2 <- compana(pheasant$mcp, pheasant$studyarea,
                   test = "parametric")
pheana2
#> ************ Compositional analysis of habitat use ***************
#> 
#> The analysis was carried out with 13 animals and 5 habitat types
#> 1. Test of the habitat selection:
#>    parametric test
#>       Lambda           df            P 
#> 8.491656e-02 4.000000e+00 1.860604e-06 
#> 
#> 2. Ranking of habitats (profile):
#>                                                           
#> habitat     Scrub  Broadleaf  Grassland  Coniferous  Crop 
#> Scrub      ------------------                             
#> Broadleaf  ------------------                             
#> Grassland                    -----------------------      
#> Coniferous                   -----------------------      
#> Crop                                                ------

## The ranking matrix:
print(pheana2$rm, quote = FALSE)
#>            Scrub Broadleaf Coniferous Grassland Crop
#> Scrub      0     +         +++        +++       +++ 
#> Broadleaf  -     0         +++        +++       +++ 
#> Coniferous ---   ---       0          -         +++ 
#> Grassland  ---   ---       +          0         +++ 
#> Crop       ---   ---       ---        ---       0

## Third order habitat selection
## (relocation within home range)
## We remove the first pheasant of the analysis
## (as in the paper of Aebischer et al.)
## before the analysis
pheana3 <- compana(pheasant$locs[-1,], pheasant$mcp[-1,c(1,2,4)])
pheana3
#> ************ Compositional analysis of habitat use ***************
#> 
#> The analysis was carried out with 12 animals and 3 habitat types
#> 1. Test of the habitat selection:
#>    randomisation test
#>    Lambda         P 
#> 0.3655733 0.0060000 
#> 
#> 2. Ranking of habitats (profile):
#>                                        
#> habitat    Broadleaf  Scrub  Grassland 
#> Broadleaf ------------------           
#> Scrub     ------------------           
#> Grassland                   -----------

## The ranking matrix:
print(pheana3$rm, quote = FALSE)
#>           Scrub Broadleaf Grassland
#> Scrub     0     -         +++      
#> Broadleaf +     0         +++      
#> Grassland ---   ---       0



#############################
## Squirrel data set: second
## example in Aebischer et al.

data(squirrel)

## Second order habitat selection
## Selection of home range within the
## study area
squiana2 <- compana(squirrel$mcp, squirrel$studyarea)
squiana2
#> ************ Compositional analysis of habitat use ***************
#> 
#> The analysis was carried out with 17 animals and 5 habitat types
#> 1. Test of the habitat selection:
#>    randomisation test
#>     Lambda          P 
#> 0.06808452 0.00200000 
#> 
#> 2. Ranking of habitats (profile):
#>                                            
#> habitat  Larch  Mature  Young  Open  Thuja 
#> Larch   ----------------------             
#> Mature  ----------------------             
#> Young   ----------------------------       
#> Open                   -------------       
#> Thuja                               -------

## The ranking matrix:
print(squiana2$rm, quote = FALSE)
#>        Young Thuja Larch Mature Open
#> Young  0     +++   -     -      +   
#> Thuja  ---   0     ---   ---    --- 
#> Larch  +     +++   0     +      +++ 
#> Mature +     +++   -     0      +++ 
#> Open   -     +++   ---   ---    0


## However, note that here, the hypothesis of identical use 
## on which this analysis relies is likely to be false.
## Indeed, an eisera indicates:

us <- round(30 * squirrel$locs / 100)
av <- squirrel$studyarea
ii <- eisera(us, av, scannf = FALSE)
scatter(ii, grid = FALSE, clab = 0.7)

## There are clearly two groups of animals.  In such cases,
## compositional analysis is to be avoided in this case.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.