auxposbernoulli.t.RdReturns behavioural effects indicator variables from a capture history matrix.
aux.posbernoulli.t(y, check.y = FALSE, rename = TRUE, name = "bei")Capture history matrix. Rows are animals, columns are sampling occasions, and values should be 0s and 1s only.
Logical, if TRUE then some basic checking is performed.
If rename = TRUE then the behavioural effects indicator
are named using the value of name as the prefix.
If FALSE then use the same column names as y.
This function can help fit certain capture–recapture models
(commonly known as \(M_{tb}\) or \(M_{tbh}\)
(no prefix \(h\) means it is an intercept-only model)
in the literature).
See posbernoulli.t for details.
A list with the following components.
A matrix the same dimension as y.
In any particular row there are 0s up to
the first capture. Then there are 1s thereafter.
A vector specifying which time occasion the animal was first captured.
Number of noncaptures before the first capture.
Number of noncaptures after the first capture.
Number of recaptures after the first capture.
# Fit a M_tbh model to the deermice data:
(pdata <- aux.posbernoulli.t(with(deermice,
cbind(y1, y2, y3, y4, y5, y6))))
#> $cap.hist1
#> bei1 bei2 bei3 bei4 bei5 bei6
#> [1,] 0 1 1 1 1 1
#> [2,] 0 1 1 1 1 1
#> [3,] 0 1 1 1 1 1
#> [4,] 0 1 1 1 1 1
#> [5,] 0 1 1 1 1 1
#> [6,] 0 1 1 1 1 1
#> [7,] 0 1 1 1 1 1
#> [8,] 0 1 1 1 1 1
#> [9,] 0 1 1 1 1 1
#> [10,] 0 1 1 1 1 1
#> [11,] 0 1 1 1 1 1
#> [12,] 0 1 1 1 1 1
#> [13,] 0 1 1 1 1 1
#> [14,] 0 1 1 1 1 1
#> [15,] 0 1 1 1 1 1
#> [16,] 0 0 1 1 1 1
#> [17,] 0 0 1 1 1 1
#> [18,] 0 0 1 1 1 1
#> [19,] 0 0 1 1 1 1
#> [20,] 0 0 1 1 1 1
#> [21,] 0 0 1 1 1 1
#> [22,] 0 0 1 1 1 1
#> [23,] 0 0 1 1 1 1
#> [24,] 0 0 0 1 1 1
#> [25,] 0 0 0 1 1 1
#> [26,] 0 0 0 1 1 1
#> [27,] 0 0 0 1 1 1
#> [28,] 0 0 0 1 1 1
#> [29,] 0 0 0 1 1 1
#> [30,] 0 0 0 0 1 1
#> [31,] 0 0 0 0 1 1
#> [32,] 0 0 0 0 1 1
#> [33,] 0 0 0 0 0 1
#> [34,] 0 0 0 0 0 1
#> [35,] 0 0 0 0 0 1
#> [36,] 0 0 0 0 0 0
#> [37,] 0 0 0 0 0 0
#> [38,] 0 0 0 0 0 0
#>
#> $cap1
#> [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 5 5 5 6 6 6
#>
#> $y0i
#> [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 4 4 4 5 5 5
#>
#> $yr0i
#> [1] 0 2 2 1 0 1 1 2 0 1 1 1 0 2 4 3 2 3 2 2 2 3 2 3 0 1 0 2 3 2 0 1 1 1 1 0 0 0
#>
#> $yr1i
#> [1] 5 3 3 4 5 4 4 3 5 4 4 4 5 3 1 1 2 1 2 2 2 1 2 0 3 2 3 1 0 0 2 1 0 0 0 0 0 0
#>
deermice <- data.frame(deermice,
bei = 0, # Add this
pdata$cap.hist1) # Incorporate these
head(deermice) # Augmented with behavioural effect indicator variables
#> y1 y2 y3 y4 y5 y6 sex age weight bei bei1 bei2 bei3 bei4 bei5 bei6
#> 1 1 1 1 1 1 1 0 y 12 0 0 1 1 1 1 1
#> 2 1 0 0 1 1 1 1 y 15 0 0 1 1 1 1 1
#> 3 1 1 0 0 1 1 0 y 15 0 0 1 1 1 1 1
#> 4 1 1 0 1 1 1 0 y 15 0 0 1 1 1 1 1
#> 5 1 1 1 1 1 1 0 y 13 0 0 1 1 1 1 1
#> 6 1 1 0 1 1 1 0 a 21 0 0 1 1 1 1 1
tail(deermice)
#> y1 y2 y3 y4 y5 y6 sex age weight bei bei1 bei2 bei3 bei4 bei5 bei6
#> 33 0 0 0 0 1 0 0 y 14 0 0 0 0 0 0 1
#> 34 0 0 0 0 1 0 1 y 11 0 0 0 0 0 0 1
#> 35 0 0 0 0 1 0 0 a 24 0 0 0 0 0 0 1
#> 36 0 0 0 0 0 1 0 y 9 0 0 0 0 0 0 0
#> 37 0 0 0 0 0 1 0 a 16 0 0 0 0 0 0 0
#> 38 0 0 0 0 0 1 1 a 19 0 0 0 0 0 0 0