zlong
2012-Oct-28 02:05 UTC
[R] Trouble with first passage time analysis using adehabitatLT
Hey all, I've run into a few problems running first passage time analysis. I'm hoping someone might be able to help me sort this out. I'm fine up to the point of creating the ltraj object from a dataset. /test<-read.table("~/Desktop/R_Directory/test.txt",header=TRUE) attach(test) library(adehabitatLT) xy<-test[,c("x","y")] date1<-as.character(date) date<-as.POSIXct(date1) fit1<-as.ltraj(xy,date,id=test$name,burst=name,typeII=TRUE)/ from here things start to get fuzzy 1) Instead of following the basic expression, /fpt(lt, radii, units = c("seconds", "hours", "days"))/ the sample code on the tutorial expressed fpt as, /fpt(lt, seq(300,1000, length=30))/ But as far as I can tell this code does not set a specific radius distance (e.g., 100 m), but rather defines how many radii are to be distributed across the dataset. The example code returns values for 30 radii (i.e., "length=30"). /data(puechcirc) i <- fpt(puechcirc, seq(300,1000, length=30)) plot(i, scale = 500, warn = FALSE)/ Modifying the code, I calculated values for 5 radii using a subsample of my data (attached below). /i <- fpt(fit1, seq(1,100, length=5)) plot(i, scale = 5, warn = FALSE) i/ [[1]] r1 r2 r3 r4 r5 1 NA NA NA NA NA 2 80403.66 NA NA NA NA 3 58711.45 NA NA NA NA 4 5325.09 137121.1 NA NA NA 5 25695.41 432542.8 587729.9 742917.0 2061795 6 32629.12 394459.5 553960.4 713461.3 2050644 7 13175.66 489781.9 649159.8 1441978.8 2088730 8 35531.17 1362903.1 1521188.3 1702321.9 2107085 9 60181.97 1348559.8 1515091.3 1698974.1 2124975 10 106913.46 1323955.4 1504503.8 1700214.7 2151971 11 94222.94 1334576.0 1513000.0 1711400.7 2145693 12 66315.86 1329840.1 1488550.8 1647261.5 2089818 13 68114.22 1352723.6 1512442.1 1690046.2 2098154 14 20141.44 1339237.6 1504857.4 1677927.2 2123560 15 5553.17 142994.1 NA NA NA 16 231598.68 NA NA NA NA 17 231598.68 NA NA NA NA 18 NA NA NA NA NA Sample_plot.pdf <http://r.789695.n4.nabble.com/file/n4647675/Sample_plot.pdf> Fig. 1. fpt(lt, seq(300,1000, length=30)) Is there a way to manually select radius distance (in meters) rather than specifying how many radii you?d like distributed across the dataset? Or am I mistaken, and I simply have to estimate radius distances from the spatial extent of my data (e.g., if an animal traveled 5 km and I had 5 radii, they are spaced 1000 m apart). 2) I was able to replicate the same pattern (at least graphically) using the basic expression by setting radii=1. Unsurprisingly, this only produces data for 1 radius. /k<-fpt(fit1,radii=1,units= "days") plot(k,scale=1) k/ [[1]] r1 1 NA 2 0.93059793 3 0.67953065 4 0.06163299 5 0.29740059 6 0.37765181 7 0.15249607 8 0.41124037 9 0.69655056 10 1.23742436 11 1.09054333 12 0.76754471 13 0.78835903 14 0.23311856 15 0.06427280 16 2.68054024 17 2.68054024 18 NA Basic_plot.pdf <http://r.789695.n4.nabble.com/file/n4647675/Basic_plot.pdf> Fig. 2. k<-fpt(fit1,radii=1,units= "days") However, setting ?radii=5? I receive a completely different pattern, but still only values for a single radius. This prevents me from plotting meanfpt and varlogfpt values, which are what I really need. /l<-fpt(fit1,radii=5,units= "days") plot(l,scale=5) l/ [[1]] r1 1 NA 2 3.5896499 3 4.2353756 4 0.3081650 5 1.4870029 6 1.8882590 7 0.7624803 8 2.0562018 9 3.4827528 10 4.3457374 11 5.3108066 12 3.8377235 13 3.9417951 14 1.1655928 15 0.3213640 16 NA 17 NA 18 NA basic_5.pdf <http://r.789695.n4.nabble.com/file/n4647675/basic_5.pdf> Fig. 3. l<-fpt(fit1,radii=5,units= "days") So clearly "length=x" in the sample code and "radii=x" in the basic expression do not reflect the same information. Is there a way to manually set radius distances in the basic expression and get it to spit out data for as many radii as are necessary to cover the spatial extent of the data? 3) I don?t quite understand the units on the Y-axis. My data are in 'days', so I would assume that the FPT would also be expressed in days (as I believe Fig. 2 and 3 are). However, the data produced by the sample code appear to be expressed in some other unit (Fig. 1). Since the sample code seems to be my most promising avenue (aside from not understanding how radii are defined), I'd like to be able to have the Y-axis expressed in days. Is there any way to do that? I have attached the small dataset I was using to test out the code in case you'd like to play around with the data. test.txt <http://r.789695.n4.nabble.com/file/n4647675/test.txt> As a point of interest, the data represent radio-telemetry points of a western toad. Thanks a lot -- View this message in context: http://r.789695.n4.nabble.com/Trouble-with-first-passage-time-analysis-using-adehabitatLT-tp4647675.html Sent from the R help mailing list archive at Nabble.com.
zlong
2012-Oct-28 16:06 UTC
[R] Trouble with first passage time analysis using adehabitatLT
I was able to answer a few of my question on my own. The units for the Y-axis can be set to days with the following: /fpt(fit1, seq(length=5), units="days") / This sets the y-axis units to 'days', defines the number of radii (5), and removes the scaling function that wasn't really necessary for my work. This code creates the same graphical output as Fig. 3, but includes data for all 5 radii. /q<-fpt(fit1, seq(length=5), units="days") plot(q, scale=5) q/ [[1]] r1 r2 r3 r4 r5 1 NA NA NA NA NA 2 0.93059793 1.8611959 2.7917938 3.2376702 3.5896499 3 0.67953065 1.3590613 2.0385919 3.0999968 4.2353756 4 0.06163299 0.1232660 0.1848990 0.2465320 0.3081650 5 0.29740059 0.5948012 0.8922018 1.1896024 1.4870029 6 0.37765181 0.7553036 1.1329554 1.5106072 1.8882590 7 0.15249607 0.3049921 0.4574882 0.6099843 0.7624803 8 0.41124037 0.8224807 1.2337211 1.6449615 2.0562018 9 0.69655056 1.3931011 2.0896517 2.7862022 3.4827528 10 1.23742436 2.4748487 3.2033270 3.7745322 4.3457374 11 1.09054333 2.1810867 3.3980111 4.6539895 5.3108066 12 0.76754471 1.5350894 2.3026341 3.0701788 3.8377235 13 0.78835903 1.5767181 2.3650771 3.1534361 3.9417951 14 0.23311856 0.4662371 0.6993557 0.9324742 1.1655928 15 0.06427280 0.1285456 0.1928184 0.2570912 0.3213640 16 2.68054024 3.3610805 4.0416207 NA NA 17 2.68054024 3.3610805 4.0416207 NA NA 18 NA NA NA NA NA I'd still like to know how I can set radii as a function of distance. -- View this message in context: http://r.789695.n4.nabble.com/Trouble-with-first-passage-time-analysis-using-adehabitatLT-tp4647675p4647704.html Sent from the R help mailing list archive at Nabble.com.