Skip to contents

bs

Description

The function bs generates a matrix that resamples length with replacement. The original data set is stored in the first row, while the resamples are stored in the \(i_{th}\) row \(B_{i}+1\), where \(B\) is the total number of resamples.

It returns a matrix mb that includes both the original data set and the \(i_{th}\) generated resamples.

The seed value is a pseudorandom number, it is an integer value defined by the user. The same results will be returned each time the same number is used, for example: seed <- 100; if seed <- NULL, different results will be returned each time. For more information, see the set.seed() documentation from the simEd package.

The function requires defining:

  • df: A data frame array.
  • B: An integer value, specify the number of resamples.
  • n: An integer value indicating the number of observations.
  • semilla: An integer value is a seed to initialize a pseudorandom number.

Seealso: set.seed from the package simEd (2.0.1)

bs

The function is included in the Repbio package Reproductive biology analysis.

#library(Repbio)

The function is detailed below.

bs <- function(df,B,n,semilla) {
  set.seed(semilla)
    mb <- matrix(sample(df, size = B * n,
                      replace = TRUE), B, n)
    mb <- rbind(df,mb)  # The resampling data is added with the original data
}     # End function bs

Examples

Falta detallar el ejemplo

#       df = tmp
#       B <- 2000
#       n <- 3000
#       semilla <- 100
# # Reproducing the same output every time
#       ejemplo <- bs(df,B,n,semilla)
# 
# # Reproducing the different output every time
#       semilla <- NULL
#       ejemplo <- bs(df,B,n,semilla)

References

Salas‐Singh, C., Morales‐Bojórquez, E., & Aguirre‐Villaseñor, H. (2022). Reproductive biology of the bullseye puffer Sphoeroides annulatus: Gonadosomatic index and its suitability for estimating length at maturity. Journal of Fish Biology, 101(5), 1119-1133.https://doi.org/10.1111/jfb.15174