## Predicting behaviour for a land bird: simplified fit for illustration
data("blackcap")
bfit <- fitme(migStatus ~ means+ Matern(1|longitude+latitude),data=blackcap,
fixed=list(lambda=0.5537,phi=1.376e-05,rho=0.0544740,nu=0.6286311))
## the plot itself, with a sea mask,
## and an ad hoc 'pointmask' to see better the predictions on small islands
#
def_pointmask <- function(xy,r=1,npts=12) {
theta <- 2*pi/npts *seq(npts)
hexas <- lapply(seq(nrow(xy)), function(li){
p <- as.numeric(xy[li,])
hexa <- cbind(x=p[1]+r*cos(theta),y=p[2]+r*sin(theta))
rbind(rep(NA,2),hexa) ## initial NA before each polygon
})
do.call(rbind,hexas)
}
ll <- blackcap[,c("longitude","latitude")]
pointmask <- def_pointmask(ll[c(2,4,5,6,7),],r=0.8) ## small islands only
#
if (spaMM.getOption("example_maxtime")>1) {
data("seaMask")
filled.mapMM(bfit,add.map=TRUE,
plot.title=title(main="Inferred migration propensity of blackcaps",
xlab="longitude",ylab="latitude"),
decorations=quote(points(pred[,coordinates],cex=1,pch="+")),
plot.axes=quote({axis(1);axis(2);
polypath(rbind(seaMask,pointmask),border=FALSE,
col="grey", rule="evenodd")
}))
}
Run the code above in your browser using DataLab