# R: adehabitatHS compana test - getting NaN for Wilk's lambda [closed]

I'm getting an "NaN" test result using the R package adehabitatHS, and the function "compana".

The compana test compares habitat availability with habitat usage by animals. The test performs a compositional analysis (Aebischer et al. 1993), yielding a value for Wilk's lambda and a p-value.

I'm running the test on empirical data for rattlesnakes (16 animals, 8 habitat categories). For some reason the compana test returns: lambda = NaN, p-value = 1.0.

I've examined my data for the standard causes of NaNs, and I don't see any problems, such as missing values (NAs), negative proportions, or row sums > 100 percent. Moreover, the error arises when I use the full data set (16 rows, 8 columns), but not when I use a subset (missing one column). It does not seem to matter which column(s) is excluded, so long as only 7 or less are included.

Details of my data are below. Any help or suggestions would be greatly appreciated.

Platform: OSX 10.7.4 (Lion) R Version: R 2.15.1 GUI 1.52 Leopard build 64-bit (6188)

R CODE:

proportions for habitat used (matrix):

used.m
Atr   Cre    DW  Dist  Gra   Mar   Mes   Opn
1   2.76 19.31  4.14 17.24 0.00 28.28  0.00  0.00
2  15.12  1.16  3.49  5.81 2.33 32.56 25.58  3.49
3  57.35 13.24  1.47  0.00 6.62  0.00  8.09 12.50
4  41.18  0.98  2.94  0.00 3.92  0.00 29.41 18.63
5   9.52 17.01 23.13  0.00 0.00 37.41  3.40  0.00
6   2.54 67.01  0.00  0.51 0.51  6.09  3.05  0.00
7  10.45 15.67  5.22  5.97 0.00  0.00 33.58 10.45
8   6.34  0.00  0.00  4.23 0.00  0.00  0.00 21.83
9   0.66 18.54  1.32 39.74 0.00  8.61  2.65  0.66
10 20.75  0.00  0.00  0.00 0.00  0.00  0.00 49.06
11 20.14 18.06 12.50  8.33 0.00  5.56 22.22  9.72
12  0.00  0.00  0.00 58.04 0.00  0.00 13.99  0.00
13 44.23  4.81  0.00  0.00 0.00  0.00 28.85 19.23
14 13.04  2.61  1.74  2.61 0.00 19.13  6.09 25.22
15 35.96  3.51  0.00  2.63 0.00  1.75 25.44  0.88
16  0.00  0.00  0.00 35.14 0.00  7.21  0.00  8.11


proportions for habitat available (matrix):

avail.m
Atr   Cre    DW  Dist   Gra   Mar   Mes   Opn
1   1.11 39.18 15.50  0.29  0.00 30.18  4.15  3.43
2  18.96  1.02  0.87  7.40  4.36 37.80  6.17 10.56
3  65.75  3.85  0.57  0.00 12.36  0.00  9.97  3.43
4  20.52  5.44  2.01  0.00  0.08  0.00 10.99 44.22
5  11.16 43.55 10.34  0.00  0.00 18.11  9.60  3.17
6  25.24  9.88  2.77  2.44  4.95 12.90 11.44  2.19
7   5.47 21.13  6.67  0.57  0.00  0.10 30.73  9.59
8   6.23  0.00  0.00  4.85  0.00  0.00  0.00  5.72
9   0.85  1.97  0.09 33.52  0.00  5.58  1.73  0.84
10 18.97  0.00  0.00  0.00  0.00  0.00  0.00  5.59
11  0.16 44.41 19.16  3.53  0.00  1.28 21.65  4.13
12  6.67  3.89  0.31 13.63  0.00  0.00 20.56  0.00
13 21.40  2.38  2.66  0.00  0.00  0.00 21.23 46.96
14 42.62  9.36  1.49  3.89  0.43  3.61 20.79  5.80
15 33.32 12.90  4.17  4.09  0.15  3.96 12.32  4.94
16  5.65  0.00  0.00  1.36  0.00  0.59  0.00  9.71


load the adehabitatHS library

library(adehabitatHS)


run the compana test on full data set (all 8 columns)

fulldata.comp <- compana(used.m, avail.m)


check result

fulldata.comp$test Lambda P NaN 1  now run compana on partial data (columns 1-7) partdata.comp <- compana(used.m[, 1:7], avail.m[, 1:7])  check result partdata.comp$test
Lambda         P
0.3319731 0.6280000

-
Is this a question only about what's happening w/ R, or also about some of the statistical content? It appears to me to be the former; if not, could you edit it to make the latter more apparent? If the former, it doesn't really belong here, but rather on Stack Overflow (although nothing in that means it isn't a perfectly good question). – gung Aug 4 '12 at 1:29
Please, don't cross-post. This is not encouraged on SE sites. I'm closing this one as a 'system-wide duplicate'. If you want to get your SO question back here, and provided you are able to address @gung's comments, please flag for moderation attention. – chl Aug 4 '12 at 10:52

## closed as off topic by gung, chl♦Aug 4 '12 at 10:53

Questions on Cross Validated are expected to relate to statistics within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.