Dear list,

I use this code to simulate movement in a landscape that has boundaries. I would like to estimate Kernel densities from the simulated locations and include  a simple boundary. However, I get an error message "Error in 3 * h : non-numeric argument to binary operator" when I run KernelUD() with the boundary, but I can't see what is wrong. Without the boundary the Kernel estimation runs. Would someone be able to help with this ?

Thanks a lot for your time,

Juliane


gamma <- 0.5#drift speed
cv.forage <- 2#random movement coefficient
nexp <- 5#number of individuals
npath <- 1#number of replicate observations
nits <- 100#number of time steps
sigmaw <- gamma*cv.forage#random movement coefficient scaled by gamma
x <- array(dim=c(nits,npath,nexp))
y <- array(dim=c(nits,npath,nexp))
dt <- 1#time step
# Simulate the paths from a start point Rec1
Rec1_x <- -20#x-coordinate of start point
Rec1_y <- -20#y-coordinate of start point
x[1,,] <- Rec1_x
y[1,,] <- Rec1_y
for(i in 2:nits){
  x[i,,] <- x[i-1,,]+dt*gamma+rnorm(npath*nexp,0,sqrt(dt))*sigmaw
  y[i,,] <- y[i-1,,]+dt*gamma+rnorm(npath*nexp,0,sqrt(dt))*sigmaw
}
Move <- matrix(0,nrow=nits*nexp,ncol=2)#put x and y locations into one matrix
Move[1:nits,1] <- x[,1,1]
Move[1:nits,2] <- y[,1,1]
for (i in 2:nexp){
Move[((i-1)*nits+1):(i*nits),1] <- x[,1,i]
Move[((i-1)*nits+1):(i*nits),2] <- y[,1,i]
}
id <- gl(1,nits*nexp)#assumes that all data relate to only one individual
Movement_Spatial <- data.frame(id)#use this to generate a data.frame
coordinates(Movement_Spatial) <- Move#declare the locations in Move to be coordinates in spatial points data.frame idsp
library(raster)
nits <- 100
n <- 5
factor <- 0.5
res <- nits/10
Raster <- raster(ncol=res, nrow=res, xmn=-nits, xmx=nits, ymn=-nits, ymx=nits)
values(Raster) <- round(runif(res*res,min=1,max=5))
library(sp)
Raster_Points <- SpatialPoints(Raster)
Raster_map <- SpatialPixelsDataFrame(points = Raster_Points, data=as.data.frame(values(Raster)))
bound <- cbind(c(-100,-50,50,100),c(-100,50,75,100))
plot(Raster,main="")
lines(bound,lwd=3)
#bound <- do.call("cbind",bound)
cl <- colors()[c(153,178,203,228,253)]
factor <- 0.5
points(x[,1,1],y[,1,1],type="o",pch=1,xlim=c(-nits*factor,nits*factor),ylim=c(-nits*factor,nits*factor),xlab="x",ylab="y")
for (i in 2:nexp){
points(x[,,i],y[,,i], pch=1,col="black",type="o")
}
points(Rec1_x,Rec1_y,pch=16,col="red")
library(adehabitatHR)
Slo1 <- Line(bound)
Sli1 <- Lines(list(Slo1), ID="coastline")
coastline <- SpatialLines(list(Sli1))
Kernel_Raster <- kernelUD(Movement_Spatial,h="href",grid=Raster_map,boundary=coastline)

Dr. Juliane Struve
Fisheries and Aquatic Sciences
7922 NW 71st Street, Gainesville, FL 32653
352-273-3632 (tel)
352-392-3672 (fax)
email: jstruve@ufl.edu<mailto:jstruve@ufl.edu>



	[[alternative HTML version deleted]]

