Generates an artificial sample of morphometric data with specified characteristics. Recommended to use set.seed() before running to ensure reproducibility.
Usage
fake_crustaceans(
L50 = 100,
slope = 5,
n = 1000,
x_mean = 105,
x_sd = 20,
allo_params = c(1.2, 0.1, 1.2, 0.1),
error_scale = 20
)
Arguments
- L50
Integer or double; the desired true length at 50% maturity on the scale of the x-axis/reference variable. Defaults to 100 mm.
- slope
Integer or double; the desired slope parameter for the logistic equation describing the probability of maturity at a given value of the x-axis/reference variable. Default is 5.
- n
Sample size of the simulated data set. Default is 1000 individuals.
- x_mean
Mean of the reference variable (e.g., carapace width). Default is 105 mm.
- x_sd
Standard deviation of the reference variable (e.g., carapace width). Default is 20 mm.
- allo_params
A numeric vector of length 4 containing the parameters controlling how the allometric relationship between the x and y variables changes at maturity. Should contain the immature slope parameter, immature intercept parameter, mature slope parameter, and mature intercept parameter, in that order.
- error_scale
Scaling for the error added to the simulated data
Value
A data frame with n rows. Columns are: (1) the x variable on the original scale, (2) the probability of maturity for the individual, (3) the assigned maturity status, 1 or 0, (4) the y variable on the original scale, (5) the log-transformed x variable, and (6) the log-transformed y variable
Examples
set.seed(123)
fake_crustaceans(n=25)
#> x prob_mat mature y log_x log_y
#> 1 93.79049 0.224104987 0 22.59484 4.541063 3.117722
#> 2 100.39645 0.519812132 1 25.51133 4.609127 3.239123
#> 3 136.17417 0.999279492 1 34.75503 4.913935 3.548324
#> 4 106.41017 0.782795735 1 27.50829 4.667301 3.314487
#> 5 107.58575 0.820118559 1 28.25854 4.678288 3.341396
#> 6 139.30130 0.999614375 1 37.15985 4.936639 3.615229
#> 7 114.21832 0.944990284 1 30.87054 4.738112 3.429802
#> 8 79.69878 0.016952453 0 18.47184 4.378254 2.916248
#> 9 91.26294 0.148373993 1 22.84396 4.513745 3.128687
#> 10 96.08676 0.313749488 0 24.30950 4.565252 3.190867
#> 11 129.48164 0.997258014 1 33.12834 4.863539 3.500389
#> 12 112.19628 0.919772153 1 27.44566 4.720250 3.312208
#> 13 113.01543 0.931059913 1 29.12296 4.727524 3.371527
#> 14 107.21365 0.808877185 1 26.86927 4.674824 3.290983
#> 15 93.88318 0.227344896 1 24.81147 4.542051 3.211306
#> 16 140.73826 0.999710670 1 39.63867 4.946902 3.679805
#> 17 114.95701 0.952184179 1 30.00144 4.744558 3.401245
#> 18 65.66766 0.001041066 0 14.57881 4.184607 2.679569
#> 19 119.02712 0.978234507 1 30.35877 4.779351 3.413086
#> 20 95.54417 0.290869341 0 25.27583 4.559589 3.229849
#> 21 83.64353 0.036569182 0 19.47490 4.426564 2.969126
#> 22 100.64050 0.531981364 0 26.96557 4.611555 3.294561
#> 23 84.47991 0.042941829 0 20.33126 4.436514 3.012160
#> 24 90.42218 0.128356952 0 21.87246 4.504490 3.085228
#> 25 92.49921 0.182402098 0 22.22107 4.527200 3.101041