Title: | Generic Functions to Analyse Data from the 'Natura 2000' Monitoring |
---|---|
Description: | All generic functions and classes for the analysis for the 'Natura 2000' monitoring. The classes contain all required data and definitions to fit the model without the need to access other sources. Potentially they might need access to one or more parent objects. An aggregation object might for example need the result of an imputation object. The actual definition of the analysis, using these generic function and classes, is defined in dedictated analysis R packages for every monitoring scheme. For example 'abvanalysis' and 'watervogelanalysis'. |
Authors: | Thierry Onkelinx [aut, cre] (<https://orcid.org/0000-0001-8804-4216>, Research Institute for Nature and Forest (INBO)), Research Institute for Nature and Forest (INBO) [cph, fnd] |
Maintainer: | Thierry Onkelinx <[email protected]> |
License: | GPL-3 |
Version: | 0.3.2 |
Built: | 2024-11-08 05:00:16 UTC |
Source: | https://github.com/inbo/n2kanalysis |
Combine multiple n2k objects
combine(...) ## S4 method for signature 'n2kAnalysisVersion' combine(...) ## S4 method for signature 'n2kParameter' combine(...) ## S4 method for signature 'n2kAnomaly' combine(...) ## S4 method for signature 'n2kResult' combine(...)
combine(...) ## S4 method for signature 'n2kAnalysisVersion' combine(...) ## S4 method for signature 'n2kParameter' combine(...) ## S4 method for signature 'n2kAnomaly' combine(...) ## S4 method for signature 'n2kResult' combine(...)
... |
n2k objects |
n2kModel
objectDelete an n2kModel
object
delete_model(x, base, project) ## S4 method for signature 'ANY,character' delete_model(x, base, project) ## S4 method for signature 'ANY,s3_bucket' delete_model(x, base, project)
delete_model(x, base, project) ## S4 method for signature 'ANY,character' delete_model(x, base, project) ## S4 method for signature 'ANY,s3_bucket' delete_model(x, base, project)
x |
the file fingerprint of the |
base |
the base location |
project |
will be a relative path within the base location |
This is a short cut for if(verbose) message(x)
.
display(verbose, message, linefeed = TRUE)
display(verbose, message, linefeed = TRUE)
verbose |
A logical.
When |
message |
a vector passed to |
linefeed |
A logical.
When |
Extract the relevant coefficients
extract(extractor, object, base, project) ## S4 method for signature 'ANY,character' extract(extractor, object, base, project) ## S4 method for signature 'ANY,n2kInla' extract(extractor, object, base = NULL, project = NULL)
extract(extractor, object, base, project) ## S4 method for signature 'ANY,character' extract(extractor, object, base, project) ## S4 method for signature 'ANY,n2kInla' extract(extractor, object, base = NULL, project = NULL)
extractor |
the extractor function |
object |
the |
base |
the optional base location of the object |
project |
the optional subdirectory |
the relevant coefficients
Fit the model to the analysis files
fit_every_model(path, status, verbose = TRUE, n_cluster = 1, ...)
fit_every_model(path, status, verbose = TRUE, n_cluster = 1, ...)
path |
The path containing the analysis files. |
status |
A vector with status levels to (re-)fit the model.
Defaults to |
verbose |
Show the name of the current analysis file on screen.
Defaults to |
n_cluster |
The number of clusters to use. |
... |
Arguments passed to |
n2kModel
objectFit an n2kModel
object
fit_model(x, ...) ## S4 method for signature 'character' fit_model( x, base, project, status = c("new", "waiting"), verbose = TRUE, ..., bucket ) ## S4 method for signature 'n2kAggregate' fit_model(x, ...) ## S4 method for signature 'n2kComposite' fit_model(x, base, project, status = "new", ...) ## S4 method for signature 'n2kHurdleImputed' fit_model(x, base, project, status = c("new", "waiting"), ...) ## S4 method for signature 'n2kInla' fit_model( x, status = "new", ..., timeout = NULL, seed = get_seed(x), num_threads = NULL, parallel_configs = TRUE ) ## S4 method for signature 'n2kInlaComparison' fit_model(x, base, project, status = "new", verbose = TRUE, ...) ## S4 method for signature 'n2kManifest' fit_model( x, base, project, status = c("new", "waiting"), verbose = TRUE, ..., local = tempfile("fit_model"), first = FALSE ) ## S4 method for signature 'n2kModelImputed' fit_model(x, ...) ## S4 method for signature 's3_object' fit_model(x, status = c("new", "waiting"), ...)
fit_model(x, ...) ## S4 method for signature 'character' fit_model( x, base, project, status = c("new", "waiting"), verbose = TRUE, ..., bucket ) ## S4 method for signature 'n2kAggregate' fit_model(x, ...) ## S4 method for signature 'n2kComposite' fit_model(x, base, project, status = "new", ...) ## S4 method for signature 'n2kHurdleImputed' fit_model(x, base, project, status = c("new", "waiting"), ...) ## S4 method for signature 'n2kInla' fit_model( x, status = "new", ..., timeout = NULL, seed = get_seed(x), num_threads = NULL, parallel_configs = TRUE ) ## S4 method for signature 'n2kInlaComparison' fit_model(x, base, project, status = "new", verbose = TRUE, ...) ## S4 method for signature 'n2kManifest' fit_model( x, base, project, status = c("new", "waiting"), verbose = TRUE, ..., local = tempfile("fit_model"), first = FALSE ) ## S4 method for signature 'n2kModelImputed' fit_model(x, ...) ## S4 method for signature 's3_object' fit_model(x, status = c("new", "waiting"), ...)
x |
the |
... |
other arguments. See details |
base |
The root of a project. Can be either a directory on a file system
or an AWS S3 bucket object.
Extracted from |
project |
The subdirectory of the project. Is relative the |
status |
A vector with status levels naming the levels which should be
calculated.
Defaults to |
verbose |
A logical indicating if the function should display the name
of the file and the status.
Defaults to |
bucket |
The name of the AWS S3 bucket.
Only used when |
timeout |
the optional number of second until the model will time out |
seed |
See the same argument in |
num_threads |
The number of threads to use in the format |
parallel_configs |
Logical.
If TRUE and not on Windows, then try to run each configuration in parallel
(not Windows) using |
local |
A local folder into which objects from an AWS S3 bucket are downloaded. |
first |
A logical.
|
status
: A vector with status levels naming the levels which should be
recalculated.
Defaults to c("new", "waiting")
.
verbose
: A logical indicating if the function should display the name of
the file and the status.
Defaults to TRUE
.
n2kModel
objectGet the analysis date of an n2kModel
object
get_analysis_date(x) ## S4 method for signature 'n2kAnalysisMetadata' get_analysis_date(x)
get_analysis_date(x) ## S4 method for signature 'n2kAnalysisMetadata' get_analysis_date(x)
x |
the |
the analysis date of the object
Get an analysis version
get_analysis_version(version) ## S4 method for signature 'data.frame' get_analysis_version(version) ## S4 method for signature 'n2kAnalysisMetadata' get_analysis_version(version) ## S4 method for signature 'sessionInfo' get_analysis_version(version)
get_analysis_version(version) ## S4 method for signature 'data.frame' get_analysis_version(version) ## S4 method for signature 'n2kAnalysisMetadata' get_analysis_version(version) ## S4 method for signature 'sessionInfo' get_analysis_version(version)
version |
the object to extract the version |
Get the anomalies from a model
get_anomaly(analysis, ...) ## S4 method for signature 'n2kInla' get_anomaly( analysis, n = 20, expected_ratio = 5, expected_absent = 5, random_threshold = 1.05, verbose = TRUE, ... ) ## S4 method for signature 'n2kModel' get_anomaly(analysis, verbose = TRUE, ...)
get_anomaly(analysis, ...) ## S4 method for signature 'n2kInla' get_anomaly( analysis, n = 20, expected_ratio = 5, expected_absent = 5, random_threshold = 1.05, verbose = TRUE, ... ) ## S4 method for signature 'n2kModel' get_anomaly(analysis, verbose = TRUE, ...)
analysis |
The model to add |
... |
Extra options. See details. |
n |
the number of anomalies per category. |
expected_ratio |
Observations that have
|
expected_absent |
Zero observations where |
random_threshold |
The minimal relative effect size of a random effect. Random effect with a smaller effect size will never be an anomaly. Defaults to 1.05 (5%). |
verbose |
Print extra information on the screen |
n2kModel
objectGet the data of an n2kModel
object
get_data(x) ## S4 method for signature 'n2kInla' get_data(x)
get_data(x) ## S4 method for signature 'n2kInla' get_data(x)
x |
the |
the data of the object
n2kModel
objectGet the file fingerprint of an n2kModel
object
get_file_fingerprint(x) ## S4 method for signature 'n2kAnalysisMetadata' get_file_fingerprint(x) ## S4 method for signature 'n2kManifest' get_file_fingerprint(x)
get_file_fingerprint(x) ## S4 method for signature 'n2kAnalysisMetadata' get_file_fingerprint(x) ## S4 method for signature 'n2kManifest' get_file_fingerprint(x)
x |
the |
the file fingerprint of the object
n2kModel
objectGet the formula of an n2kModel
object
get_formula(x) ## S4 method for signature 'n2kAnalysisMetadata' get_formula(x)
get_formula(x) ## S4 method for signature 'n2kAnalysisMetadata' get_formula(x)
x |
the |
the formula of the object
n2kModel
objectGet the location group id of an n2kModel
object
get_location_group_id(x) ## S4 method for signature 'n2kAnalysisMetadata' get_location_group_id(x)
get_location_group_id(x) ## S4 method for signature 'n2kAnalysisMetadata' get_location_group_id(x)
x |
the |
the location group id of the object
n2kModel
objectGet the model of a n2kModel
object
get_model(x) ## S4 method for signature 'n2kInla' get_model(x) ## S4 method for signature 'character' get_model(x)
get_model(x) ## S4 method for signature 'n2kInla' get_model(x) ## S4 method for signature 'character' get_model(x)
x |
the |
the model of the object
Add the model parameters from a model
get_model_parameter(analysis, ...) ## S4 method for signature 'n2kAggregate' get_model_parameter(analysis, ...) ## S4 method for signature 'n2kComposite' get_model_parameter(analysis, ...) ## S4 method for signature 'n2kHurdleImputed' get_model_parameter(analysis, ...) ## S4 method for signature 'n2kInla' get_model_parameter(analysis, verbose = TRUE, ...) ## S4 method for signature 'n2kInlaComparison' get_model_parameter(analysis, ...) ## S4 method for signature 'n2kModelImputed' get_model_parameter(analysis, ...)
get_model_parameter(analysis, ...) ## S4 method for signature 'n2kAggregate' get_model_parameter(analysis, ...) ## S4 method for signature 'n2kComposite' get_model_parameter(analysis, ...) ## S4 method for signature 'n2kHurdleImputed' get_model_parameter(analysis, ...) ## S4 method for signature 'n2kInla' get_model_parameter(analysis, verbose = TRUE, ...) ## S4 method for signature 'n2kInlaComparison' get_model_parameter(analysis, ...) ## S4 method for signature 'n2kModelImputed' get_model_parameter(analysis, ...)
analysis |
The model to add. |
... |
extra options |
verbose |
Print extra information on the screen |
n2kModel
objectGet the model type of an n2kModel
object
get_model_type(x) ## S4 method for signature 'n2kAnalysisMetadata' get_model_type(x)
get_model_type(x) ## S4 method for signature 'n2kAnalysisMetadata' get_model_type(x)
x |
the |
the model type of the object
n2kModel
objectGet the object of the parent analyses of an n2kModel
object
get_parents(child, base, project)
get_parents(child, base, project)
child |
the child object |
base |
the base location to read the model |
project |
will be a relative path within the base location |
Add the results from an analysis
get_result(x, ...) ## S4 method for signature 'character' get_result(x, n_cluster = 1, verbose = TRUE, ...) ## S4 method for signature 'n2kInla' get_result(x, verbose = TRUE, ...) ## S4 method for signature 'n2kModel' get_result(x, verbose = TRUE, ...) ## S4 method for signature 'n2kManifest' get_result(x, ..., base, project, verbose = TRUE) ## S4 method for signature 's3_object' get_result(x, ...)
get_result(x, ...) ## S4 method for signature 'character' get_result(x, n_cluster = 1, verbose = TRUE, ...) ## S4 method for signature 'n2kInla' get_result(x, verbose = TRUE, ...) ## S4 method for signature 'n2kModel' get_result(x, verbose = TRUE, ...) ## S4 method for signature 'n2kManifest' get_result(x, ..., base, project, verbose = TRUE) ## S4 method for signature 's3_object' get_result(x, ...)
x |
object with the current results |
... |
further arguments (see Details) |
n_cluster |
The number of clusters to run this function in parallel.
Defaults to |
verbose |
Print extra information on the screen |
base |
the base location to read the model |
project |
will be a relative path within the base location |
scheme_id
of an n2kModel
objectGet the scheme_id
of an n2kModel
object
get_scheme_id(x) ## S4 method for signature 'n2kAnalysisMetadata' get_scheme_id(x)
get_scheme_id(x) ## S4 method for signature 'n2kAnalysisMetadata' get_scheme_id(x)
x |
the |
the scheme_id
of the object
n2kModel
objectGet the seed of an n2kModel
object
get_seed(x) ## S4 method for signature 'n2kAnalysisMetadata' get_seed(x)
get_seed(x) ## S4 method for signature 'n2kAnalysisMetadata' get_seed(x)
x |
the |
the seed of the object
n2kModel
objectGet the species group id of an n2kModel
object
get_species_group_id(x) ## S4 method for signature 'n2kAnalysisMetadata' get_species_group_id(x)
get_species_group_id(x) ## S4 method for signature 'n2kAnalysisMetadata' get_species_group_id(x)
x |
the |
the species group id of the object
n2kModel
objectGet the status fingerprint of an n2kModel
object
get_status_fingerprint(x) ## S4 method for signature 'n2kAnalysisMetadata' get_status_fingerprint(x)
get_status_fingerprint(x) ## S4 method for signature 'n2kAnalysisMetadata' get_status_fingerprint(x)
x |
the |
the status fingerprint of the object
This is useful for calculating the variance of a random effect when the marginal gives the precision of the random effect.
inla_inverse(marginal)
inla_inverse(marginal)
marginal |
The INLA marginal |
Convert a manifest yaml file into a bash script
manifest_yaml_to_bash( base, project, hash, shutdown = FALSE, split = 1, status = c("new", "waiting"), limit = FALSE, timeout = 4 ) ## S4 method for signature 's3_bucket' manifest_yaml_to_bash( base, project, hash, shutdown = FALSE, split = 1, status = c("new", "waiting"), limit = FALSE, timeout = 4 ) ## S4 method for signature 'character' manifest_yaml_to_bash( base, project, hash, shutdown = FALSE, split = 1, status = c("new", "waiting"), limit = FALSE )
manifest_yaml_to_bash( base, project, hash, shutdown = FALSE, split = 1, status = c("new", "waiting"), limit = FALSE, timeout = 4 ) ## S4 method for signature 's3_bucket' manifest_yaml_to_bash( base, project, hash, shutdown = FALSE, split = 1, status = c("new", "waiting"), limit = FALSE, timeout = 4 ) ## S4 method for signature 'character' manifest_yaml_to_bash( base, project, hash, shutdown = FALSE, split = 1, status = c("new", "waiting"), limit = FALSE )
base |
the base location to store the manifest |
project |
will be a relative path within the base location |
hash |
Fingerprint of the manifest |
shutdown |
Append a shutdown command at the end of the script.
Defaults to |
split |
Number of scripts over which to splits the analyses. Default to 1. |
status |
A vector with status levels naming the levels which should be
calculated.
Defaults to |
limit |
Limit bandwidth and CPU usage.
Defaults to |
timeout |
number of hours to time out the docker container.
Defaults to |
A dataset is obsolete when a newer version is available
mark_obsolete_dataset(channel)
mark_obsolete_dataset(channel)
channel |
An open ODBC channel |
n2kAggregate
objectA new n2kAggregate
model.
n2k_aggregate(...) ## S4 method for signature 'ANY' n2k_aggregate(...)
n2k_aggregate(...) ## S4 method for signature 'ANY' n2k_aggregate(...)
... |
other arguments. See below |
scheme_id
: a string holding the id of the scheme.
species_group_id
: a string identifying the species group.
location_group_id
: a string identifying the location group.
model_type
: a string identifying the type of model to fit to the data.
first_imported_year
: Oldest year considered in the data.
last_imported_year
: Most recent year considered in the data.
duration
: The width of the moving window.
Defaults to the last_imported_year - first_imported_year + 1
.
last_analysed_year
: Most recent year in the window.
Defaults to last_imported_year
.
analysis_date
: A POSIXct
date indicating the date that the dataset was
imported.
seed
: A single integer used as a seed for all calculations.
A random seed will be inserted when missing.
fun
: The function to apply when aggregating.
filter
: An optional list for the filter
argument of
multimput::aggregate_impute()
.
join
: An optional list for thejoin
argument of
multimput::aggregate_impute()
.
n2kComposite
objectA new n2kComposite
model is created when parent
is a
data.frame
.
n2k_composite(parent_status, ...) ## S4 method for signature 'data.frame' n2k_composite( parent_status, status = "waiting", result_datasource_id, scheme_id, formula, species_group_id, location_group_id, model_type, first_imported_year, last_imported_year, duration, last_analysed_year, analysis_date, extractor, ..., seed )
n2k_composite(parent_status, ...) ## S4 method for signature 'data.frame' n2k_composite( parent_status, status = "waiting", result_datasource_id, scheme_id, formula, species_group_id, location_group_id, model_type, first_imported_year, last_imported_year, duration, last_analysed_year, analysis_date, extractor, ..., seed )
parent_status |
A |
... |
other arguments |
status |
A single character indicating the status of the model.
Defaults to |
result_datasource_id |
A string identifying the data source. |
scheme_id |
A single integer holding the id of the scheme. |
formula |
A single character identifying the comparison. |
species_group_id |
A string identifying the species group. |
location_group_id |
A string identifying the location group. |
model_type |
The type of the models.
Must start with |
first_imported_year |
Oldest year considered in the data. |
last_imported_year |
Most recent year considered in the data. |
duration |
The width of the moving window.
Defaults to the |
last_analysed_year |
Most recent year in the window.
Defaults to |
analysis_date |
A |
extractor |
a function to extract the relevant parameters from the model |
seed |
A single integer used as a seed for all calculations. A random seed will be inserted when missing. |
n2kHurdleImputed
objectA new n2kHurdleImputed
model.
n2k_hurdle_imputed(presence, count, verbose = FALSE) ## S4 method for signature 'n2kInla' n2k_hurdle_imputed(presence, count, verbose = FALSE)
n2k_hurdle_imputed(presence, count, verbose = FALSE) ## S4 method for signature 'n2kInla' n2k_hurdle_imputed(presence, count, verbose = FALSE)
presence |
the |
count |
the |
verbose |
display the location group ID and species group ID.
Defaults to |
n2kImport
objectA new n2kImport
model.
n2k_import(...) ## S4 method for signature 'ANY' n2k_import(...)
n2k_import(...) ## S4 method for signature 'ANY' n2k_import(...)
... |
other arguments. See below |
scheme_id
: a string holding the id of the scheme.
species_group_id
: a string identifying the species group.
location_group_id
: a string identifying the location group.
model_type
: a string identifying the type of model to fit to the data.
first_imported_year
: Oldest year considered in the data.
last_imported_year
: Most recent year considered in the data.
duration
: The width of the moving window.
Defaults to the last_imported_year - first_imported_year + 1
.
last_analysed_year
: Most recent year in the window.
Defaults to last_imported_year
.
analysis_date
: A POSIXct
date indicating the date that the dataset was
imported.
seed
: A single integer used as a seed for all calculations.
A random seed will be inserted when missing.
formula
: a string holding the model formula.
dataset
: A data.frame
with filename
, fingerprint
and import_date
.
n2kInla
objectA new n2kInla
model is created when data
is a data.frame
.
In case data
is an n2kInla
object, then only the model and
status are updated.
All other slots are unaffected.
n2k_inla(data, ..., model_fit) ## S4 method for signature 'data.frame,ANY' n2k_inla( data, status = "new", result_datasource_id, scheme_id, family = "poisson", formula, species_group_id, location_group_id, model_type, first_imported_year, last_imported_year, duration, last_analysed_year, analysis_date, lin_comb = NULL, minimum = "", imputation_size, parent = character(0), seed, replicate_name = list(), control = list(), parent_status = "converged", parent_statusfingerprint, extra, ..., model_fit ) ## S4 method for signature 'n2kInla,inla' n2k_inla(data, status, raw_imputed = NULL, ..., model_fit)
n2k_inla(data, ..., model_fit) ## S4 method for signature 'data.frame,ANY' n2k_inla( data, status = "new", result_datasource_id, scheme_id, family = "poisson", formula, species_group_id, location_group_id, model_type, first_imported_year, last_imported_year, duration, last_analysed_year, analysis_date, lin_comb = NULL, minimum = "", imputation_size, parent = character(0), seed, replicate_name = list(), control = list(), parent_status = "converged", parent_statusfingerprint, extra, ..., model_fit ) ## S4 method for signature 'n2kInla,inla' n2k_inla(data, status, raw_imputed = NULL, ..., model_fit)
data |
a |
... |
other arguments. See below |
model_fit |
The fitted model |
status |
A single character indicating the status of the model.
Defaults to |
result_datasource_id |
A string identifying the data source. |
scheme_id |
A single integer holding the id of the scheme. |
family |
the family to use in the INLA model. |
formula |
A single character identifying the comparison. |
species_group_id |
A string identifying the species group. |
location_group_id |
A string identifying the location group. |
model_type |
The type of the models.
Must start with |
first_imported_year |
Oldest year considered in the data. |
last_imported_year |
Most recent year considered in the data. |
duration |
The width of the moving window.
Defaults to the |
last_analysed_year |
Most recent year in the window.
Defaults to |
analysis_date |
A |
lin_comb |
A model matrix to calculate linear combinations. |
minimum |
The name of the variable which holds the minimum counts. Only relevant in case of multiple imputation. |
imputation_size |
The required number of imputations defaults to 0. |
parent |
The file fingerprint of the optional parent analysis. |
seed |
A single integer used as a seed for all calculations. A random seed will be inserted when missing. |
replicate_name |
A list with the names of replicates.
Defaults to an empty list.
Used in case of |
control |
A named list passed to |
parent_status |
The status of the parent analysis. |
parent_statusfingerprint |
The status fingerprint of the parent analysis. |
extra |
a |
raw_imputed |
the optional |
n2kInlaComparison
objectA new n2kInlaComparison
model is created when parent
is a
character
.
n2k_inla_comparison(parent_status, ...) ## S4 method for signature 'data.frame' n2k_inla_comparison( parent_status, status = "waiting", result_datasource_id, scheme_id, formula, species_group_id, location_group_id, model_type, first_imported_year, last_imported_year, duration, last_analysed_year, analysis_date, ..., seed )
n2k_inla_comparison(parent_status, ...) ## S4 method for signature 'data.frame' n2k_inla_comparison( parent_status, status = "waiting", result_datasource_id, scheme_id, formula, species_group_id, location_group_id, model_type, first_imported_year, last_imported_year, duration, last_analysed_year, analysis_date, ..., seed )
parent_status |
A |
... |
other arguments |
status |
A single character indicating the status of the model.
Defaults to |
result_datasource_id |
A string identifying the data source. |
scheme_id |
A single integer holding the id of the scheme. |
formula |
A single character identifying the comparison. |
species_group_id |
A string identifying the species group. |
location_group_id |
A string identifying the location group. |
model_type |
The type of the models.
Must start with |
first_imported_year |
Oldest year considered in the data. |
last_imported_year |
Most recent year considered in the data. |
duration |
The width of the moving window.
Defaults to the |
last_analysed_year |
Most recent year in the window.
Defaults to |
analysis_date |
A |
seed |
A single integer used as a seed for all calculations. A random seed will be inserted when missing. |
n2kManifest
objectA new n2kManifest
object is created when manifest
is a
data.frame
.
n2k_manifest(manifest) ## S4 method for signature 'data.frame' n2k_manifest(manifest)
n2k_manifest(manifest) ## S4 method for signature 'data.frame' n2k_manifest(manifest)
manifest |
a |
n2kModelImputed
objectA new n2kModelImputed
model.
n2k_model_imputed(...) ## S4 method for signature 'ANY' n2k_model_imputed(...)
n2k_model_imputed(...) ## S4 method for signature 'ANY' n2k_model_imputed(...)
... |
other arguments. See below |
scheme_id
: a string holding the id of the scheme.
species_group_id
: a string identifying the species group.
location_group_id
: a string identifying the location group.
model_type
: a string identifying the type of model to fit to the data.
first_imported_year
: Oldest year considered in the data.
last_imported_year
: Most recent year considered in the data.
duration
: The width of the moving window.
Defaults to the last_imported_year - first_imported_year + 1
.
last_analysed_year
: Most recent year in the window.
Defaults to last_imported_year
.
analysis_date
: A POSIXct
date indicating the date that the dataset was
imported.
seed
: A single integer used as a seed for all calculations.
A random seed will be inserted when missing.
model_fun
: The model_fun
argument of multimput::model_impute()
.
package
: A character vector of package names which must be loaded for
model_fun
.
model_args
: An optional list for the model_args
argument of
multimput::model_impute()
.
extractor
: An optional list for the extractor
argument of
multimput::model_impute()
.
extractor_args
: An optional list for the extractor_args
argument of
multimput::model_impute()
.
filter
: An optional list for the filter
argument of
multimput::model_impute()
.
mutate
: An optional list for the 'mutate“ argument of
multimput::model_impute()
.
n2kAggregate
classIt holds analysis data based on an aggregated imputation
RawImputed
A rawImputed
object with multiple imputations.
Function
The function to apply on each group.
Filter
The object to pass to the filter
argument of
multimput::aggregate_impute()
.
Join
The object to pass to the join
argument of
multimput::aggregate_impute()
.
AggregatedImputed
An aggregatedImputed
object with multiple
imputations.
n2kComposite
classCalculate composite indices from multiple analysis
Extractor
A function to extract the relevant parameters from the model.
Parameter
A data.frame
with the relevant parameter estimates of each
parent analysis.
Index
The composite index based on the parameters.
n2kHurdleImputed
classIt holds the model2 of hurdle imputed data.
Presence
A rawImputed
object with the presence component.
Count
A rawImputed
object with the count component.
Hurdle
A aggregatedImputed
object with the resulting hurdle object.
n2kImport
classIt hold the imported datasets
Dataset
A data.frame
with the datasets.
n2kInla
classIt hold analysis data based on an INLA Poisson model
Data
A data.frame
with the data.
LinearCombination
An optional matrix with the linear combinations.
ReplicateName
An optional list with names of replicates.
Model
Either NULL or the resulting INLA model.
Family
The family of the INLA model.
Control
A named list with options passed to the arguments of
INLA::inla()
.
ImputationSize
The number of multiple imputations.
Defaults to 0
, indication no multiple imputation.
Minimum
An optional string containing the name of the variable in
Data
holding the minimal values for imputation.
RawImputed
A rawImputed
object with multiple imputations.
Extra
A data.frame with extra data to add to the imputations. This data is not used in the imputation model. It must contain the same variables as the original data.
n2kInlaComparison
classCompare multiple models using the WAIC criterion
WAIC
A data.frame
with WAIC values per model.
n2kModelImputed
classIt holds the model of aggregated imputed data
Function
The object to pass to the model.fun
argument of
multimput::model_impute()
.
Package
A vector of package names which must be loaded to run the function.
ModelArgs
The object to pass to the model.args
argument of
multimput::model_impute()
.
PrepareModelArgs
An optional list containing a single function that
will be applied to the object.
The result of the function will be appended to the ModelsArgs
.
Extractor
The object to pass to the extractor
argument of
multimput::model_impute()
.
ExtractorArgs
The object to pass to the extractor.args
argument of
multimput::model_impute()
.
Filter
The object to pass to the filter
argument of
multimput::model_impute()
.
Mutate
The object to pass to the mutate
argument of
multimput::model_impute()
.
AggregatedImputed
An aggregatedImputed
object with multiple
imputations.
Results
The data.frame
with the results of
multimput::model_impute()
.
n2kModel
Get the parent status of an n2kModel
parent_status(x) ## S4 method for signature 'n2kAnalysisMetadata' parent_status(x)
parent_status(x) ## S4 method for signature 'n2kAnalysisMetadata' parent_status(x)
x |
the |
the parent status of the object
n2kAnalysisMetadata
Overwrite the status of an n2kAnalysisMetadata
parent_status(x) <- value ## S4 replacement method for signature 'n2kComposite' parent_status(x) <- value
parent_status(x) <- value ## S4 replacement method for signature 'n2kComposite' parent_status(x) <- value
x |
the |
value |
the new values for the status |
n2kManifest
objectRead a n2kManifest
object
read_manifest(base, project, hash) ## S4 method for signature 'character' read_manifest(base, project, hash) ## S4 method for signature 's3_bucket' read_manifest(base, project, hash)
read_manifest(base, project, hash) ## S4 method for signature 'character' read_manifest(base, project, hash) ## S4 method for signature 's3_bucket' read_manifest(base, project, hash)
base |
The base location to read the manifest. |
project |
Will be a relative path within the base location. |
hash |
Optional the |
n2kModel
objectRead an n2kModel
object
read_model(x, base, project) ## S4 method for signature 'ANY,character' read_model(x, base, project) ## S4 method for signature 'ANY,s3_bucket' read_model(x, base, project) ## S4 method for signature 'ANY,ANY' read_model(x, base, project)
read_model(x, base, project) ## S4 method for signature 'ANY,character' read_model(x, base, project) ## S4 method for signature 'ANY,s3_bucket' read_model(x, base, project) ## S4 method for signature 'ANY,ANY' read_model(x, base, project)
x |
the file fingerprint of the |
base |
the base location to read the model |
project |
will be a relative path within the base location |
n2kResult
objectRead an n2kResult
object
read_result(x, base, project) ## S4 method for signature 'ANY,character' read_result(x, base, project) ## S4 method for signature 'ANY,s3_bucket' read_result(x, base, project) ## S4 method for signature 'ANY,ANY' read_result(x, base, project)
read_result(x, base, project) ## S4 method for signature 'ANY,character' read_result(x, base, project) ## S4 method for signature 'ANY,s3_bucket' read_result(x, base, project) ## S4 method for signature 'ANY,ANY' read_result(x, base, project)
x |
the file fingerprint of the |
base |
the base location to read the results |
project |
will be a relative path within the base location |
Aggregate all results estimates in a single dataframe
result_estimate(x, ...) ## S4 method for signature 'character' result_estimate(x, ..., base, project) ## S4 method for signature 'n2kResult' result_estimate(x, ...)
result_estimate(x, ...) ## S4 method for signature 'character' result_estimate(x, ..., base, project) ## S4 method for signature 'n2kResult' result_estimate(x, ...)
x |
object with the current results |
... |
further arguments (see Details) |
base |
the base location to read the results |
project |
will be a relative path within the base location |
Aggregate all results meta data in a single dataframe
result_metadata(x, ...) ## S4 method for signature 'character' result_metadata(x, ..., base, project) ## S4 method for signature 'n2kResult' result_metadata(x, ...)
result_metadata(x, ...) ## S4 method for signature 'character' result_metadata(x, ..., base, project) ## S4 method for signature 'n2kResult' result_metadata(x, ...)
x |
object with the current results |
... |
further arguments (see Details) |
base |
the base location to read the results |
project |
will be a relative path within the base location |
Presences have Count > 0
.
select_factor_count_strictly_positive( observation, variable, threshold, relative = FALSE, dimension = 1 )
select_factor_count_strictly_positive( observation, variable, threshold, relative = FALSE, dimension = 1 )
observation |
the |
variable |
the name of the |
threshold |
the minimal threshold |
relative |
When |
dimension |
Indicates which element of |
observation <- data.frame( Count = c(4, 4, 4, 4, 3, 3, 3, 0, 2, 2, 0, 0), LocationID = rep(1:3, each = 4), Year = rep(c(1, 1, 1, 1, 2, 2), 2) ) # Select the locations with at least 3 prescenses select_factor_count_strictly_positive( observation, variable = "LocationID", threshold = 3 ) # Select those locations in which the species is present in at least 2 years select_factor_count_strictly_positive( observation, variable = c("LocationID", "Year"), threshold = 2 ) # Select those years in which the species is present in at least 2 locations select_factor_count_strictly_positive( observation, variable = c("LocationID", "Year"), threshold = 2, dimension = 2 )
observation <- data.frame( Count = c(4, 4, 4, 4, 3, 3, 3, 0, 2, 2, 0, 0), LocationID = rep(1:3, each = 4), Year = rep(c(1, 1, 1, 1, 2, 2), 2) ) # Select the locations with at least 3 prescenses select_factor_count_strictly_positive( observation, variable = "LocationID", threshold = 3 ) # Select those locations in which the species is present in at least 2 years select_factor_count_strictly_positive( observation, variable = c("LocationID", "Year"), threshold = 2 ) # Select those years in which the species is present in at least 2 locations select_factor_count_strictly_positive( observation, variable = c("LocationID", "Year"), threshold = 2, dimension = 2 )
The negative binomial average of the Count
variable is calculated for
each level of variable
.
Only the levels which are equal or larger than threshold
times the
maximal average (in the original scale) are retained.
select_factor_threshold(observation, variable, threshold)
select_factor_threshold(observation, variable, threshold)
observation |
the |
variable |
the name of the |
threshold |
the minimal threshold |
observation <- data.frame( Count = c(100, 101, 50, 51, 1, 0, 0, 0), LocationID = factor(rep(1:4, each = 2)) ) select_factor_threshold(observation, "LocationID", threshold = 0.05)
observation <- data.frame( Count = c(100, 101, 50, 51, 1, 0, 0, 0), LocationID = factor(rep(1:4, each = 2)) ) select_factor_threshold(observation, "LocationID", threshold = 0.05)
Limit the observation to the range in which the species is present
select_observed_range(observation, variable)
select_observed_range(observation, variable)
observation |
the |
variable |
the name of the |
observation <- data.frame( Count = c(0, 0, 100, 101, 0, 51, 1, 0, 0, 0), Year = 1:10 ) select_observed_range(observation, "Year")
observation <- data.frame( Count = c(0, 0, 100, 101, 0, 51, 1, 0, 0, 0), Year = 1:10 ) select_observed_range(observation, "Year")
sessionInfo()
to a data.frame of packagesConvert a sessionInfo()
to a data.frame of packages
session_package(session) ## S4 method for signature 'sessionInfo' session_package(session)
session_package(session) ## S4 method for signature 'sessionInfo' session_package(session)
session |
The output of |
a data.frame with the packages of a sessionInfo()
n2kModel
Get the status of an n2kModel
status(x) ## S4 method for signature 'n2kAnalysisMetadata' status(x) ## S4 method for signature 'character' status(x)
status(x) ## S4 method for signature 'n2kAnalysisMetadata' status(x) ## S4 method for signature 'character' status(x)
x |
the |
the status of the object
n2kAnalysisMetadata
Overwrite the status of an n2kAnalysisMetadata
status(x) <- value ## S4 replacement method for signature 'n2kInla' status(x) <- value ## S4 replacement method for signature 'n2kComposite' status(x) <- value ## S4 replacement method for signature 'n2kInlaComparison' status(x) <- value ## S4 replacement method for signature 'n2kAggregate' status(x) <- value ## S4 replacement method for signature 'n2kModelImputed' status(x) <- value ## S4 replacement method for signature 'n2kHurdleImputed' status(x) <- value
status(x) <- value ## S4 replacement method for signature 'n2kInla' status(x) <- value ## S4 replacement method for signature 'n2kComposite' status(x) <- value ## S4 replacement method for signature 'n2kInlaComparison' status(x) <- value ## S4 replacement method for signature 'n2kAggregate' status(x) <- value ## S4 replacement method for signature 'n2kModelImputed' status(x) <- value ## S4 replacement method for signature 'n2kHurdleImputed' status(x) <- value
x |
the |
value |
the new values for the status |
n2kManifest
objectStore an n2kManifest
object
store_manifest(x, base, project) ## S4 method for signature 'ANY,character' store_manifest(x, base, project) ## S4 method for signature 'ANY,s3_bucket' store_manifest(x, base, project)
store_manifest(x, base, project) ## S4 method for signature 'ANY,character' store_manifest(x, base, project) ## S4 method for signature 'ANY,s3_bucket' store_manifest(x, base, project)
x |
the |
base |
the base location to store the manifest |
project |
will be a relative path within the base location |
Store a Docker configuration
store_manifest_yaml(x, base, project, docker, dependencies) ## S4 method for signature 'ANY,s3_bucket' store_manifest_yaml(x, base, project, docker, dependencies) ## S4 method for signature 'ANY,character' store_manifest_yaml(x, base, project, docker, dependencies)
store_manifest_yaml(x, base, project, docker, dependencies) ## S4 method for signature 'ANY,s3_bucket' store_manifest_yaml(x, base, project, docker, dependencies) ## S4 method for signature 'ANY,character' store_manifest_yaml(x, base, project, docker, dependencies)
x |
the |
base |
the base location to store the manifest |
project |
will be a relative path within the base location |
docker |
the docker image to use |
dependencies |
extra GitHub packages to install |
n2kModel
objectStore an n2kModel
object
store_model(x, base, project, overwrite = TRUE, validate = TRUE) ## S4 method for signature 'ANY,character' store_model(x, base, project, overwrite = TRUE, validate = TRUE) ## S4 method for signature 'ANY,s3_bucket' store_model(x, base, project, overwrite = TRUE, validate = TRUE)
store_model(x, base, project, overwrite = TRUE, validate = TRUE) ## S4 method for signature 'ANY,character' store_model(x, base, project, overwrite = TRUE, validate = TRUE) ## S4 method for signature 'ANY,s3_bucket' store_model(x, base, project, overwrite = TRUE, validate = TRUE)
x |
The |
base |
The base location to store the model. |
project |
Will be a relative path within the base location. |
overwrite |
Should an existing object be overwritten?
Defaults to |
validate |
Check that the object is valid before storing it.
Defaults to |
AnalysisVersions
Make a union of AnalysisVersions
union(...)
union(...)
... |
the |
Get the validity of objects in files
## S4 method for signature 'character' validObject(object, test = FALSE, complete = FALSE)
## S4 method for signature 'character' validObject(object, test = FALSE, complete = FALSE)
object |
a single filename, a single path or a vector with filenames. |
test |
|
complete |