Plot the evolution of a diving parameter accross time between two populations
Source:R/plot_comp.R
plot_comp.Rd
This function approximates the relationship between the considered diving behavior and time in order to better represent this evolution by a smooth curve, rather than by a scatterplot.
Usage
plot_comp(
data,
diving_parameter = NULL,
group_to_compare = "sp",
time = "day_departure",
id = ".id",
nb_days = 100,
bs = "cs",
k = 6,
alpha_point = 0.01,
alpha_ribbon = 0.4,
linetype_ribbon = 2,
colours = NULL,
ribbon = TRUE,
point = TRUE,
individual = TRUE,
populational = TRUE,
rows = NULL,
cols = NULL,
scales = "fixed",
method = "REML",
export_data_model = FALSE
)
Arguments
- data
A dataset containing the required information
- diving_parameter
The colname associated with the diving parameter to represent
- group_to_compare
The colname associated with the groups to compare
- time
The colname associated with time
- id
The colname associated with individual
- nb_days
How many days to represent
- bs
Smooth terms in GAM
- k
The dimension of the basis used to represent the smooth term
- alpha_point
The transparency of the point
- alpha_ribbon
The transparency of the ribbon
- linetype_ribbon
Line type for ribbon border
- colours
The colours to use
- ribbon
Should confidence interval be added
- point
Should the points be displayed
- individual
Should individuals curves be displayed
- populational
Should populational curve be displayed
- rows
The colname used for a facet in row
- cols
The colname used for a facet in column
- scales
Are scales shared across all facets (the default, "fixed")
- method
The smoothing parameter estimation method for the GAM (default
REML
)- export_data_model
Boolean to export the data of the underlying model
Details
This function fits a GAM with the species as a grouping factor and a random effect (intercept + slope) on the individual (i.e. diving parameter ~ species + s(time) + (1 time | individual). This allows to represent a curve for each species, but also to access to the curve associated with each individual.
References
James Grecian. (2022). jamesgrecian/harpPup: v1.0 (v1.0). Zenodo. https://doi.org/10.5281/zenodo.5901391