# NOT RUN {
data(calves) #load data
calves.dateTime<-datetime.append(calves, date = calves$date,
time = calves$time) #add dateTime column
calves.agg<-tempAggregate(calves.dateTime, id = calves.dateTime$calftag,
dateTime = calves.dateTime$dateTime, point.x = calves.dateTime$x,
point.y = calves.dateTime$y, secondAgg = 300, extrapolate.left = FALSE,
extrapolate.right = FALSE, resolutionLevel = "reduced", parallel = FALSE,
na.rm = TRUE, smooth.type = 1) #aggregate to 5-min timepoints
calves.dist<-dist2All_df(x = calves.agg, parallel = FALSE,
dataType = "Point", lonlat = FALSE) #calculate inter-calf distances
calves.contact.block<-contactDur.all(x = calves.dist, dist.threshold=1,
sec.threshold=10, blocking = TRUE, blockUnit = "hours", blockLength = 1,
equidistant.time = FALSE, parallel = FALSE, reportParameters = TRUE)
emp.summary <- summarizeContacts(calves.contact.block,
importBlocks = TRUE) #empirical contact summ.
emp.potential <- potentialDurations(calves.dist, blocking = TRUE,
blockUnit = "hours", blockLength = 1,
distFunction = "dist2All_df")
calves.agg.rand<-randomizePaths(x = calves.agg, id = "id",
dateTime = "dateTime", point.x = "x", point.y = "y", poly.xy = NULL,
parallel = FALSE, dataType = "Point", numVertices = 1, blocking = TRUE,
blockUnit = "mins", blockLength = 20, shuffle.type = 0, shuffleUnit = NA,
indivPaths = TRUE, numRandomizations = 2) #randomize calves.agg
calves.dist.rand<-dist2All_df(x = calves.agg.rand, point.x = "x.rand",
point.y = "y.rand", parallel = FALSE, dataType = "Point", lonlat = FALSE)
calves.contact.rand<-contactDur.all(x = calves.dist.rand,
dist.threshold=1, sec.threshold=10, blocking = TRUE, blockUnit = "hours",
blockLength = 1, equidistant.time = FALSE, parallel = FALSE,
reportParameters = TRUE) #NULL model contacts (list of 2)
rand.summary <- summarizeContacts(calves.contact.rand, avg = TRUE,
importBlocks = TRUE) #NULL contact summary
rand.potential <- potentialDurations(calves.dist.rand, blocking = TRUE,
blockUnit = "hours", blockLength = 1,
distFunction = "dist2All_df")
contactCompare_chisq(x.summary = emp.summary, y.summary = rand.summary,
x.potential = emp.potential, y.potential = rand.potential,
importBlocks = FALSE, shuffle.type = 0,
popLevelOut = TRUE, parallel = FALSE) #no blocking
contactCompare_chisq(x.summary = emp.summary, y.summary = rand.summary,
x.potential = emp.potential, y.potential = rand.potential,
importBlocks = TRUE, shuffle.type = 0,
popLevelOut = TRUE, parallel = FALSE) #blocking
# }
Run the code above in your browser using DataLab