if(require(unmarked)) {
##example with mallard data set from unmarked package
data(mallard)
mallardUMF <- unmarkedFramePCount(mallard.y, siteCovs = mallard.site,
obsCovs = mallard.obs)
##run model with zero-inflated Poisson abundance
fm.mall.one <- pcount(~ ivel + date ~ length + forest, mallardUMF, K=30,
mixture = "ZIP")
##make prediction
predictSE.zip(fm.mall.one, type = "response", parm.type = "lambda",
newdata = data.frame(length = 0, forest = 0, elev = 0))
##compare against predict
predict(fm.mall.one, type = "state", backTransform = TRUE,
newdata = data.frame(length = 0, forest = 0, elev = 0))
##add offset in model to scale abundance per transect length
fm.mall.off <- pcount(~ ivel + date ~ forest + offset(length), mallardUMF, K=30,
mixture = "ZIP")
##make prediction
predictSE.zip(fm.mall.off, type = "response", parm.type = "lambda",
newdata = data.frame(length = 10, forest = 0, elev = 0))
##compare against predict
predict(fm.mall.off, type = "state", backTransform = TRUE,
newdata = data.frame(length = 10, forest = 0, elev = 0))
detach(package:unmarked)
}
Run the code above in your browser using DataLab