Aggregate bootstrapped distance data into count data
Source:R/create.bootcount.data.R
create.bootcount.data.Rd
This function creates a new data set where dis.data
is aggregated
for each visit to a segment. For bootstrapped data, the column with the ids
for visits to a segment is segment.id2
which is created
by create.bootstrap.data
using the default for argument rename
.
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.
All other columns from the observation layer should be discarded. This is achieved
by specifying the columns that should be retained using the argument column.numbers
.
Generally, all columns from the segment and higher levels should be kept.
If the default is used, column.numbers=NULL
, the columns distance
, object
,
size
, distbegin
and distend
from 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.
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 and that ids insegment.id2
are unique regardless of what resampled transect they belong to.- column.numbers
Optional argument: vector of integers indicating which columns other than
NHAT
fromdis.data
should be retained in the returned data.
Value
This function returns bootstrapped 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)
# bootstrap data without stratification
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
bootstrap.data<-create.bootstrap.data(dis.data.re)
#> Error in is_tibble(dis.data): could not find function "is_tibble"
bootcount.data<-create.bootcount.data(bootstrap.data)
#> Error in create.bootcount.data(bootstrap.data): object 'bootstrap.data' not found