Simulate a Mixed Fishery Sample from Known Stock Proportions
Source:R/simulate.R
simulate_mixture.Rd
Creates a synthetic fishery mixture by sampling individuals from different baseline stocks according to specified true proportions. Sampling from each stock is done with replacement.
Arguments
- baseline_data_list
A list of numeric matrices. Each matrix represents the baseline (standard) data for one stock/population, with observations as rows and variables as columns.
- actual_proportions
A numeric vector of true proportions for each stock in the mixture. Must sum to 1 and have the same length as
baseline_data_list
.- N_mixture_size
Integer, the total number of individuals to draw for the synthetic mixture.
Value
A numeric matrix representing the simulated mixture sample. Rows are individuals, and columns are variables. Returns an error if the mixture cannot be formed (e.g., due to empty baseline stocks needed for sampling).
Examples
# Dummy baseline data
stock1 <- matrix(rnorm(20 * 2, mean = 0, sd = 1), ncol = 2) # Assuming 2 variables
stock2 <- matrix(rnorm(30 * 2, mean = 2, sd = 1), ncol = 2) # Assuming 2 variables
baseline_list_ex <- list(stock1, stock2)
true_props_ex <- c(0.6, 0.4) # 60% from stock1, 40% from stock2
mixture_N_ex <- 100
# simulated_sample_ex <- simulate_mixture(baseline_list_ex, true_props_ex, mixture_N_ex)
# print(head(simulated_sample_ex))
# print(nrow(simulated_sample_ex)) # Should be close to 100