# NOT RUN {
library(CoSMoS)
## Load data included in the package
## (to find out more about the data use ?precip)
data('precip')
# }
# NOT RUN {
## Fit seasonal ACSs and distributions to the data
a <- analyzeTS(precip)
reportTS(a, 'dist') ## show seasonal distribution fit
reportTS(a, 'acs') ## show seasonal ACS fit
reportTS(a, 'stat') ## display basic descriptive statisctics
######################################
## 'duplicate' analyzed time series ##
sim <- simulateTS(a)
## plot the result
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()
################################################
## or simulate timeseries of different length ##
sim <- simulateTS(a,
from = as.POSIXct('1978-12-01 00:00:00'),
to = as.POSIXct('2008-12-01 00:00:00'))
## and plot the result
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()
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab