coordsHabitatGridCenter <- matrix(c(0.5, 3.5,
1.5, 3.5,
2.5, 3.5,
3.5, 3.5,
0.5, 2.5,
1.5, 2.5,
2.5, 2.5,
3.5, 2.5,
0.5, 1.5,
1.5, 1.5,
2.5, 1.5,
3.5, 1.5,
0.5, 0.5,
1.5, 0.5,
2.5, 0.5,
3.5, 0.5), ncol = 2,byrow = TRUE)
colnames(coordsHabitatGridCenter) <- c("x","y")
# Create observation windows
lowerCoords <- matrix(c(0, 0, 1, 0, 0, 1, 1, 1), nrow = 4, byrow = TRUE)
upperCoords <- matrix(c(1, 1, 2, 1, 1, 2, 2, 2), nrow = 4, byrow = TRUE)
colnames(lowerCoords) <- colnames(upperCoords) <- c("x","y")
# Rescale coordinates
ScaledLowerCoords <- scaleCoordsToHabitatGrid(coordsData = lowerCoords,
coordsHabitatGridCenter = coordsHabitatGridCenter)
ScaledUpperCoords <- scaleCoordsToHabitatGrid(coordsData = upperCoords,
coordsHabitatGridCenter = coordsHabitatGridCenter)
ScaledUpperCoords$coordsDataScaled[,2] <- ScaledUpperCoords$coordsDataScaled[,2] + 1.5
ScaledLowerCoords$coordsDataScaled[,2] <- ScaledLowerCoords$coordsDataScaled[,2] - 1.5
# Detection locations
x <- matrix(c(1.5, 2, 1.1, 1.5,0.6, 2.1, 0.5, 2, 1, 1.5), nrow = 5, byrow = TRUE)
# get the window indeces on the third dimension of x
windowIndexes <- 0
for(i in 1:nrow(x)){
windowIndexes[i] <- getWindowIndex(curCoords = x[i,],
lowerCoords = ScaledLowerCoords$coordsDataScaled,
upperCoords = ScaledUpperCoords$coordsDataScaled)
}
x <- cbind(x, windowIndexes)
# get the total number of detections on x[1,1]
x <- rbind(c(length(windowIndexes),0,0) ,x )
s <- c(1, 1)
sd <- 0.1
baseIntensities <- c(1:4)
windowIndices <- c(1, 2, 2, 3, 4)
numPoints <- 5
numWindows <- 4
indicator <- 1
dpoisppDetection_normal(x, lowerCoords, upperCoords, s, sd, baseIntensities,
numMaxPoints = dim(x)[1] , numWindows, indicator, log = TRUE)
Run the code above in your browser using DataLab