decomp_cj {SWMPr} | R Documentation |
Simple trend decomposition of monthly swmpr data
Description
Decompose monthly SWMP time series into grandmean, annual, seasonal, and event series as described in Cloern and Jassby 2010.
Usage
decomp_cj(dat_in, ...)
## S3 method for class 'swmpr'
decomp_cj(
dat_in,
param,
vals_out = FALSE,
event = TRUE,
type = c("add", "mult"),
center = c("mean", "median"),
...
)
## Default S3 method:
decomp_cj(
dat_in,
param,
date_col,
vals_out = FALSE,
event = TRUE,
type = c("add", "mult"),
center = c("mean", "median"),
...
)
Arguments
dat_in |
input data object |
... |
additional arguments passed to or from other methods |
param |
chr string of variable to decompose |
vals_out |
logical indicating of numeric output is returned, default is |
event |
logical indicating if an 'events' component should be determined |
type |
chr string indicating the type of decomposition, either additive ( |
center |
chr string indicating the method of centering, either |
date_col |
chr string indicating the name of the date column which should be a date or POSIX object. |
Details
This function is a simple wrapper to the decompTs
function in the archived wq package, also described in Cloern and Jassby (2010). The function is similar to decomp.swmpr
(which is a wrapper to decompose
) with a few key differences. The decomp.swmpr
function decomposes the time series into a trend, seasonal, and random components, whereas the current function decomposes into the grandmean, annual, seasonal, and events components. For both functions, the random or events components, respectively, can be considered anomalies that don't follow the trends in the remaining categories.
The decomp_cj
function provides only a monthly decomposition, which is appropriate for characterizing relatively long-term trends. This approach is meant for nutrient data that are obtained on a monthly cycle. The function will also work with continuous water quality or weather data but note that the data are first aggregated on the monthly scale before decomposition. Use the decomp.swmpr
function to decompose daily variation.
Value
A ggplot
object if vals_out = FALSE
(default), otherwise a monthly time series matrix of class ts
.
References
Cloern, J.E., Jassby, A.D. 2010. Patterns and scales of phytoplankton variability in estuarine-coastal ecosystems. Estuaries and Coasts. 33:230-241.
See Also
Examples
## get data
data(apacpnut)
dat <- apacpnut
dat <- qaqc(dat, qaqc_keep = NULL)
## decomposition of chl, values as data.frame
decomp_cj(dat, param = 'chla_n', vals_out = TRUE)
## decomposition of chl, ggplot
decomp_cj(dat, param = 'chla_n')
## decomposition changing arguments passed to decompTs
decomp_cj(dat, param = 'chla_n', type = 'mult')
## Not run:
## monthly decomposition of continuous data
data(apacpwq)
dat2 <- qaqc(apacpwq)
decomp_cj(dat2, param = 'do_mgl')
## using the default method with a data frame
dat <- data.frame(dat)
decomp_cj(dat, param = 'chla_n', date_col = 'datetimestamp')
## End(Not run)