Skip to contents

Draws K values using multinomial sampling with probabilities P(K | length) for each length observed in a given survey.

Usage

simulate_sample_from_model(P_model_K_given_l, survey_obs)

Arguments

P_model_K_given_l

Matrix of predicted probabilities P(K | length).

survey_obs

A data frame for one survey with at least a Length column.

Value

An integer vector of simulated K values aligned with survey_obs rows.

Examples

set.seed(1)
P <- matrix(c(0.7, 0.3, 0.2, 0.8), nrow = 2, byrow = TRUE)
rownames(P) <- c("20", "30"); colnames(P) <- c("0", "1")
survey_obs <- data.frame(Length = c(20, 20, 30, 30, 30))
simulate_sample_from_model(P, survey_obs)
#> [1] 0 0 1 1 1