EliGurarie / smoove

Functions and methods for simulating and estimating correlated velocity movement (CVM) models.
7 stars 1 forks source link

Make "sweepRACVM" and a few other functions "ltraj" and "Movebank" compatible #6

Open EliGurarie opened 6 years ago

faridcher commented 6 years ago

done in the latest commit (#9 ). test with :

taus <- c(3, 3, 1)
mus <- c(2, 0, 0)
etas <- c(2, 1, 1)
durations <- c(40,60,100)
Z.raw <- 0
T.raw <- 0
mycvm <- list()
for(i in 1:length(taus)) {
if(i > 1) v0 <- mycvm$V[length(mycvm)] else v0 = mus[1]
mycvm <- simulateRACVM(tau = taus[i], eta = etas[i], mu = mus[i], v0 = v0,
                       Tmax = durations[i], dt = 0.01)
Z.raw <- c(Z.raw, mycvm$Z + Z.raw[length(Z.raw)])
T.raw <- c(T.raw, mycvm$T + T.raw[length(T.raw)])
}
multicvm <- data.frame(Z = Z.raw, T = T.raw)[sample(1:length(Z.raw), 400),] %>% dplyr::arrange(T)
with(multicvm, scan_track(z = Z, time = T))
with(multicvm, sweepRACVM(Z = Z, T = T,
                          windowsize = 80, windowstep = 5,
                          model = "ACVM", progress=FALSE))

data(ibex, package='adehabitatLT')
sweepRACVM(ibex,
           windowsize = 80, windowstep = 5,
           model = "ACVM", progress=FALSE)

data(leroy,package="move")
sweepRACVM(leroy,
           windowsize = 80, windowstep = 5,
           time.unit="hour", #"day" throws error
           model = "ACVM", progress=FALSE)

The dataset from move package throws error because they have NA values.

faridcher commented 6 years ago

this needs more work. we need to deal with the peculiarity of the ltraj and move objects such as NA values etc