| analyzeTS | R Documentation |
analyzeTS automatically performs seasonal analysis, fits distributions
and correlation structures. reportTS visualises the fitted
distributions and correlation structures, or returns a table of fitted
parameters and descriptive statistics. simulateTS takes the result of
analyzeTS and generates synthetic realisations.
analyzeTS(
TS,
season = "month",
dist = "ggamma",
acsID = "weibull",
norm = "N1",
n.points = 30,
lag.max = 30,
constrain = FALSE,
opts = NULL
)
reportTS(aTS, method = "dist")
simulateTS(aTS, from = NULL, to = NULL)
TS |
data frame or data table with columns |
season |
character; name of a date-component function
(e.g. |
dist |
character; name of the distribution to fit (e.g. |
acsID |
character; ACS identifier passed to |
norm |
character; norm identifier — one of |
n.points |
integer; number of ECDF points used in the norm computation |
lag.max |
integer; maximum lag for the empirical ACF |
constrain |
logical; if |
opts |
list of |
aTS |
an |
method |
character; report type — |
from |
POSIXct; start of simulation period (defaults to start of observed series) |
to |
POSIXct; end of simulation period (defaults to end of observed series) |
In practice, we typically want to simulate a natural process from observed
data. analyzeTS fits a marginal distribution and autocorrelation
structure for each season; reportTS lets you inspect the fit;
simulateTS generates synthetic time series with the same seasonal
statistical properties.
Recommended distributions by variable type:
precipitation / streamflow: ggamma, burrXII, burrIII
relative humidity: beta
temperature: norm
analyzeTS: a list with elements data, dfits,
afits, and attributes season, dist, acsID,
date
reportTS: a ggplot object ("dist" or "acs"
method) or a data.frame ("stat" method)
simulateTS: a data.table with columns date and
value
fitDist, fitACS, generateTS
library(CoSMoS)
## Load data included in the package
data("precip")
## Fit seasonal ACSs and distributions to the data
a <- analyzeTS(precip)
reportTS(a, "dist") ## seasonal distribution fits
reportTS(a, "acs") ## seasonal ACS fits
reportTS(a, "stat") ## descriptive statistics
## Simulate a time series of the same length
sim <- simulateTS(a)
precip[, id := "observed"]
sim[, id := "simulated"]
dta <- rbind(precip, sim)
ggplot(dta) +
geom_line(aes(x = date, y = value)) +
facet_wrap(~id, ncol = 1) +
theme_classic()
## Simulate a time series of different length
sim <- simulateTS(a,
from = as.POSIXct("1978-12-01 00:00:00"),
to = as.POSIXct("2008-12-01 00:00:00"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.