This function creates a new data set where dis.data is aggregated for
each visit to a segment (segment.id). The sum of the estimated number
of individuals for each segment from dis.data$NHAT is given in the
column NHAT in the new data.
Only columns from the segment or higher layers should be carried over into
count.data from dis.data. Use argument column.numbers to
identify these.
Arguments
- dis.data
Data frame containing distance data (one row for each detection). Expects a column
NHAT, i.e. size of detection divided by its probability of detection (seecreate.NHAT) and that ids insegment.idare unique regardless of what transect they belong to- column.numbers
Optional argument: vector of integers indicating which columns other than
NHATfromdis.datashould be retained in the returned data. Generally all columns from the segment and higher levels should be kept while those from the observation level should be discarded. If the default is used,column.numbers=NULL, the columnsdistance,object,size,distbeginanddistendfrom the observation level are automatically discarded. Note that for those columns from the observation layer that are kept, only the first recorded value will be transferred.
Value
This function returns count data that is suited for second stage count modelling of distance sampling
data. The data includes the columns NHAT and area which are the response and
the offset required by functions concerned with second stage modelling from this package.
Examples
data(dis.data.re)
dis.data.re$survey.id<-paste(dis.data.re$season,dis.data.re$impact,sep="")
result<-ddf(dsmodel=~mcds(key="hn", formula=~1), data=dis.data.re, method="ds",
meta.data=list(width=250))
#> Error in ddf(dsmodel = ~mcds(key = "hn", formula = ~1), data = dis.data.re, method = "ds", meta.data = list(width = 250)): could not find function "ddf"
dis.data.re<-create.NHAT(dis.data.re,result)
#> Error in which(data$distance <= ddf.obj$meta.data$width): object 'result' not found
count.data<-create.count.data(dis.data.re)
#> Error in `$<-.data.frame`(`*tmp*`, "NHAT", value = numeric(0)): replacement has 0 rows, data has 10951