Learn R Programming

lefko3 (version 6.6.0)

bootstrap3: Bootstrap Standardized hfv_data Datasets

Description

Function bootstrap3() takes already standardized hfvdata datasets and bootstraps them by individual identity, or by row.

Usage

bootstrap3(
  data,
  by_pop = NULL,
  by_patch = NULL,
  by_indiv = NULL,
  prop_size = NULL,
  max_limit = NULL,
  reps = NULL,
  popcol = NULL,
  patchcol = NULL,
  indivcol = NULL
)

Value

A list of class hfvlist, which is composed of data frames of class hfvdata.

Arguments

data

A data frame of class hfvdata.

by_pop

A logical value indicating whether to sample the data frame by population. If TRUE, then the number of individuals sampled for each population will be set to the respective population's actual number of individuals; otherwise, population identity is ignored. Defaults to TRUE.

by_patch

A logical value indicating whether to sample the data frame by patch. If TRUE, then the number of individuals sampled for each patch will be set to the respective patch's actual number of individuals; otherwise, patch identity is ignored. Defaults to TRUE.

by_indiv

A logical value indicating whether to sample the data frame by individual identity, or by row. If TRUE, then samples by individual identity. Defaults to TRUE.

prop_size

A logical value indicating whether to keep the proportions of individuals (if by_indiv = TRUE) or of rows (if by_indiv = FALSE) in each bootstrapped dataset to the same proportions across populations (if by_pop = TRUE, and patches (if by_patch = TRUE, as in the original dataset. If FALSE, then allows the specific proportions to be set by argument max_limit. Defaults to TRUE.

max_limit

Sets the sample size to pull from the original data frame, if prop_size = FALSE. Defaults to the size of the original dataset if prop_size = TRUE, and to 100 if if prop_size = FALSE. Can also be input as an integer vector giving the number of samples to take by population (if by_pop = TRUE), patch (if by_patch = TRUE), or population-patch (if by_pop = TRUE and by_patch = TRUE).

reps

The number of bootstrap replicates to produce. Defaults to 100.

popcol

A string denoting the variable name coding for population identity in the data frame. Defaults to "popid".

patchcol

A string denoting the variable name coding for patch identity in the data frame. Defaults to "patchid".

indivcol

A string denoting the variable name coding for individual identity in the data frame. Defaults to "individ".

Examples

Run this code
data(lathyrus)

sizevector <- c(0, 100, 13, 127, 3730, 3800, 0)
stagevector <- c("Sd", "Sdl", "VSm", "Sm", "VLa", "Flo", "Dorm")
repvector <- c(0, 0, 0, 0, 0, 1, 0)
obsvector <- c(0, 1, 1, 1, 1, 1, 0)
matvector <- c(0, 0, 1, 1, 1, 1, 1)
immvector <- c(1, 1, 0, 0, 0, 0, 0)
propvector <- c(1, 0, 0, 0, 0, 0, 0)
indataset <- c(0, 1, 1, 1, 1, 1, 1)
binvec <- c(0, 100, 11, 103, 3500, 3800, 0.5)

lathframe <- sf_create(sizes = sizevector, stagenames = stagevector,
  repstatus = repvector, obsstatus = obsvector, matstatus = matvector,
  immstatus = immvector, indataset = indataset, binhalfwidth = binvec,
  propstatus = propvector)

lathvert <- verticalize3(lathyrus, noyears = 4, firstyear = 1988,
  patchidcol = "SUBPLOT", individcol = "GENET", blocksize = 9,
  juvcol = "Seedling1988", sizeacol = "Volume88", repstracol = "FCODE88",
  fecacol = "Intactseed88", deadacol = "Dead1988",
  nonobsacol = "Dormant1988", stageassign = lathframe, stagesize = "sizea",
  censorcol = "Missing1988", censorkeep = NA, censor = TRUE)

lathboot <- bootstrap3(lathvert, reps = 3)

lathsupp3 <- supplemental(stage3 = c("Sd", "Sd", "Sdl", "Sdl", "Sd", "Sdl"), 
  stage2 = c("Sd", "Sd", "Sd", "Sd", "rep", "rep"),
  stage1 = c("Sd", "rep", "Sd", "rep", "all", "all"), 
  givenrate = c(0.345, 0.345, 0.054, 0.054, NA, NA),
  multiplier = c(NA, NA, NA, NA, 0.345, 0.054),
  type = c(1, 1, 1, 1, 3, 3), type_t12 = c(1, 2, 1, 2, 1, 1),
  stageframe = lathframe, historical = TRUE)

ehrlen3_boot <- rlefko3(data = lathboot, stageframe = lathframe,
  year = c(1989, 1990), stages = c("stage3", "stage2", "stage1"),
  supplement = lathsupp3, yearcol = "year2", indivcol = "individ")

Run the code above in your browser using DataLab