Hi everybody, I write to ask if anyone has an R code to calculate ENFA analyses with data from a matrix. Any help with R code would be highly appreciated. Carolina Lang Chile -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/adehabitat-in-R-tp7580377.html Sent from the R-sig-geo mailing list archive at Nabble.com.
adehabitat in R
2 messages · carolang, Mathieu Basille
1 day later
Dear Carolina,
I'm not sure what's your exact problem, since you don't provide any data,
sample or code. If your matrix is such that rows define available units
(usually, one row = one pixel of a raster map) over several variables (i.e.
columns), you just need a vector of presence, with the number of
observation associated to each available unit. This vector can be an
additional column. Please have a look at the help of ?enfa, and
specifically the example:
data(lynxjura)
map <- lynxjura$map
## We keep only "wild" indices.
locs <- lynxjura$locs
locs <- locs[slot(locs, "data")[,2]!="D",]
hist(map, type = "l")
## The variable artif is far from symetric
## We perform a square root transformation
## of this variable
## We therefore normalize the variable 'artif'
slot(map,"data")[,4] <- sqrt(slot(map,"data")[,4])
hist(map, type = "l")
## We prepare the data for the ENFA
tab <- slot(map, "data")
pr <- slot(count.points(locs, map), "data")[,1]
You can then check what's in 'tab' and 'pr', which are the basic elements
required for an ENFA:
> head(tab)
forets hydro routes artif
1 5.154568 11.230920 11.622950 16.607230
2 11.643950 10.054470 11.389700 4.661158
3 16.126420 8.814120 10.972950 7.452453
4 18.757530 7.549436 10.417370 9.770423
5 19.779750 6.323049 9.784133 21.188813
6 22.390620 5.249640 9.140086 26.448665
> head(pr)
[1] 0 0 0 0 0 0
> table(pr)
pr
0 1 2 3 4
8220 379 33 7 1
All that's needed then is to run a PCA on the variables measured on the
available units (don't forget to remove the vector of presence if it's a
column of your matrix), and use the result of this PCA together with the
vector of presence:
## We then perform the PCA before the ENFA
pc <- dudi.pca(tab, scannf = FALSE)
(enfa1 <- enfa(pc, pr,
scannf = FALSE))
Hope this helps,
Mathieu.
Le 03/07/2012 10:36, carolang a ?crit :
Hi everybody, I write to ask if anyone has an R code to calculate ENFA analyses with data from a matrix. Any help with R code would be highly appreciated. Carolina Lang Chile -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/adehabitat-in-R-tp7580377.html Sent from the R-sig-geo mailing list archive at Nabble.com.
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
~$ whoami Mathieu Basille, Post-Doc ~$ locate Laboratoire d'?cologie Comportementale et de Conservation de la Faune + Centre d'?tude de la For?t D?partement de Biologie Universit? Laval, Qu?bec ~$ info http://ase-research.org/basille ~$ fortune ``If you can't win by reason, go for volume.'' Calvin, by Bill Watterson.