The script worked fine for a different animal over several days, but when I got to this individual, it estimated distance travelled on Day 1, and I got the error on Day 2.
I have used other functions in the ctmm package with this same dataset without issue, so I'm inclined to think the issue isn't with the data, but I'm at a loss to explain what's happening.
### Estimate daily movement distance over the duration of the animal wearing the collar
days<-unique(
mydata2.tel$day) #determines how many days the animal was tracked for
res<-list() #Empty list to fill with the results
#Loop over the number of days
for(i in 1:length(days)){
message("Estimating distance travelled on day ", i, ": ", days[i])
#Select data for the day in question
#Calculate the duration of the sampling period in seconds
SAMP.TIME<-diff(c(mydata2.tel.SUBSET$t[1],
mydata2.tel.SUBSET$t[nrow(mydata2.tel.SUBSET)]))
#Guesstimate the model for initial parameter values
#Turn error on
GUESS$error<-TRUE
#Fits the movement model to the day's data
FITS<-ctmm.fit(mydata2.tel.SUBSET, CTMM=GUESS)
#Calculate the speed in m/s
ctmm_speed<-speed(object= mydata2.tel.SUBSET, CTMM= FITS, units = FALSE)
#Multiply speed (in m/s) by the sample time (in s) to get the estimate distance traveled (in m)
ctmm_dist<-ctmm_speed*SAMP.TIME
#Rename the variable
rownames(ctmm_dist) <- "distance (meters)"
#Store the results in the list
x<-c(i, #The day
ctmm_dist[2], #The ML distance estimate
ctmm_dist[1], #Min CI
ctmm_dist[3]) #Max CI
names(x) <- c("date", "dist.ML", "dist.Min", "dist.Max")
res[[i]]<-x
}