library(envPred)
First, we recommend carefully reading the help page for the main function
?env_stats
To calculate the five environmental statistics (seasonality, colour of environmental noise, predictability, constancy, contingency) using sample data (temporally even SST data):
sst_pred <- env_stats(time_series = sst$time_series, dates = sst$dates, n_states = 11, delta = 1, is_uneven = FALSE, interpolate = FALSE, show_warns = TRUE, noise_method = "spectrum")
The argument n_states
is a numeric vector of length 1 containing a somewhat arbitrary number, as Colwell's method divides a continuous variable up into discrete states (read the original paper for further details). Default (arbitrary) is 11.
The above example threw a warning, which can be addressed in this example by:
sst <- sst[sst$dates <= as.Date("2007-01-01"), ] sst_pred <- env_stats(sst$time_series, sst$dates, n_states = 11, delta = 1, is_uneven = FALSE, interpolate = FALSE, show_warns = TRUE, noise_method = "spectrum")
The data can be plotted using ggplot2
methods. The user can plot both the de-trended dataset overlaid with the seasonal interpolation,
gg_envpred(sst_pred, type = "detrended")
or the spectral density on the log-10 scale
gg_envpred(sst_pred, type = "spectral")
Finally, the package also handles temporally uneven NPP data
with NAs (carefully check warnings), by using the Lomb-Scargle Periodogram from package
lomb
.
npp_pred <- env_stats(npp$time_series, npp$dates, n_states = 11, delta = 8, is_uneven = TRUE, interpolate = TRUE, show_warns = TRUE, noise_method = "lomb_scargle")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.