Hello All,
Ive been using unmarked to come up with population estimates for a group of restored sites that I randomly sampled between 2012 and 2015. Ive run into a problem with my population estimates which is that the
best model from the first year is different than each of the subsequent
years so the best model from 2012 was forest (continuous) and cp (categorical) but the best model
for subsequent years included forest and crp (continuous). Although I didnt think that
was a major problem to begin with when I generated the estimates the
first year was way higher than all the subsequent years. Anyway, my way
of dealing with that was to come up with a model using all variables
from the top models in all years so the new model includes forest, crp,
and cp however when I run parboot to come up with the standard
error, t0(which is the estimate for all locations combined) comes out as 14434 which is way too high relative to the estimates generated from
either of the previous top models. For some reason when I include cp and crp together the predictions go way up and the variability of the estimates in parboot is extremely high, i.e. it generates estimates greater than 50,000 and all the way down to 3000. Obviously there is some problem but I
cant figure out what it is, if anyone has time could you take a look at
it?
Here is my code and the two files needed to do the analysis.
a<-read.csv("BEVI2012_20m.csv")
y<-a[,2:21]
R<-202
T<-4
crp<-scale(a["crp"])
forest<- scale(a["forest"])
patch<-scale(a["patch"])
db<-c(0,20,40,60,80,100)
site.Covs<-data.frame(cp=a["
cp"], crp, forest, patch)
beviumf<-unmarkedFrameGDS(y=y, siteCovs=site.Covs, survey="point", dist.breaks=db,unitsIn="m", numPrimary=T)
summary(beviumf)
BEVInull<-gdistsamp(~1, ~1, ~1, beviumf, keyfun="halfnorm",output="density", unitsOut="ha",mixture="NB", K=50)
BEVIcp<-gdistsamp(~cp, ~1, ~1, beviumf,keyfun="halfnorm", output="density", unitsOut="ha", mixture="NB", K=50)
BEVIcrp<-gdistsamp(~crp, ~1, ~1, beviumf,keyfun="halfnorm", output="density", unitsOut="ha", mixture="NB", K=50)
BEVIforest<-gdistsamp(~forest, ~1, ~1, beviumf,keyfun="halfnorm", output="density", unitsOut="ha", mixture="NB", K=50)
BEVIpatch<-gdistsamp(~patch, ~1, ~1, beviumf,keyfun="halfnorm",output="density", unitsOut="ha", mixture="NB", K=50)
BEVIpatchsq<-gdistsamp(~(patch)^2, ~1, ~1, beviumf,keyfun="halfnorm",output="density", unitsOut="ha", mixture="NB", K=50)
BEVIforestcp<-gdistsamp(~forest+cp, ~1, ~1, beviumf,keyfun="halfnorm",output="density", unitsOut="ha", mixture="NB", K=50)
BEVIforestcrp<-gdistsamp(~forest+crp, ~1, ~1, beviumf,keyfun="halfnorm",output="density", unitsOut="ha", mixture="NB", K=50)
BEVIforestpatch<-gdistsamp(~forest+patch, ~1, ~1, beviumf,keyfun="halfnorm", output="density", unitsOut="ha", mixture="NB", K=50)
BEVIcppatch<-gdistsamp(~cp+patch, ~1, ~1, beviumf,keyfun="halfnorm",output="density", unitsOut="ha", mixture="NB", K=50)
BEVIcrppatch<-gdistsamp(~crp+patch, ~1, ~1, beviumf,keyfun="halfnorm", output="abund", mixture="NB", K=50)
BEVIcrppatchforest<-gdistsamp(~crp+patch+forest, ~1, ~1, beviumf, keyfun="halfnorm",output="abund", mixture="NB", K=50)
BEVIforestcrpCP<-gdistsamp(~forest+crp+cp, ~1, ~1, beviumf,keyfun="halfnorm",output="density", unitsOut="ha", mixture="NB", K=50)
fmlist<-fitList(BEVInull,
BEVIcp,BEVIcrp, BEVIforest, BEVIpatch, BEVIpatchsq, BEVIforestcp,
BEVIforestcrp, BEVIforestpatch, BEVIcppatch, BEVIcrppatch,
BEVIcrppatchforest,BEVIforestcrpCP)
modSel (fmlist)
#Fit statistics########################################################################################################
fitstats1 <- function(BEVIforestcp) {
observed <- getY(BEVIforestcp@data)
expected <- fitted(BEVIforestcp)
resids <- residuals(BEVIforestcp)
sse <- sum(resids^2,na.rm=TRUE)
chisq <- sum((observed - expected)^2 / expected,na.rm=TRUE)
freeTuke <- sum((sqrt(observed) - sqrt(expected))^2,na.rm=TRUE)
out <- c(SSE=sse, Chisq=chisq, freemanTukey=freeTuke)
return(out)
}
(pb.mhb <- parboot(BEVIforestcp, fitstats1, nsim=25, report=1))
#plot parboot - the dashed line should be somewhere near the biggest bar.
plot(pb.mhb, main = "")
#extract coefficients for the best model
betaBEVI<-coef(BEVIforestcrpCP)
betaBEVI<-betaBEVI[c("lambda(Int)","lambda(forest)","lambda(crp)","lambda(cp)")]
## sample area, in ha:
point.area<- pi*50*50/10000
b <- read.csv("C:/Users/Bryan/Desktop/CREP dissertation/ch.2CREPPopulationestimate/N-mixture data/BEVI_csv/Landscape/FedCREP_updated2010abuffer700m_truncated.csv")
b$FOR_700[b$FOR_700<0]<-NA
b$CRP_1200[b$CRP_1200<0]<-NA
b <- na.omit(b)
# create new data frame for prediction
newdat <- data.frame(crp.orig=b[,"CRP_1200"],cp=b[,"CP"],forest.orig=b[,"FOR_700"],ha=b[,"ha"])
# scale to match the model
newdat$forest <- (newdat$forest.orig-attr(forest,"scaled:center"))/attr(forest,"scaled:scale")
newdat$crp <- (newdat$crp.orig-attr(crp,"scaled:center"))/attr(crp,"scaled:scale")
# predict density for newdat using top model
mod.pred <- predict(BEVIforestcrpCP,newdata=newdat,type="lambda")