Prepares a data.frame object for use with the ERF (not needed if using erf())
A data.frame with a new first column of var as a binary factor (duplicated if duplicate=TRUE), the header and covariates columns, and a random variable column
erf_data_prep(
df = NULL,
var = NULL,
covariates = NULL,
header = NULL,
weights = NULL,
duplicate = TRUE,
mode = "bin"
)
A data.frame object
A character string indicating the column name of the data frame that contains the number of interactions for the ERF to model; column should be a numeric column
A character vector indicating the column name(s) of the data frame that contain the covariates
A character vector indicating the column name(s) of the data frame that contain the additional columns you wish appended to the output
a vector equal in length to nrow(df) of weights, NULL by default
A logical flag that indicates whether to duplicate observations with more than one interaction. Default is TRUE to duplicate all records that interacted with more than one individual (i.e. a fishing set that caught two of the same species)
data <- erf_data_prep(df = simData$samples, var = 'obs', covariates = grep('cov', colnames(simData$samples), value=TRUE), header = c('prob.raw','prob'))
head(data)
#> obs prob.raw prob cov1 cov2 cov3 cov4
#> 1 0 -0.2525018 0.4372078 -0.07158000 -0.27811766 0.5741324 0.01366734
#> 2 0 2.7156166 0.9379419 -0.12028137 0.26103341 -0.2298234 0.14750795
#> 3 0 0.5609232 0.6366661 0.12422049 0.09052045 -0.3070963 0.14493653
#> 4 0 0.2723824 0.5676777 -0.12481261 -0.29583389 0.6282519 0.06067430
#> 5 0 3.0913999 0.9565366 0.01361460 -0.04989738 0.1600218 0.42189437
#> 6 0 -2.1467836 0.1046322 0.01842766 0.18300638 -0.3421439 -0.33128857
#> cov5 random
#> 1 -0.15537696 -0.3647314
#> 2 0.32482174 1.3904656
#> 3 0.02303010 -2.3638196
#> 4 -0.25240678 -0.2992857
#> 5 0.13166581 1.7098621
#> 6 0.07998399 -0.6688155