library(CoSMoS)
## Load data included in the package
data("precip")
# \donttest{
## 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"))
# }
# \dontshow{
precip <- precip[between(date,
as.POSIXct("1990-1-01", format("%Y-%m-%d"), tz = "America/Regina"),
as.POSIXct("1990-1-5", format("%Y-%m-%d"), tz = "America/Regina"))]
a <- analyzeTS(precip, opts = list("algorithm" = "NLOPT_LN_NELDERMEAD",
"maxeval" = 10))
# }
Run the code above in your browser using DataLab