DistanceDevelopment / distance-bugs

A place to keep bugs in Distance
http://distancesampling.org/Distance
1 stars 0 forks source link

results of Abundance, Density and Expected cluster size I get only zero values #152

Open luismmm opened 9 years ago

luismmm commented 9 years ago

I’m new to R and Distance sampling. I’m not sure if this is the right place to ask my question, it seemed to me that the Distance help forum is not active anymore. Maybe someone can point me to the right help forum?

When I am trying to run an MCDS in R in the package distance. I manage to get the detection function. But for the results of Abundance, Density and Expected cluster size I get only zero values. I am working with R-Studio (R 3.0.1). I have tried to change cutpoints (bins), the truncation distance, the key function (hazard rate, half normal, and the uniform with adjustments terms cosine). I also tested if all Sample Labels are correct, which they are. I have over 500 sightings, but they are somewhat clustered at some distances. So it seems that the dht part of the model does not converge. I presume that the mistake must be either related to the clustered distances, or some parts of the samples or region dataframe. Does anyone have tips which mistakes to check for?

Best wishes Luis

read in data

setwd("C:/Users/Luis/Scheinwerferzaehlung/Gis_Exel_csv _Taxation")

Rehwild

seg<-read.csv("Alle_TransekteNeu.csv",h=T,dec=",",sep=";") str(seg) summary(seg)

data<-read.csv("Verschobene_Alle(_Sichtungen_Alle10Transekte.csv",header=T,dec=",",sep=";")

Prediction grid

preddata<-read.csv("Fishnetfinal.csv",header=T,dec=",",sep=";")

preddata$width<-((max(preddata$x)-min(preddata$x))/36)

preddata$height<-((max(preddata$y)-min(preddata$y))/50)

preddata$area<-284123572

str(preddata)

region<-data[,c("Region.Label","Area")] str(region) region<-region[ !duplicated(region$Region.Label), ]

samples<-seg[,c("Region.Label","Effort","Sample.Label")]

samples<-samples[ !duplicated(samples$Sample.Label), ]

reh<-reh[ !duplicated(reh$object), ]

str(samples) summary(samples)

obs<-data[,c("Region.Label","Sample.Label","distance","size","object","centerx","centery", "Habitat","KLASSE_06","Laub_Nadel","Mischungsm","Jahr")] max(obs$distance,na.rm=TRUE) str(obs) summary(obs)

hist(obs$distance) histogram(~obs$distance|obs$Habitat) plot(obs$size~obs$distance) abline(lm(obs$size~obs$distance))

obs<-subset(obs,size<10)

trunc<-400 cutpoint<-c(0,50,90,140,200,400)

cutpoint<-c(0,80,120,170,210,250,300)

hr.Wald1<-ds(obs,trunc,sample.table = samples, region.table=region, key="hr",adjustment=NULL,obs.table=obs,formula=~1, cutpoints=cutpoint) hn.Wald1<-ds(obs,trunc,sample.table = samples, region.table=region, key="hn",adjustment=NULL,obs.table=obs,formula=~1, cutpoints=cutpoint) hr.Wald2<-ds(obs,trunc,sample.table = samples, region.table=region, key="hr",adjustment=NULL,obs.table=obs,formula=~size, cutpoints=cutpoint) hn.Wald2<-ds(obs,trunc,sample.table = samples, region.table=region, key="hn",adjustment=NULL,obs.table=obs,formula=~size, cutpoints=cutpoint) hr.Wald3<-ds(obs,trunc,sample.table = samples, region.table=region, key="hr",adjustment=NULL,obs.table=obs,formula=~Habitat, cutpoints=cutpoint) hn.Wald3<-ds(obs,trunc,sample.table = samples, region.table=region, key="hn",adjustment=NULL,obs.table=obs,formula=~Habitat, cutpoints=cutpoint) hr.Wald4<-ds(obs,trunc,sample.table = samples, region.table=region, key="hr",adjustment=NULL,obs.table=obs,formula=~size+Habitat)

hn.Wald4<-ds(obs,trunc,sample.table = samples, region.table=region, key="hn",adjustment=NULL,obs.table=obs,formula=~size+Habitat, cutpoints=cutpoint)

summary(hr.Wald1)$ds$aic summary(hr.Wald2)$ds$aic summary(hr.Wald3)$ds$aic summary(hr.Wald4)$ds$aic summary(hn.Wald1)$ds$aic summary(hn.Wald2)$ds$aic summary(hn.Wald3)$ds$aic summary(hn.Wald4)$ds$aic model<-hr.Wald3

summary(model) par(mfrow=c(1,1)) plot(model) esws<-as.numeric(unlist(predict(model$ddf,esw=T))) obs1<-subset(obs,obs$distance<301)

dsm.m<-dsm(Nhat~s(x,y)+Wald+s(aspect,bs="cc")+s(SFEUCH_Y,k=5),hr.Wald4,seg,obs,engine="gam", family=Tweedie(1.5)) summary(dsm.m)

plot(dsm.m,page=1,shade=TRUE) gam.check(dsm.m)

off.set<-preddata$width*preddata$height resp<-predict(dsm.m, preddata, off.set) pp<-cbind(preddata,resp) p<-ggplot(pp)+gg.opts p <- p + scale_fill_gradient(low="yellow", high="darkgreen") p <- p + geom_tile(aes(x = x, y = y, fill=resp), width = preddata$width, height = preddata$height) p <- p + coord_equal() p <- p + labs(fill = "Abundance") p <- p + geom_point(aes(x = x, y = y,size=size), data=obs,colour="red",alpha=I(0.7))

Summary for distance analysis Number of observations : 530 Distance range : 0 - 300

Model : Hazard-rate key function AIC : 1091.698

Detection function parameters Scale Coefficients:
estimate se (Intercept) 4.909131 0.07847082

Shape parameters:
estimate se (Intercept) 1.390525 0.2185818

                   Estimate          SE         CV

Average p 0.5394389 0.02363619 0.04381625 N in covered region 982.5024503 51.88549633 0.05280953

Summary for clusters

Summary statistics: Region Area CoveredArea Effort n k ER se.ER cv.ER 1 Hunsrueck 397095500 238745530 397909.2 0 217 0 0 0

Abundance: Label Estimate se cv lcl ucl df 1 Total 0 0 0 0 0 216

Density: Label Estimate se cv lcl ucl df 1 Total 0 0 0 0 0 216

Summary for individuals

Summary statistics: Region Area CoveredArea Effort n ER se.ER cv.ER mean.size se.mean 1 Hunsrueck 397095500 238745530 397909.2 0 0 0 0 0 0

Abundance: Label Estimate se cv lcl ucl df 1 Total 0 0 0 0 0 216

Density: Label Estimate se cv lcl ucl df 1 Total 0 0 0 0 0 216

Expected cluster size Region Expected.S se.Expected.S cv.Expected.S 1 Total 0 0 0 2 Total 0 0 0

obs$distance<-jitter(obs$distance,10) max(obs$distance,na.rm=TRUE) [1] 397.3283 obs$distance<-jitter(obs$distance,50) max(obs$distance,na.rm=TRUE) [1] 398.0229 hr.Wald1<-ds(obs,trunc,sample.table = samples, region.table=region,

  • key="hr",adjustment=NULL,obs.table=obs,formula=~1,
  • cutpoints=cutpoint) Fitting hazard-rate key function AIC= 1089.905

\ Warning: Some observations not included in the analysis**

summary(hr.Wald1)

Summary for distance analysis Number of observations : 530 Distance range : 0 - 300

Model : Hazard-rate key function AIC : 1089.905

Detection function parameters Scale Coefficients:
estimate se (Intercept) 4.893945 0.07637602

Shape parameters:
estimate se (Intercept) 1.351946 0.2015361

                   Estimate          SE         CV

Average p 0.5353601 0.02331952 0.04355856 N in covered region 989.9878592 52.14170594 0.05266904

Summary for clusters

Summary statistics: Region Area CoveredArea Effort n k ER se.ER cv.ER 1 Hunsrueck 397095500 238745530 397909.2 0 217 0 0 0

Abundance: Label Estimate se cv lcl ucl df 1 Total 0 0 0 0 0 216

Density: Label Estimate se cv lcl ucl df 1 Total 0 0 0 0 0 216

Summary for individuals

Summary statistics: Region Area CoveredArea Effort n ER se.ER cv.ER mean.size se.mean 1 Hunsrueck 397095500 238745530 397909.2 0 0 0 0 0 0

Abundance: Label Estimate se cv lcl ucl df 1 Total 0 0 0 0 0 216

Density: Label Estimate se cv lcl ucl df 1 Total 0 0 0 0 0 216

Expected cluster size Region Expected.S se.Expected.S cv.Expected.S 1 Total 0 0 0 2 Total 0 0 0

erex commented 9 years ago

Luis

We do have an active Distance sampling list for asking questions such as this. A description of that list and how to subscribe is found on one of the pages of our distance sampling website.

http://distancesampling.org/distancelist.html

Github does not provide us with your email address, so we cannot respond to you directly. However if you subscribe to the Google list, we can carry on a dialog about your problem that will be sharable by all the distance list subscribers.

Given you are trying to use density-surface modelling (from your calls to dsm()), rather than design-based methods to produce your abundance estimates; I don't think you need to be providing information regarding the Region table and sample table. Those constructs are for use with design-based analyses.

Are you following the vignettes we have provided near the bottom of http://distancesampling.org/R/index.html that provide example analyses?

You should also read through Miller et al. (2013) linked at this wiki page https://github.com/DistanceDevelopment/dsm/wiki