# NOT RUN {
# Using the included simulated movement data
require(bcpa)
data(Simp)
plot(Simp)
Simp.VT <- GetVT(Simp)
## note: column names of Simp.VT include:
### "S" - step length
### "Theta" - turning angle
### T.start" "T.end" "T.mid" "T.POSIX" - time variables
if(interactive())
Simp.ws <- WindowSweep(Simp.VT, "V*cos(Theta)", windowsize = 50,
windowstep = 1, progress=TRUE) else
Simp.ws <- WindowSweep(Simp.VT, "V*cos(Theta)", windowsize = 50,
windowstep = 1, progress=FALSE)
plot(Simp.ws, threshold = 7)
plot(Simp.ws, type = "flat", clusterwidth = 3)
PathPlot(Simp, Simp.ws)
PathPlot(Simp, Simp.ws, type="flat")
DiagPlot(Simp.ws)
# Example of application on one dimensional data (e.g. depth)
# simulate some data with three change points: surface, medium, deep, surface
## random times within 100 hours of now
n.obs <- 100
time = sort(Sys.time() - runif(n.obs, 0, n.obs) * 60 * 60)
d1 <- 50; d2 <- 100
t1 <- 25; t2 <- 65; t3 <- 85
sd1 <- 1; sd2 <- 5; sd3 <- 10
dtime <- as.numeric(difftime(time, min(time), units="hours"))
phases <- cut(dtime, c(-1, t1, t2, t3, 200), labels = c("P1","P2","P3","P4"))
means <- c(0,d1,d2,0)[phases]
sds <- c(sd1,sd2,sd3,sd1)[phases]
depth <- rnorm(n.obs,means, sds)
# make all depths positive!
depth <- abs(depth)
mydata <- data.frame(time, depth)
# perform windowsweep
ws <- WindowSweep(mydata, "depth", time.var = "time", windowsize = 30,
windowstep = 1, progress=interactive())
plot(ws)
plot(ws, type = "flat", cluster = 6)
ChangePointSummary(ws, cluster = 6)
# }
Run the code above in your browser using DataLab