This function is a wrapper for siteSelection
and reportingRateModel
that
allows users the run a well sampled sites analysis as in Roy et al (2012).
Usage
WSS(
taxa,
site,
time_period,
minL = 2,
minTP = 3,
species_to_include = unique(taxa),
overdispersion = FALSE,
family = "Binomial",
verbose = FALSE,
print_progress = FALSE
)
Arguments
- taxa
A character vector of taxon names, as long as the number of observations.
- site
A character vector of site names, as long as the number of observations.
- time_period
A numeric vector of user defined time periods, or a date vector, as long as the number of observations.
- minL
numeric, The minimum number of taxa recorded at a site at a given time period (list-length) for the visit to be considered well sampled.
- minTP
numeric, The minimum number of time periods, or if time_period is a date the minimum number of years, a site must be sampled in for it be be considered well sampled.
- species_to_include
A character vector giving the name of species to model. By default all species will be modelled
- overdispersion
This option allows modelling overdispersion (
TRUE
) in models. Default isFALSE
.- family
The type of model to be use. Can be
"Binomial"
or"Bernoulli"
.- verbose
This option, if
TRUE
, sets models to verbose, allowing the interations of each model to be viewed.- print_progress
Logical, if
TRUE
progress is printed to console when running models. Default isTRUE
Value
A dataframe of results are returned to R. Each row gives the results for a
single species, with the species name given in the first column, species_name
.
For each of the following columns the prefix (before ".") gives the covariate and the
sufix (after the ".") gives the parameter of that covariate.
number_observations
gives the number of visits where the species of interest
was observed. If any of the models encountered an error this will be given in the
column error_message
.
The data.frame has a number of attributes:
intercept_year
- The year used for the intercept (i.e. the year whose value is set to 0). Setting the intercept to the median year helps to increase model stabilitymin_year
andmax_year
- The earliest and latest year in the dataset (after years have been centered onintercept_year
nVisits
- The total number of visits that were in the datasetmodel_formula
- The model used, this will vary depending on the combination of arguements usedminL
- The setting of minL used in site selectionminTP
- The setting of minTP used in site selection
References
Roy, H.E., Adriaens, T., Isaac, N.J.B. et al. (2012) Invasive alien predator causes rapid declines of native European ladybirds. Diversity & Distributions, 18, 717-725.
Examples
# Create data
n <- 1500 #size of dataset
nyr <- 8 # number of years in data
nSamples <- 20 # set number of dates
# Create somes dates
first <- as.POSIXct(strptime("2003/01/01", "%Y/%m/%d"))
last <- as.POSIXct(strptime(paste(2003+(nyr-1),"/12/31", sep=''), "%Y/%m/%d"))
dt <- last-first
rDates <- first + (runif(nSamples)*dt)
# taxa are set as random letters
taxa <- sample(letters, size = n, TRUE)
# three sites are visited randomly
site <- sample(c('one', 'two', 'three'), size = n, TRUE)
# the date of visit is selected at random from those created earlier
time_period <- sample(rDates, size = n, TRUE)
# combine this to a dataframe
df <- data.frame(taxa, site, time_period)
results <- WSS(df$taxa,
df$site,
df$time_period,
minL = 4,
minTP = 3,
species_to_include = c('a', 'b', 'c'))
#> Warning: 537 out of 1500 observations will be removed as duplicates
#> boundary (singular) fit: see help('isSingular')
#> boundary (singular) fit: see help('isSingular')
# Look at the results for the first few species
head(results)
#> species_name intercept.estimate year.estimate intercept.stderror
#> 1 a 0.3943994 -0.02898427 0.2664725
#> 2 b 0.2753493 0.01740075 0.2641437
#> 3 c 0.7243898 0.23104897 0.4574995
#> year.stderror intercept.zvalue year.zvalue intercept.pvalue year.pvalue
#> 1 0.1057096 1.480075 -0.2741876 0.1388532 0.78394046
#> 2 0.1042904 1.042422 0.1668491 0.2972159 0.86748882
#> 3 0.1175658 1.583367 1.9652737 0.1133378 0.04938256
#> observations
#> 1 36
#> 2 34
#> 3 38
# Look at the attributes of the object returned
attributes(results)
#> $names
#> [1] "species_name" "intercept.estimate" "year.estimate"
#> [4] "intercept.stderror" "year.stderror" "intercept.zvalue"
#> [7] "year.zvalue" "intercept.pvalue" "year.pvalue"
#> [10] "observations"
#>
#> $class
#> [1] "data.frame"
#>
#> $row.names
#> [1] 1 2 3
#>
#> $intercept_year
#> [1] 2007
#>
#> $min_year
#> [1] -4
#>
#> $max_year
#> [1] 3
#>
#> $nVisits
#> [1] 60
#>
#> $model_formula
#> [1] "cbind(successes, failures) ~ year + (1|site)"
#>
#> $minL
#> [1] 4
#>
#> $minTP
#> [1] 3
#>