Re: [R-sig-eco] [AniMov/R-sig-eco] adehabitat HR: Problem with BRB and sample size (number of fixes)

2017-08-27 Thread Mathieu Basille
Hey Dagmar,

What do you mean by "testing if the UD size is related to the number of
fixes"? Did you model UD size as a function of number of fixes using all
fixes for all animals? If that's what you did, you could also check if it's
true by animal too. One way to do it would be to compute UDs for each
animal over samples of fixes for instance every 10, 20, 30, 40, 50 and 60
minutes, and see if there is any relation here. If there is, you may not
have other option than subsampling at the hour scale to compare all animals
(but what does the UD mean if there is such variation related to sampling?
I'm not familiar enough with BRBs to comment here). If there is no
relationship per animal, then you simply have animals with high number of
fixes AND large UDs!

Hope this helps,
Mathieu.


On 08/23/2017 03:59 PM, Dagmar wrote:
> Dear all,
> 
> I want to compare the homerange size between animals based on GPS data but
> it seems not to work.
> 
> Here is what I did:
> 
> I calculated the homeranges using the Biased random bridges from adehabitat
> HR.
> 
> Animal_ltraj <- as.ltraj(animalxy, animaltime, id=TierID)
> D_Animal <- BRB.D(Animal_ltraj, Tmax=21600, Lmin=36)
> 
> Animal_Grid <- ascgen(allanimals_xy, cellsize=32)  # I chose 32 because it
> was the smallest cellsize chosen automatically. I thought to compare
> homerange size between animals I must use the same grid for all of them.
> 
> Animal_BRB <- BRB(Animal_ltraj, D=
> D_Animal,type=c("UD"),Tmax=21600,Lmin=36, hmin=100,grid=Animalgrid)
> kernel.area(Animal_BRB, unout=c("km2"))
> 
> My problem:
> 
> I have very different sample sizes (i.e. number of fixes): Most animals
> were located hourly but two animals were located about each 5 min. This
> results in sample sizes of about 150 fixes per animals and some animals do
> have almost 10.000 fixes for the same periods of time.
> 
> Because I want to compare the resulting home range sizes I tested if the UD
> size is related to the number of fixes and unfortunatly (!!) they are.
> 
> That means that I cannot compare homerange sizes between my animals
> 
> My question:
> 
> - did I do something wrong?
> 
> - is that problem known and is there a way to solve it?
> 
> The only way that I find is to reduce the number of fixes of my frequently
> located animals artificially / randomly to start with the equal number of
> fixes for all animals. This would be a shame though!
> 
> Help would be very, very, very much appreciated!!!
> 
> 
> ___
> AniMov mailing list
> ani...@lists.faunalia.it
> https://lists.faunalia.it/cgi-bin/mailman/listinfo/animov

-- 

Mathieu Basille

basi...@ufl.edu | http://ase-research.org/basille
+1 954-577-6314 | University of Florida FLREC

  « Le tout est de tout dire, et je manque de mots
  Et je manque de temps, et je manque d'audace. »
  — Paul Éluard

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

[R-sig-eco] Workshop: Next Generation Data Management in Movement Ecology (Florida, May 8–12 2017)

2017-02-08 Thread Mathieu Basille
* Venue: Fort Lauderdale REC, Davie, Florida

* Contact: Mathieu Basille (basi...@ufl.edu)

* Instructors: Simona Picardi, David Bucklin & Mathieu Basille (UF WEC)

* Guest lecturers: Anne Berger (Leibniz Institute for Zoo and Wildlife
Research, Germany), Hamish Campbell (Charles Darwin University, Australia),
Francesca Cagnacci (Fondazione Edmund Mach, Italy) & Ferdinando Urbano
(Independent researcher, Italy)

* Attendance: Reserved for Natural Resource managers (for a fee) and UF
students (with tuition waiver). Limited seats are available on a first come
– first served basis. Natural Resource managers, please register on
Eventbrite.com [1].

* More info on: http://ase-research.org/training/PostGIS_2017/


Recent technological progress has allowed ecologists to obtain a huge
amount and diversity of animal movement data sets of increasing spatial and
temporal resolution and size, together with complex associated information
related to the environmental context, such as habitat types based on remote
sensing, population density, and weather. Based on several years of
experience on multiple species, this intensive five-day workshop is
designed to teach participants how to handle, manage, store and retrieve
movement data in a spatial database, and how to eventually feed them to
analysis tools. In the first part of the course, participants will be
exposed to basics of spatial databases for wildlife tracking data, using
PostgreSQL/PostGIS, the reference free and open-source database system. The
second part will focus on the integration of environmental data in the
process. The third part will tackle the specifics of movement data, and how
to connect the database to the R statistical environment for analysis. Step
by step, using reproducible, hands-on exercises that will be released
on-line, we will provide a complete and seamless procedure from raw data to
final analysis that will enable participants to fully manage and integrate
complex animal movement data sets. Although the workshop is intended for a
wide audience, basic knowledge of SQL, spatial databases and R are highly
recommended to get the best experience.

Participants will have to bring their own laptop computers, with necessary
software installed (instructions for open-source software will be provided).

Reference: Urbano, F. & Cagnacci, F. (ed.) (2014) Spatial Database for GPS
Wildlife Tracking Data: A Practical Guide to Creating a Data Management
System with PostgreSQL/PostGIS and R. Springer, 257 pp. DOI:
10.1007/978-3-319-03743-1


[1]
https://www.eventbrite.com/e/next-generation-data-management-in-movement-ecology-tickets-31849319171


-- 

Mathieu Basille

basi...@ufl.edu | http://ase-research.org/basille
+1 954-577-6314 | University of Florida FLREC

  « Le tout est de tout dire, et je manque de mots
  Et je manque de temps, et je manque d'audace. »
  — Paul Éluard

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

Re: [R-sig-eco] adehabitatLT merge different bursts for same ID

2017-02-02 Thread Mathieu Basille
Hey Giulia,

By definition, you cannot have a single burst with different burst names.
If you really want to merge all bursts into one, you need to have a unique
burst ID:

* Either in your simulations
* or later one after your call to ld:

migrdf <- ld(migr)
migrdf$movtype <- migrdf$burst# If you want to keep the movement type
migrdf$burst <- "Prova"   # Same as ID, but does not need to be
migr_singleburst <- dl(migrdf)

Hope this helps,
Mathieu.


On 02/02/2017 10:00 AM, g.cerritelli wrote:
> Dear list,
> 
> I'm trying to simulate the migratory movement of an animal, following the
> work of Bunnefeld et al 2011.
> I started from a dataset of dates and used the function simm.mou and
> simm.bb in adehabitatLT to simulate five distinct movement types: the stay
> in a wintering area, the migration to reproductive areas, the stay in this
> sites, the return migration and finally the stay in wintering areas.
> Now I would like to merge this five simulations into one and so obtain a
> single object ltraj with all the information on the whole movement. For
> this purpose, I assigned to the five simulation the same ID but different
> burst and than used the string c() to put all the simulations in one object
> ltraj. However the five bursts remained separated.
> Does anyone know how can I actually merge in adehabitatLT this tracks to be
> one?
> 
> 
> da = as.POSIXct(strptime(as.character(data$timestamp),
> tz="",format="%d/%m/%Y %H:%M:%S"))
> da[1:10]
>  [1] "2014-04-29 00:00:00 CEST" "2014-04-29 00:19:00 CEST"
>  [3] "2014-04-29 00:37:00 CEST" "2014-04-29 00:55:00 CEST"
>  [5] "2014-04-29 01:14:00 CEST" "2014-04-29 01:32:00 CEST"
>  [7] "2014-04-29 01:51:00 CEST" "2014-04-29 02:09:00 CEST"
>  [9] "2014-04-29 02:27:00 CEST" "2014-04-29 02:46:00 CEST"
> 
> 
> hr<-simm.mou(da[1:70],b = c(0,
> 0),a=diag(c(0.001,0.001)),sigma=diag(c(100,100)),
>  x0 = c(0, 0),id = "Prova", burst = "HR1")
> bb<-simm.bb(da[71:110],
> begin=c(0,0),end=c(6,6),id="Prova",burst="migr")
> hr2<-simm.mou(da[111:210],b = c(6,
> 6),a=diag(c(0.001,0.001)),sigma=diag(c(100,100)),
>   x0 = c(6, 6),id = "Prova",burst="HR2")
> bb2<-simm.bb(da[211:240],
> begin=c(6,6),end=c(0,0),id="Prova",burst="migr2")
> hr3<-simm.mou(da[241:350],b = c(0,
> 0),a=diag(c(0.001,0.001)),sigma=diag(c(100,100)),
>  x0 = c(0, 0),id = "Prova", burst = "HR3")
> migr<- c(hr,bb,hr2,bb2,hr3)
> 
> ld(migr)
>   x ydatedxdy  dist   dt
> 68   1273.749  7132.147 2014-04-29 20:31:00 -4814.308 -9767.770 10889.761 1080
> 69  -3540.560 -2635.623 2014-04-29 20:49:00 -2708.557 -1208.668  2966.001 1140
> 70  -6249.117 -3844.291 2014-04-29 21:08:00NANANA   NA
> 111 0.000 0.000 2014-04-29 21:26:00  1444.220  1450.462  2046.854 1080
> 210  1444.220  1450.462 2014-04-29 21:44:00  1545.417  1533.493  2177.134 1140
> 310  2989.636  2983.956 2014-04-29 22:03:00  1505.393  1525.449  2143.176 1080
> 
> R2n  abs.angle rel.angleid burst  pkey
> 68  52489961 -2.0287292 -3.1366093166 Prova   HR1 Prova.2014-04-29 20:31:00
> 69  19482070 -2.7218694 -0.6931401962 Prova   HR1 Prova.2014-04-29 20:49:00
> 70  53830039 NANA Prova   HR1 Prova.2014-04-29 21:08:00
> 1110  0.7875548    NA Prova  migr Prova.2014-04-29 21:26:00
> 210  4189611  0.7815256 -0.0060292387 Prova  migr Prova.2014-04-29 21:44:00
> 310 17841916  0.7920154  0.0104897686 Prova  migr Prova.2014-04-29 22:03:00
> 
> 
> Thank you in advance for your time.
> 
> Giulia
> 
> ___
> R-sig-ecology mailing list
> R-sig-ecology@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

-- 

Mathieu Basille

basi...@ufl.edu | http://ase-research.org/basille
+1 954-577-6314 | University of Florida FLREC

  « Le tout est de tout dire, et je manque de mots
  Et je manque de temps, et je manque d'audace. »
  — Paul Éluard

This message is signed to guarantee its authenticity.
For a true private correspondence, use my public key
to encrypt your messages:

  http://mathieu.basille.net/pub.asc

Learn more: http://mzl.la/1BsOGiZ

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Package adehabitatLT; lion telemetry data; removing intermittent 1-hr locations to create 2-hr locations

2016-11-14 Thread Mathieu Basille
0 | 614.954651 | 7200 | Bhubesi |
> | 529519.1 | 7906819 | 9/10/2011 3:00 | 2308.861303 | 3600 | Bhubesi |
> | 531726.2 | 7907497 | 9/10/2011 4:00 | 764.682101 | 3600 | Bhubesi |
> | 532321.3 | 7907017 | 9/10/2011 5:00 | 282.912376 | 3600 | Bhubesi |
> | 532142 | 7906798 | 9/10/2011 6:00 | 705.010909 | 3600 | Bhubesi |
> 
> 
> Any guidance would be appreciated.
> Best,Lisanne
>   [[alternative HTML version deleted]]
> 
> ___
> R-sig-ecology mailing list
> R-sig-ecology@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
> 

-- 

Mathieu Basille

basi...@ufl.edu | http://ase-research.org/basille
+1 954-577-6314 | University of Florida FLREC

  « Le tout est de tout dire, et je manque de mots
  Et je manque de temps, et je manque d'audace. »
  — Paul Éluard

This message is signed to guarantee its authenticity.
For a true private correspondence, use my public key
to encrypt your messages:

  http://mathieu.basille.net/pub.asc

Learn more: http://mzl.la/1BsOGiZ

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

Re: [R-sig-eco] adehabitatLT

2016-04-19 Thread Mathieu Basille
[I'm resending my answer since it didn't make it to the list]

Hi Carolina,

Please check my package 'hab' [1]. I refined 'plot.ltraj' there to allow
for better control for the user. I believe it can be used to do what you
want. See for instance the following example:

library(hab)
data(puechcirc)
plot(puechcirc, by = "none")
plot(puechcirc, by = "none", ppar = list(col = c(CH930824 = "blue",
CH930827 = "blue", JE930827 = "red"), pch = 20), lpar = list(col =
c(CH930824 = "blue", CH930827 = "blue", JE930827 = "red")))

You will find other useful examples in the help page of the function.

Hope this helps!
Mathieu.


[1] https://github.com/basille/hab


Le 14/04/2016 06:17, Carolina Massa a écrit :
> Hello,
> Someone know how can I plot two ltraj (2 different animals) in the same
> graph?
> thanks
> 
> Caro
> 
> ___
> R-sig-ecology mailing list
> R-sig-ecology@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
> 

-- 

Mathieu Basille

basi...@ufl.edu | http://ase-research.org/basille
+1 954-577-6314 | University of Florida FLREC

  « Le tout est de tout dire, et je manque de mots
  Et je manque de temps, et je manque d'audace. »
  — Paul Éluard

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Compute the distance between the trajectories of two animals with varying sampling intervals

2015-07-22 Thread Mathieu Basille
As far as I can tell, there is no such function in adehabitatLT. However, I 
wrote a function 'closest' [1] in the package 'hab' [2], which specifically 
does that: find the closest relocations from ltraj objects. It can work 
with only one ltraj, in which case it will look in other bursts, or with 
two different ltraj, in which case it will in the other ltraj. Most 
importantly, you can define a temporal windows to restrict the search, 
which may solve your problem of irregular time (the ltraj do not have to be 
regular, or on the same time schedule). It's only Euclidean distance 
though. Lastly, it works at the location level, i.e. it's not considering 
lines (steps). If that's what you're looking for, I would probably suggest 
using PostGIS...


Hope this helps,
Mathieu.


[1] https://github.com/basille/hab/blob/master/R/closest.r

[2] https://github.com/basille/hab


Le 22/07/2015 10:09, Jeremy Chacon a écrit :

I bet Sarah's right and adehabitatLT has something, but I also know that
the longitudinalData package can compute distances between two trajectories
including the frechet distance.

http://www.inside-r.org/packages/cran/longitudinalData/docs/pathFrechet

However, it does not deal with the timing problem. You will have to roll
your own method of aligning the trajectories in time.

On Wed, Jul 22, 2015 at 9:02 AM, Sarah Goslee sarah.gos...@gmail.com
wrote:


Try the adehabitatLT package.

On Wed, Jul 22, 2015 at 9:41 AM, André Zehnder andrezehn...@hotmail.com
wrote:

Hi list,



I want to compute the distances between two trajectories that consist of

a

sequence of point measurements. The trajectories do not have the same

length

or sampling interval. So, while for animal A, there is a data point at

15.00

p.m. and another at 15.38 p.m, animal B might have data points at 14.56

p.m.


and 17.02 p.m.



A possible approach would be to connect these point series to

trajectories

and then calculate the distance between the two trajectories at the

sampled

positions of one trajectory (take the sampled position of the second
trajectory that is temporally closest). Are there any packages in R (or
tools outside of R) that allow me to do this? The support of other

distances

than the Euclidean one (e.g. Fr chet) would be an advantage.



Best regards,

Andre



--
Sarah Goslee
http://www.functionaldiversity.org

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology







--

~$ whoami
Mathieu Basille
http://ase-research.org/basille

~$ locate --details
University of Florida \\
Fort Lauderdale Research and Education Center
(+1) 954-577-6314

~$ fortune
« Le tout est de tout dire, et je manque de mots
Et je manque de temps, et je manque d'audace. »
 -- Paul Éluard

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

Re: [R-sig-eco] Compute the distance between the trajectories of two animals with varying sampling intervals

2015-07-22 Thread Mathieu Basille

Hi André,

Yes, that's one way to do it. If you already have a single ltraj with all 
individuals (one individual per burst), you can simply give it the ltraj 
alone. With a single ltraj, the function looks for the closest point in 
other bursts. Check the example of the function.


Note that I do not guarantee that my function is efficient! This is R: 
there is no use of spatial indexes or bounding boxes, so that for each 
point, distances are computed to all other points in the temporal window. 
Depending on your data, I guess it could be fairly slow...


Again, if you're looking for performance and/or robustness, I would give a 
try to PostGIS here.

Mathieu.


Le 22/07/2015 15:31, André Zehnder a écrit :

Thank you for all your answers!

@ Krzysztof: Yes, I think an approximated method that uses only the nearest 
points to compute the distance will suffice. When I include a threshold that 
ensures that only temporal differences smaller than xy minutes are taken into 
consideration, reasonable results should be achievable.

@ Sarah: I think you are referring to the simulation of a Brownian motion by 
the function simm.bb()  for an exact solution? I could not find a function that 
directly computes the distances. Or did I miss something?

@ Jeremy: Thanks for the hint! A also stumbled upon the pathFrechet() / 
distFrechet() function of longitudinalData but rejected them because they seem 
not to include the temporal dimension. However, this seems to be only an 
erroneous information of inside-r. When I looked at the official reference 
manual I saw that distFrechet() considers the time as well.

@ Mathieu: That is pretty much what I am intending to do for a first (and 
possibly also final) try, thanks! So I need to input the ltray-object of the 
first individual  as 'from' and the other one as 'to' in order to check the 
distances between their closest points, right? I also tried to program 
something like that but the result is shockingly time inefficient and might 
still contain some errors. So I will probably try out your function tomorrow :)

Best regards
Andre



-Ursprüngliche Nachricht-
Von: Mathieu Basille [mailto:basille@ase-research.org]
Gesendet: Mittwoch, 22. Juli 2015 19:44
An: André Zehnder; R-sig-eco
Cc: Jeremy Chacon; Sarah Goslee
Betreff: Re: [R-sig-eco] Compute the distance between the trajectories of two 
animals with varying sampling intervals

As far as I can tell, there is no such function in adehabitatLT. However, I 
wrote a function 'closest' [1] in the package 'hab' [2], which specifically 
does that: find the closest relocations from ltraj objects. It can work with 
only one ltraj, in which case it will look in other bursts, or with two 
different ltraj, in which case it will in the other ltraj. Most importantly, 
you can define a temporal windows to restrict the search, which may solve your 
problem of irregular time (the ltraj do not have to be regular, or on the same 
time schedule). It's only Euclidean distance though. Lastly, it works at the 
location level, i.e. it's not considering lines (steps). If that's what you're 
looking for, I would probably suggest using PostGIS...

Hope this helps,
Mathieu.


[1] https://github.com/basille/hab/blob/master/R/closest.r

[2] https://github.com/basille/hab


Le 22/07/2015 10:09, Jeremy Chacon a écrit :

I bet Sarah's right and adehabitatLT has something, but I also know
that the longitudinalData package can compute distances between two
trajectories including the frechet distance.

http://www.inside-r.org/packages/cran/longitudinalData/docs/pathFreche
t

However, it does not deal with the timing problem. You will have to
roll your own method of aligning the trajectories in time.

On Wed, Jul 22, 2015 at 9:02 AM, Sarah Goslee sarah.gos...@gmail.com
wrote:


Try the adehabitatLT package.

On Wed, Jul 22, 2015 at 9:41 AM, André Zehnder
andrezehn...@hotmail.com
wrote:

Hi list,



I want to compute the distances between two trajectories that
consist of

a

sequence of point measurements. The trajectories do not have the
same

length

or sampling interval. So, while for animal A, there is a data point
at

15.00

p.m. and another at 15.38 p.m, animal B might have data points at
14.56

p.m.


and 17.02 p.m.



A possible approach would be to connect these point series to

trajectories

and then calculate the distance between the two trajectories at the

sampled

positions of one trajectory (take the sampled position of the second
trajectory that is temporally closest). Are there any packages in R
(or tools outside of R) that allow me to do this? The support of
other

distances

than the Euclidean one (e.g. Fr chet) would be an advantage.



Best regards,

Andre



--
Sarah Goslee
http://www.functionaldiversity.org

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology









--

~$ whoami
Mathieu Basille
http://ase

[R-sig-eco] Re : problem with kernel UD estimation using adehabitatHR

2014-06-18 Thread Mathieu Basille
Hey Lindsey,

Just a blind guess here, did you try using a SpatialPixels instead of the 
default number for the 'grid' parameter in 'kernelUD'? It might solve your 
problem, in addition to give you more flexibility on the format of the output.

Mathieu.


 Le mar., 03 juin 2014 17:03:46 -0400 
lnmessingerlindsey.messin...@huskers.unl.edu a écrit  

  I have data containing locations of 100+ pheasants during 3 seasons. I am 
  looking to estimate kernel home ranges for each of the seasons for each 
  individual. I run the kernelUD() function with no errors or warnings, but am 
  receiving an error message when I attempt to use the getverticeshr() and 
  kernel.area() functions to extract 95% polygons and area estimates from the 
  kernel UD's. 
   
  Here is the structure of the input data set: 
   
  Formal class 'SpatialPointsDataFrame' [package sp] with 5 slots 
..@ data   :'data.frame':2376 obs. of  1 variable: 
.. ..$ ID: Factor w/ 122 levels 150.002_2013_KOR,..: 1 1 1 1 1 1 2 2 2 2 
  ... 
..@ coords.nrs : num(0)  
..@ coords : num [1:2376, 1:2] 347887 347862 347948 347964 348200 ... 
.. ..- attr(*, dimnames)=List of 2 
.. .. ..$ : NULL 
.. .. ..$ : chr [1:2] X_Estimate Y_Estimate 
..@ bbox   : num [1:2, 1:2] 315869 4442294 349590 4472129 
.. ..- attr(*, dimnames)=List of 2 
.. .. ..$ : chr [1:2] X_Estimate Y_Estimate 
.. .. ..$ : chr [1:2] min max 
..@ proj4string:Formal class 'CRS' [package sp] with 1 slots 
.. .. ..@ projargs: chr NA 
   
  The following code works without errors or warnings for my pre season 
  data: 
   
  kud.pre-kernelUD(pre.hr.id[,1],h=href,extent=1) 
  pre.hr.poly-getverticeshr(kud.pre, percent=95) 
  pre.kud.area-kernel.area(kud.pre,percent=95) 
   
  However, when I repeat my other 2 seasons, kernelUD() runs with no errors or 
  warnings: 
   
  kud.early-kernelUD(early.hr.id[,1],h=href,extent=1) 
   
  but I get the following error when running the getverticeshr() function: 
   
  early.hr.poly-getverticeshr(kud.early, percent=95) 
   
  Error in getverticeshr.estUD(x[[i]], percent, ida = names(x)[i], unin,  :  
The grid is too small to allow the estimation of home-range. 
  You should rerun kernelUD with a larger extent parameter 
   
  I have adjusted the extent parameter as requested, using values of 
  0.5,1,5,10,25,100 and all produce the same error. I am able to generate 
  mcp's using the same data without a problem and like I said, kernelUD() 
  works with no errors or warnings for all 3 seasons and I am able to see each 
  UD when I look at the image. 
   
  What I find particularly strange is that I am able to run kernel.area() and 
  even with warnings that say: 
   
  1: In kernel.area(j, percent, unin, unout) : 
The grid is too small to allow the estimation of home-range 
  for the following value of percent: 95. You should rerun kernelUD with a 
  larger extent parameter 
   
  I still get a data frame with area values for each individual. It seems as 
  if an area is estimated regardless of the error warning of small extent 
  size. 
   
  Has anyone experienced a similar issue or have a suggestion as to how I 
  should proceed? 
   
  Thanks, 
  Lindsey 
   
   
   
   
   
   
  -- 
  View this message in context: 
  http://r-sig-ecology.471788.n2.nabble.com/problem-with-kernel-UD-estimation-using-adehabitatHR-tp7578930.html
   
  Sent from the r-sig-ecology mailing list archive at Nabble.com. 
   
  ___ 
  R-sig-ecology mailing list 
  R-sig-ecology@r-project.org 
  https://stat.ethz.ch/mailman/listinfo/r-sig-ecology 
  


--

~$ whoami 
Mathieu Basille, PhD 
 
~$ locate --details 
University of Florida \\ 
Fort Lauderdale Research and Education Center 
(+1) 954-577-6314 
http://ase-research.org/basille 
 
~$ fortune 
« Le tout est de tout dire, et je manque de mots 
Et je manque de temps, et je manque d'audace. » 
  -- Paul Éluard

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Animal movement packages

2013-09-29 Thread Mathieu Basille

Hi Bruce,

Have a look at adehabitatLT and adehabitatHR and their vignettes:

http://cran.r-project.org/web/packages/adehabitatLT/
http://cran.r-project.org/web/packages/adehabitatHR/

You'll find a lot of useful stuff in there for the study of movement and 
home range (probably the most extensive packages for that).


Hope this helps,
Mathieu.


Le 09/29/2013 04:38 PM, Bruce Miller a écrit :

Hi all,

I am looking for a (many?) R packages that deal with animal movement data
to generate:
Minimum Convex Polygon, Kernel Home Range Analysis, Harmonic Mean, Circular
Stats etc.

I did a quick look at the CRAN Task View: Analysis of Ecological and
Environmental Data, maintained by Gavin Simpson but did not find a package
that explicitly indicated it could do this.

Possibly Hawthorne Beyer's Geospatial Modeling Environment, now all R code
and was Hath's Tools eons ago may do this.

Bruce

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


--

~$ whoami
Mathieu Basille, PhD

~$ locate --details
University of Florida \\
Fort Lauderdale Research and Education Center
(+1) 954-577-6314
http://ase-research.org/basille

~$ fortune
« Le tout est de tout dire, et je manque de mots
Et je manque de temps, et je manque d'audace. »
 -- Paul Éluard

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] adehabitat in R

2012-07-05 Thread Mathieu Basille

Dear Carolina,

I already replied to your question on R-sig-Geo [1]. Please avoid 
cross-posting and continue there if any additional help is required. You 
may want to read the R posting guide [2], too.


Mathieu.

[1] https://stat.ethz.ch/pipermail/r-sig-geo/2012-July/015538.html

[2] http://www.r-project.org/posting-guide.html


Le 05/07/2012 17:45, carolang a écrit :

Hi, everybody
i´m new in this, I need help for work in ENFA anlyses and determine the
habitat selection of a marine specie, i have a data matrix with
oceanographic variables linked to specie presence and i have another matrix
with the same variables but wihtout the presence of the specie (anchovy).
Can someone help me on the step to follow for the analyses (a code for
example).

Any suggestion i will appreciate,

regards,

Carolina

From Chile.


--
View this message in context: 
http://r-sig-ecology.471788.n2.nabble.com/adehabitat-in-R-tp7577494.html
Sent from the r-sig-ecology mailing list archive at Nabble.com.

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


--

~$ 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.

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Brownian Bridge for migratory paths

2011-09-15 Thread Mathieu Basille

Hi Tsewang,

I'm not sure about your script, but there is a function in 
'adehabitatHR' to estimate kernel Brownian-Bridge home ranges. See:


?kernelbb

You can find additional details in section 5 of:

vignette(adehabitatHR)

Hope this helps,
Mathieu.


Le 15/09/2011 19:31, Tsewang Namgail a écrit :

Hi everyone,

I am using the Brownian Bridge Model to demarcate migratory paths of
birds. I used the following script used for mammals. Using this I
didn't get bridges but simply blotches of high use areas without any
link between them. Can anyone guide me as to how can I get continuous
bridges between all the bird locations. Any help would be highly
appreciated.

Thanks
Tsewang

BrownianBridge=function(X,Y,Time,LocationError,cell.size=50,max.lag)
 {options(digits=20)

#Alternative
#BBMM=brownian.bridge(x=locations$X,y=locations$Y,time.lag=locations$time.lag,location.error=20,cell.size=50)

#X = locsTN$X
#Y = locsTN$Y
#Time = locsTN$Clock
#LocationError = locsTN$TeleError
#cell.size = 500

#max.lag = abs(min(diff(Time))+1)
LocationError = LocationError/sqrt(pi/2)

# Create grid
xmin=(min(X) - 0.1*(max(X)-min(X)))
xmax=(max(X) + 0.1*(max(X)-min(X)))
ymin=(min(Y) - 0.1*(max(Y)-min(Y)))
ymax=(max(Y) + 0.1*(max(Y)-min(Y)))
x = seq(xmin, xmax, by=cell.size)
y = seq(ymin, ymax, by=cell.size)
x = rep(x, length(y))
y = sort(rep(y, length(x)/length(y)))
grid = data.frame(x, y)
cat(Size of grid =, length(unique(grid$y)), X,
length(unique(grid$x)), fill=TRUE)

n.locs = length(X)
 cat(Number of animal locations =, n.locs, fill=TRUE)

 #--
#Calculate Brownian motion variance BMvar
 #LocationError = rep(LocationError, length(X))
 T.jump = alpha = ztz = ob = loc.error.1 = loc.error.2 = NULL
 i = 2
 while(i  n.locs){
if((Time[i+1]-Time[i-1])/ 300  max.lag) {i = i + 1}
else {
ob = c(ob, i)
t = Time[i+1]-Time[i-1]
T.jump = c(T.jump, t)
a = (Time[i]-Time[i-1]) / t
alpha = c(alpha, a)
u = c(X[i-1], Y[i-1]) + a*(c(X[i+1], Y[i+1]) -
 c(X[i-1], Y[i-1]))
ztz = c(ztz, (c(X[i], Y[i]) - u)%*%(c(X[i], Y[i]) - u))
loc.error.1 = c(loc.error.1, LocationError[i-1])
loc.error.2 = c(loc.error.2, LocationError[i+1])
}
i = i + 2
 }

 #Likelihood
 likelihood- function(var){
v = T.jump*alpha*(1-alpha)*var +
 ((1-alpha)^2)*(loc.error.1^2) +
(alpha^2)*(loc.error.2^2)
l = (1/(2*pi*v))*exp(-ztz/(2*v))
-sum(log(l), na.rm=T)
 }
 BMvar = nlminb(start=1, likelihood, lower=10)$par
 cat(Brownian Motion Variance (meters^2) =, round(BMvar),
 fill=TRUE)
 BMvar = rep(BMvar, length(X))

#Estimate Brownian bridge
#Note: 5 minute time step (dt interval in Eq.5 Horne et al. 2007) is 
used.
Time.Diff = c(diff(Time), NA)
Max.Time.Diff = max(diff(Time))
T.Total = Time[n.locs] - Time[1]
probability = NULL
int = 0
for(i in 1:(n.locs-1)){
#if(Time.Diff[i]= max.lag){
if(Time.Diff[i]= Max.Time.Diff){
theta = NULL
tm = 0
while(tm= Time.Diff[i]){
alpha = tm/Time.Diff[i]
mu.x = X[i] + alpha*(X[i+1] - X[i])
mu.y = Y[i] + alpha*(Y[i+1] - Y[i])
sigma.2 = Time.Diff[i]*alpha*(1-alpha)*BMvar[i] 
+
((1-alpha)^2)*(LocationError[i]^2) +
(alpha^2)*(LocationError[i+1]^2)
ZTZ = (grid$x - mu.x)^2 + (grid$y - mu.y)^2
theta = 
(1/sqrt(2*pi*sigma.2))*exp(-ZTZ/(2*sigma.2))
int = int + theta
tm = tm + 1800
}
}
}

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


--

~$ 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.

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] problem barplot width

2011-02-04 Thread Mathieu Basille
The help page of barplot says:

   width: optional vector of bar widths. Re-cycled to length the number
  of bars drawn.  Specifying a single value will have no
  visible effect unless ‘xlim’ is specified.

Following your code, have a look at these examples, which might help to
understand:

barplot(d,col=barcol,ylim=c(min(d-s*1.25),max(d+s*1.25)),space=2)
barplot(d,col=barcol,ylim=c(min(d-s*1.25),max(d+s*1.25)), width = c(1,
3, 2))
barplot(d,col=barcol,ylim=c(min(d-s*1.25),max(d+s*1.25)), width = 0.01,
xlim = c(0,1))

Hope this helps,
Mathieu.


Le 2011-02-04 16:24, Mario Beolco a écrit :
 Dear R-users,
 
 apologies for the total beginner's question, but I have been trying to
 solve this problem for ages and I seem to be getting nowhere. I also
 have tried to search through the archives of the R mailing list, but I
 am still left with my problem. How do I change the width of the bars
 for this simple barplot? I understand that the the width argument
 might do what I want and I have tried to use it to change the width of
 the bars e.g. width=c(0.01,0.01,0.01), but it does not do what I want.
 Any help/suggestions would be greatly appreciated.
 
 # some data
 d-c(-4.227684e-04,2.012307e-04,4.085164e-05)
 s-c(3.588785e-05,9.133071e-05,2.072433e-05)
 
 # barplot colour
 barcol-c(#6E8B3D,#FFB90F,#8B,#6E8B3D,#FFB90F,#8B,#6E8B3D,#FFB90F,#8B)
 
 # create barplot
 barplot(d,col=barcol,ylim=c(min(d-s*1.25),max(d+s*1.25)),space=0.1)
 
 
 thanks in advance for your help
 
 Best wishes,
 
 Mario
 
 ___
 R-sig-ecology mailing list
 R-sig-ecology@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

-- 

~$ 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.

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] QIC for conditional logistic regression + GEE

2010-11-10 Thread Mathieu Basille
Finally, I got a solution, with the help of Thierry Duchesne and Marc
Mazerolle. A coxph object returns a $loglik element, with 2 values, the
second being the quasi-likelihood (under R = I) to estimate the betas.

Here we are, we can thus write a simple function:

QIC - function(mod, ...)
UseMethod(QIC)

QIC.coxph - function(mod, details = FALSE) {
trace - sum(diag(solve(mod$naive.var) %*% mod$var))
quasi - mod$loglik[2]
return(-2*quasi + 2*trace)
}

which should just do the trick!
Mathieu.


Le 2010-11-10 10:17, Mathieu Basille a écrit :
 Dear Maarten,
 
 Thank you for the links! They are very useful!
 
 However, in both cases, they address the problem of QIC for GLMs, i.e.
 for parametric models. This said, I was unable to adjust the code for
 Cox models, which are semi-parametric, and use partial likelihood
 instead (which should behave similarly). In the end, I have no idea how
 to extract/compute the quasi partial likelihood for such a model, which
 is required for the QIC...
 
 I'm still struggling a lot about QIC on coxph, any additional hint would
 be greatly appreciated!
 Mathieu.
 
 
 Le 10/11/2010 02:32, Maarten de Groot a écrit :
 Dear Matthieu,

 Henric Nilsson
 (http://hisdu.sph.uq.edu.au/lsu/SSAI%20course/course_tools.htm) and
 Casper Kraan
 (http://www.waddenacademie.knaw.nl/fileadmin/inhoud/pdf/06-wadweten/Proefschriften/Thesis_Casper_Kraan.pdf)

 provide the R code for the QIC. Maybe this might be useful to you.
 Interestingly however is that the code of Nilsson gives another QIC
 output as you get from the yags package.

 Kind regards,

 Maarten

 On 11/9/2010 4:50 PM, Mathieu Basille wrote:
 Dear Timothy,

 Thanks for the hint! I didn't know about the package yags... I was
 able to install it and use it in simple cases (glm), and it does
 provide a QIC!

 However, it seems to be limited to the case of GLM (any family), but
 not Cox models... At least, I was unable to use it with a Cox model
 approach.

 Last but not least, the routine that computes the QIC (pan.aic) is in
 C, not in R, and my skills in C are below zero.

 Any idea?
 Mathieu.


 PS: I cc-ed back the list, since it could be useful there...




 Le 09/11/2010 05:04, treid a écrit :
 Hi Mathieu,
 Someone has probably already told you, but just in case, there is an R
 package named yags that does QIC. Last I looked, you had to go to the
 R-forge site to get it rather than cran.
 tim.

 - Original Message -
 From: Mathieu Basille basi...@ase-research.org
 Date: Monday, November 8, 2010 16:32
 Subject: [R-sig-eco] QIC for conditional logistic regression + GEE
 To: r-sig-ecology@r-project.org

  Dear list,
 
  I'm currently trying to fit a conditional logistic regression on
  correlated data (these are actually steps from animals, with 1
  case and a bunch of random controls). The state of the art is to
  use a GEE approach to estimate the variance of the coefficients,
  using a coxph model by strata (composed of one step +
  corresponding random steps), and a clustered estimation of the
  variances (i.e. robust variances). This is quite easy to achieve
  in R, with nevertheless some convergence problems...
 
  The next step, however, is to select the best model within a set
  of competing ones. Again, the state of the art is to use the
  Quasi-likelihood under Independence Criterion (QIC) [1] also
  sometimes known as modified AIC [2].
 
  After an extensive search (with the help of rseek.org), I was
  unable to find any guidance for this criterion using R. I know
  the criterion is already available in SAS or Stata, but I was
  wondering if anyone tried to code QIC in R? That would be a very
  valuable tool in the R toolbox!
 
  I was considering posting this question directly to the main R-
  help, but decided to try it here first... Let me know if it is
  the right move!
 
  Sincerely,
  Mathieu Basille.
 
 
  [1] Pan, W. (2001a). Akaike's information criterion in
  generalized estimating equations. Biometrics, 57, 120-125.
 
 http://www.biostat.jhsph.edu/~fdominic/teaching/bio655/references/extra/QIC.biometrics.pdf


 
  [2] McCullagh, P., and Nelder, J. A. (1989). Generalized Linear
  Models (2nd ed.). London:Chapman  Hall.
 
  See an example in: A. H. M. M. Latif, M. Z. Hossain and M. A.
  Islam: Model selection using modified Akaike's Information
  Criterion: an application to maternal morbidity data. Austrian
  Journal of Statistics, 37, 2008, 175-184.
  http://www.stat.tugraz.at/AJS/ausg082/082Latif.pdf
 
 
  --
 
  ~$ 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.
 
  ___
  R-sig-ecology mailing list
  R-sig-ecology@r-project.org
  https://stat.ethz.ch

Re: [R-sig-eco] QIC for conditional logistic regression + GEE

2010-11-09 Thread Mathieu Basille

Dear Timothy,

Thanks for the hint! I didn't know about the package yags... I was 
able to install it and use it in simple cases (glm), and it does provide 
a QIC!


However, it seems to be limited to the case of GLM (any family), but not 
Cox models... At least, I was unable to use it with a Cox model approach.


Last but not least, the routine that computes the QIC (pan.aic) is in C, 
not in R, and my skills in C are below zero.


Any idea?
Mathieu.


PS: I cc-ed back the list, since it could be useful there...




Le 09/11/2010 05:04, treid a écrit :

Hi Mathieu,
Someone has probably already told you, but just in case, there is an R
package named yags that does QIC. Last I looked, you had to go to the
R-forge site to get it rather than cran.
tim.

- Original Message -
From: Mathieu Basille basi...@ase-research.org
Date: Monday, November 8, 2010 16:32
Subject: [R-sig-eco] QIC for conditional logistic regression + GEE
To: r-sig-ecology@r-project.org

  Dear list,
 
  I'm currently trying to fit a conditional logistic regression on
  correlated data (these are actually steps from animals, with 1
  case and a bunch of random controls). The state of the art is to
  use a GEE approach to estimate the variance of the coefficients,
  using a coxph model by strata (composed of one step +
  corresponding random steps), and a clustered estimation of the
  variances (i.e. robust variances). This is quite easy to achieve
  in R, with nevertheless some convergence problems...
 
  The next step, however, is to select the best model within a set
  of competing ones. Again, the state of the art is to use the
  Quasi-likelihood under Independence Criterion (QIC) [1] also
  sometimes known as modified AIC [2].
 
  After an extensive search (with the help of rseek.org), I was
  unable to find any guidance for this criterion using R. I know
  the criterion is already available in SAS or Stata, but I was
  wondering if anyone tried to code QIC in R? That would be a very
  valuable tool in the R toolbox!
 
  I was considering posting this question directly to the main R-
  help, but decided to try it here first... Let me know if it is
  the right move!
 
  Sincerely,
  Mathieu Basille.
 
 
  [1] Pan, W. (2001a). Akaike's information criterion in
  generalized estimating equations. Biometrics, 57, 120-125.
 
http://www.biostat.jhsph.edu/~fdominic/teaching/bio655/references/extra/QIC.biometrics.pdf
 
  [2] McCullagh, P., and Nelder, J. A. (1989). Generalized Linear
  Models (2nd ed.). London:Chapman  Hall.
 
  See an example in: A. H. M. M. Latif, M. Z. Hossain and M. A.
  Islam: Model selection using modified Akaike's Information
  Criterion: an application to maternal morbidity data. Austrian
  Journal of Statistics, 37, 2008, 175-184.
  http://www.stat.tugraz.at/AJS/ausg082/082Latif.pdf
 
 
  --
 
  ~$ 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.
 
  ___
  R-sig-ecology mailing list
  R-sig-ecology@r-project.org
  https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


--

~$ 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.

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Warning message when creating ltraj files

2010-08-12 Thread Mathieu Basille
 51.41260622 813.4440399 5701.670425 2 2
2006-06-18 06:57:07 -5.98775543 51.41267244 811.6018087 5701.677768 2 2
2006-06-18 06:58:02 -5.974175598 51.41253374 809.7611497 5701.662386 2 2
2006-06-18 06:58:54 -5.960625316 51.41187295 807.9244959 5701.589104 2 2
2006-06-18 06:59:47 -5.947075033 51.41121216 806.0878421 5701.515822 2 2
2006-06-18 07:00:41 -5.933506128 51.41073386 804.2486641 5701.462779 2 2
2006-06-18 07:01:34 -5.919932857 51.41029834 802.4088944 5701.41448 2 2
2006-06-18 07:02:28 -5.906357595 51.40991035 800.5688548 5701.371451 2 2
2006-06-18 07:03:20 -5.892766569 51.40989859 798.7266784 5701.370148 2 2
2006-06-18 07:04:11 -5.879175543 51.40988684 796.8845021 5701.368844 2 2
2006-06-18 07:05:01 -5.865685103 51.41065218 795.0559596 5701.453721 2 2
2006-06-18 07:05:50 -5.852273708 51.41202819 793.2381311 5701.60632 2 2
2006-06-18 07:06:39 -5.838862313 51.4134042 791.4203026 5701.75892 2 2
2006-06-18 07:07:29 -5.825418459 51.41464934 789.5980745 5701.897006 2 2
2006-06-18 07:08:19 -5.811954736 51.41581437 787.7731533 5702.026209 2 2
2006-06-18 07:09:09 -5.798491013 51.4169794 785.9482321 5702.155411 2 2
2006-06-18 07:09:54 -5.787447046 51.42188136 784.4512933 5702.699039 2 2
2006-06-18 07:10:39 -5.7764647 51.42687848 782.9627067 5703.253221 2 2
2006-06-18 07:11:25 -5.765482353 51.4318756 781.4741202 5703.807403 2 2
2006-06-18 07:12:10 -5.756485544 51.43816682 780.2546604 5704.505101 2 2
2006-06-18 07:12:56 -5.748003871 51.4447938 779.105024 5705.240034 2 2
2006-06-18 07:13:42 -5.739522198 51.45142078 777.9553877 5705.974968 2 2
2006-06-18 07:14:35 -5.72728434 51.45491467 776.2966247 5706.362441 2 2
2006-06-18 07:15:29 -5.714676499 51.45809995 774.5877127 5706.71569 2 2
2006-06-18 07:30:48 -5.703759612 51.4568175 773.1079988 5706.573466 2 2
2006-06-18 07:32:39 -5.696167729 51.46360426 772.0789677 5707.326119 2 2
2006-06-18 07:33:51 -5.688566796 51.47063575 771.0487101 5708.105913 2 2
2006-06-18 07:34:44 -5.681469717 51.47786456 770.0867466 5708.90759 2 2
2006-06-18 07:35:28 -5.674640269 51.48519818 769.1610588 5709.72089 2 2
2006-06-18 07:36:12 -5.667810822 51.49253181 768.235371 5710.534191 2 2
2006-06-18 07:36:55 -5.660981374 51.49986543 767.3096833 5711.347492 2 2
2006-06-18 07:37:39 -5.653269016 51.50673633 766.2643226 5712.109476 2 2
2006-06-18 07:38:23 -5.64281024 51.51216784 764.8467027 5712.711831 2 2
2006-06-18 07:39:08 -5.632351465 51.51759934 763.4290828 5713.314187 2 2
2006-06-18 07:39:52 -5.622135669 51.52318135 762.0443973 5713.933233 2 2
2006-06-18 07:40:36 -5.61348266 51.52973133 760.8715376 5714.659627 2 2
2006-06-18 07:41:21 -5.604829652 51.53628131 759.6986778 5715.386021 2 2
2006-06-18 07:42:05 -5.596176643 51.54283129 758.525818 5716.112415 2 2
2006-06-18 07:42:49 -5.587523635 51.54938126 757.3529583 5716.838809 2 2
2006-06-18 07:43:33 -5.578870626 51.55593124 756.1800985 5717.565203 2 2
2006-06-18 07:44:19 -5.571172583 51.56284924 755.1366781 5718.332412 2 2
2006-06-18 07:45:08 -5.565611693 51.57059086 754.3829352 5719.190959 2 2
2006-06-18 07:45:56 -5.560050802 51.57833248 753.6291922 5720.049506 2 2
2006-06-18 07:46:45 -5.554489912 51.5860741 752.8754493 5720.908053 2 2
2006-06-18 07:47:34 -5.548929022 51.59381571 752.1217063 5721.766601 2 2
2006-06-18 07:48:23 -5.543368132 51.60155733 751.3679634 5722.625148 2 2
2006-06-18 07:49:11 -5.537807242 51.60929895 750.6142204 5723.483695 2 2
2006-06-18 07:50:00 -5.532246352 51.61704057 749.8604775 5724.342242 2 2
2006-06-18 07:50:49 -5.526685462 51.62478218 749.1067345 5725.20079 2 2
2006-06-18 07:51:37 -5.521124572 51.6325238 748.3529915 5726.059337 2 2
2006-06-18 08:06:02 -5.508869792 51.63209301 746.6919348 5726.011562 2 2
2006-06-18 08:08:30 -5.50812194 51.63989581 746.5905683 5726.876894 2 2

BIRD15=read.delim2(BIRD15.txt)

date=as.POSIXct(BIRD15[,1])
id=as.factor(BIRD15[,6])
burst=as.factor(BIRD15[,7])
xy=data.frame(BIRD15[,4],BIRD15[,5])
BIRD15=as.ltraj(xy, date, id, burst = id, typeII = TRUE,slsp = c(remove,
missing))




--

~$ 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.

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Strange calculation of dt in adehabitat

2010-07-15 Thread Mathieu Basille

Anders,

I run into the exact same problem because of DST. As you said that it 
was GPS data, it is safe to explicitly set up the timezone to GMT (or to 
any other timezone *without* DST that better suits your needs) at the 
importation step. For example, try:


as.POSIXct(strptime(points$LMT_Date, format = %Y-%m-%d %H:%M:%S, tz = 
GMT)) ## Check out the exact 'format' here


And then have a look again at your results. The problem comes from 
as.POSIXct which assumes, if not stated otherwise, that times are in 
your locale (i.e. LC_TIME=Swedish_Sweden.1252, I guess with DST). And 
the output of the trajectory does not tell you the actual timezone. To 
be sure of this, try:


points$LMT_Date[6]
points$LMT_Date[7]

The second time should be with DST. Alternatively, you can use the 
modified function attached, which shows you, in a ltraj summary, the 
timezone of the different bursts.


Hope this helps,
Mathieu.


Anders Kagervall a écrit :

Hi Matt,

From: Matt Beard [mailto:biozealo...@gmail.com] 
Sent: den 10 juli 2010 04:35

To: Anders Kagervall
Cc: r-sig-ecology@r-project.org
Subject: Re: [R-sig-eco] Strange calculation of dt in adehabitat

Anders,


I was not able to recreate your problem with the demo you provided. What are the details of your platform? 


Here is my sessionInfo()
R version 2.10.1 (2009-12-14) 
i386-pc-mingw32 


locale:
[1] LC_COLLATE=Swedish_Sweden.1252  LC_CTYPE=Swedish_Sweden.1252   
[3] LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C   
[5] LC_TIME=Swedish_Sweden.1252


attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base 


other attached packages:
[1] gpclib_1.5-1 adehabitat_1.8.3 ade4_1.4-14 


I also ran the test with Linux and R 2.11.1 and got the same results.
However, your comment made me think a little further and I'm now pretty sure 
that the problem comes from the fact that 2008-10-26 was a date when we changed 
from daylight savings time to normal time. I tested by replacing the month from 
 10 to 09 in the data file and got results without any missing points.
I'm still not sure if the problem I see is in how we record time in our 
database or how adehabitat calculates the time interval.  I will re-run the 
analyze using GMT-datetime, that we also have in the database, and see if I can 
get rid of the problem.

ps
Your assumption about the precision of the X and Y coordinates was correct. I 
have now attached the actual data file I used.
ds 





___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


--

~$ 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.
summary.ltraj - function (object, ...) 
{
if (!inherits(object, ltraj)) 
stop(object should be of class \ltraj\)
id - factor(unlist(lapply(object, function(x) attr(x, id
burst - unlist(lapply(object, function(x) attr(x, burst)))
nr - unlist(lapply(object, nrow))
na - unlist(lapply(object, function(i) sum(is.na(i[, 1]
if (attr(object, typeII)) {
beg - unlist(lapply(object, function(i) i$date[1]))
## MB (2010-02-25)
## Next line added to take into account the time zone
beg - as.POSIXct(as.POSIXlt(beg, origin=1970-01-01, tz = 
attr(object[[1]]$date, tzone)))
endd - unlist(lapply(object, function(i) i$date[nrow(i)]))
## MB (2010-02-25)
## Next line added to take into account the time zone
endd - as.POSIXct(as.POSIXlt(endd, origin=1970-01-01, tz = 
attr(object[[1]]$date, tzone)))
## MB (2010-02-25)
## Next line removed to take into account the time zone
## class(beg) - class(endd) - c(POSIXct, POSIXt)
pr - data.frame(id = id, burst = burst, nb.reloc = nr, 
NAs = na, date.begin = beg, date.end = endd)
}
else {
pr - data.frame(id = id, burst = burst, Nb.reloc = nr, 
NAs = na)
}
return(pr)
}

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] FPT and Adehabitat

2010-04-22 Thread Mathieu Basille
6.2 6.2 614549.490005753746.7
2006-06-2121:08:18-7.3452751.92961
6.2 6.2 613772.550005754502.5
2006-06-2121:10:37-7.3604151.93295
6.2 6.2 612723.160005754850.9
2006-06-2121:16:36-7.4005651.94133
6.2 6.2 609942.270005755721.4
2006-06-2121:18:49-7.4002851.94125
6.2 6.2 609962.290005755712.4
2006-06-2121:21:01-7.4004451.94117
6.2 6.2 609951.370005755703.6
2006-06-2121:23:25-7.4004651.94107
6.2 6.2 609949.790005755692.1
2006-06-2121:25:37-7.4000851.94118
6.2 6.2 609976.090005755705.0
2006-06-2121:27:55-7.4001651.94100
6.2 6.2 609971.020005755685.3
2006-06-2121:31:25-7.4007551.94086
6.2 6.2 609930.75755669.0
2006-06-2121:34:33-7.4003651.94086
6.2 6.2 609957.630005755668.9
2006-06-2121:37:55-7.4003651.94075
6.2 6.2 609957.560005755656.4


Dr Samantha Patrick
EU INTERREG Post Doc
Marine Biology  Ecology Research Centre
University of Plymouth
Plymouth
PL4 8AA

T: 01752 584699
M: 07740472719

-Original Message-
From: Clément Calenge [mailto:clement.cale...@oncfs.gouv.fr]
Sent: 21 April 2010 11:18
To: Samantha Patrick
Cc: r-sig-ecology@r-project.org
Subject: Re: [R-sig-eco] FPT and Adehabitat

Hard to say without any reproducible example... could you post an
example (minimum dataset + R code)?
Best regards,

Clément Calenge

Samantha Patrick wrote:


 
I am calculating First Passage Time for GPS movements.  The code 
all runs fine and R recognises that an individual, for example, has 
139 relocations.  However when I then view the FPT output there are 
295 data points.  I have checked back and the data file, the 
imported data and  the number of time points all equal 139.  In the 
help it says that the FPT output is a data frame per individual 
with a row for each relocation so I cannot understand why it is 
outputting so many rows.  This happens for many individuals but 
there doesn't not seem to be any pattern in the number of output 
rows and occurs if I run individuals separately.  Has anyone ever 
come across this or have any ideas?


Many Thanks

Sam


Dr Samantha Patrick
EU INTERREG Post Doc
Marine Biology  Ecology Research Centre
University of Plymouth
Plymouth
PL4 8AA

T: 01752 584699
M: 07740472719


 [[alternative HTML version deleted]]

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology





  

--
Clément CALENGE
Cellule d'appui à l'analyse de données
Office national de la chasse et de la faune sauvage
Saint Benoist - 78610 Auffargis
tel. (33) 01.30.46.54.14







--
Clément CALENGE
Cellule d'appui à l'analyse de données
Office national de la chasse et de la faune sauvage
Saint Benoist - 78610 Auffargis
tel. (33) 01.30.46.54.14


  





--

~$ 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.

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] adehabitat - data projection

2010-02-03 Thread Mathieu Basille
As previously highlighted by Kingsford and Tammy, you need to go through
the rgdal package, which handles projection systems in R (via the GDAL
library).

For example, say you have a data frame Toto with one column Lat, one
column Long giving coordinates from e.g. a GPS collar, and whatever
other columns. At the end you want the same data frame, but projected in
UTM zone 19 (datum NAD83). First you need to convert the data frame into
a SpatialPointsDataFrame (package sp)*:

coordinates(Toto) - ~Long+Lat# You provide the names of the columns

And then define the projection system:

proj4string(Toto) - CRS(+proj=longlat +datum=WGS84)

Now, you need to know the parameters of you new projection. I find it
handy to look at the EPSG code of your projection, much easier to use
than the full series of parameters. First build the EPSG index:

EPSG - make_EPSG()

Then you can search within it (here you need to adjust with what you're
looking for):

EPSG[grep(NAD83 / UTM zone 19, EPSG$note), ]

And finally, you can reproject using the EPSG code you found:

Toto - spTransform(Toto, CRS(+init=epsg:26919))

Now, you have a nice SpatialPointsDataFrame projected in the correct
projection system. If you want to use the points coordinates in home
range calculations, they are available with the function coordinates
again (which returns a matrix of coordinates):

Coord - data.frame(coordinates(Toto))

Hope this helps,
Mathieu.


* I assumed you don't have NAs in the coordinates, otherwise you need to
adjust it a little bit to remove them (coordinates do not allow for NAs).


danik a écrit :
 I'm just starting to use adehabitat to do home range calculations, and I'm
 wondering if there is a simple way to convert my xy coordinates (which are
 in decimal degrees) to UTMs or kilometers. The demo(homerange) already has
 their coordinates listed in kilometers, so I'm not quite sure how to get to
 that step.
 
 Another option would be to project my data. There is a package called
 mapproj, but I also am not sure how that works. I usually work with GIS so R
 is new to me. Any help is appreciated. Thank you.

-- 

~$ 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.

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


Re: [R-sig-eco] Producing ENFA derived suitability maps with adehabitat

2009-09-13 Thread Mathieu Basille
Dear all,

[This is a slightly modified version of a message posted on R-SIG-Geo. I
post here too for the sake of consistency]

The so-called predictions of the ENFA (function 'predict.enfa') are
based on the row coordinates ($li) and the vector of presence ($pr).
From the row coordinates, the function computes Mahalanobis distances
from the center of the niche to every pixel (row), given the niche
covariance structure.

The row coordinates gives you the coordinates of every pixel projected
into the new space created by the ENFA. You can compute them by hand by
multiplying the (scaled) table of environmental variables with the
columns coordinates. For example, following the example of the function
'enfa':

## We load the data
data(lynxjura)
map - lynxjura$map
tmp - lynxjura$locs[,4]!=D
locs - lynxjura$locs[tmp, c(X,Y)]
map[,4] - sqrt(map[,4])

## We perform the ENFA
dataenfa1 - data2enfa(map, locs)
pc - dudi.pca(dataenfa1$tab, scannf = FALSE)
(enfa1 - enfa(pc, dataenfa1$pr, scannf = FALSE))

## We compute the row coordinates by hand and check that this is
## correct
bla - as.matrix(enfa1$tab) %*% as.matrix(enfa1$co)
all.equal(bla, as.matrix(enfa1$li))

This means that we can then reproject any new environmental variable
into the space created by the ENFA. Let's say that a second set of
environmental maps is called 'map2'. It can be then projected as follows:

li2 - as.matrix(scale(kasc2df(map2)$tab)) %*% as.matrix(enfa1$co)

Note that:
1) the table must be scaled, as is the $tab component of an ENFA object
(modified array).
2) for the sake of simplicity, I used here the function 'scale', which
used a N-1 denominator. In the ENFA example, a PCA ('dudi.pca') is ran
first on the data, before we use the scale table. In the 'dudi.pca'
function, the denominator is N, so that it might give slightly different
results (negligible for large N).

Then, to predict, you must use an adapted 'predict.enfa' function,
with a 'new' argument in which we feed the new maps:

predict.enfa - function (object, index, attr, nf, new, ...)
{
if (!inherits(object, enfa))
stop(should be an object of class \enfa\)
warning(the enfa is not mathematically optimal for prediction:\n
please consider the madifa instead)
if ((missing(nf)) || (nf  object$nf))
nf - object$nf
Zli - object$li[, 1:(nf + 1)]
f1 - function(x) rep(x, object$pr)
Sli - apply(Zli, 2, f1)
m - apply(Sli, 2, mean)
cov - t(as.matrix(Sli)) %*% as.matrix(Sli)/nrow(Sli)
if (!missing(new))
Zli - as.matrix(dudi.pca(kasc2df(new)$tab, scannf = FALSE,
   nf = 1)$tab) %*% as.matrix(object$co)
maha - mahalanobis(Zli, center = m, cov = cov)
map - getkasc(df2kasc(data.frame(toto = maha, tutu = maha),
index, attr), toto)
return(invisible(map))
}

And this should work like this:

pred2 - predict(enfa1, dataenfa1$index, dataenfa1$attr, new = map2)

Note that the two maps have here the same attributes. It still works if
it's not the case, simply by adjusting the index and attr in the predict
call (given by a kasc2df on map2).

Hope this helps,
Mathieu.



Alexandre VILLERS a écrit :
 Dear list(s) 'members,
 
 I have a dataset representing the position of a species over a large
 region for 3 different years (2000, 2004 and 2008) and seven
 ecogeographical variables. Given that the study takes place on an
 agricultural region, the landscape changes every year at fine scale and
 there is a long term trend in crops sowed, leading me to account for
 between years variability.
 I would like to use the niche determined by the landscape and location
 of birds in 2000 and then, appply this niche over the landscape in 2004
 and 2008 (this would, I believe, give me a first answer on whether
 changes in birds' location are due to a decrease in habitat suitability
 or birds).
 I have already computed ENFA with adehabitat (using the doc provided
 with the package adehabitat and the www.spatial-analyst.net of T.
 Hengl) but I don't see how exactly using the result of an ENFA on a
 new landscape...
 
 Any link or help would be welcome.
 
 Alex
 

-- 

~$ whoami
Mathieu Basille, PhD

~$ locate
Laboratoire de Biométrie et Biologie Évolutive
Université Claude Bernard Lyon 1 - France
http://lbbe.univ-lyon1.fr/

~$ info
http://ase-research.org/basille

~$ fortune
``If you can't win by reason, go for volume.''
Calvin, by Bill Watterson.

___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology