Learn R Programming

CoSMoS

Complete Stochastic Modelling Solution

CoSMoS is an R package that makes time series generation with desired properties easy. Just choose the characteristics of the time series you want to generate, and it will do the rest. The generated time series preserve any probability distribution and any linear autocorrelation structure. Users can generate as many and as long time series from processes such as precipitation, wind, temperature, relative humidity etc. It is based on a framework that unified, extended, and improved a modelling strategy that generates time series by transforming “parent” Gaussian time series having specific characteristics (Papalexiou, 2018).

Install

To install the latest version of the package run:

## copy-paste to get the latest version of CoSMoS

if (!require('devtools')) {install.packages('devtools'); library(devtools)} 

install_github('TycheLab/CoSMoS', upgrade = 'never')

library(CoSMoS)

?`CoSMoS-package`

Funding

The package was partly funded by the Global institute for Water Security (GIWS; https://www.usask.ca/water/) and the Global Water Futures (GWF; https://gwf.usask.ca/) program.

Authors

Coded by: Filip Strnad and Francesco Serinaldi
Conceptual design by: Simon Michael Papalexiou
Tested and documented by: Yannis Markonis
Maintained by: Kevin Shook

References

Papalexiou, S.M., 2018. Unified theory for stochastic modelling of hydroclimatic processes: Preserving marginal distributions, correlation structures, and intermittency. Advances in Water Resources 115, 234-252. https://doi.org/10.1016/j.advwatres.2018.02.013

Copy Link

Version

Install

install.packages('CoSMoS')

Monthly Downloads

693

Version

2.1.2

License

AGPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Kevin Shook

Last Published

January 27th, 2026

Functions in CoSMoS (2.1.2)

advectionFspiral

Spiraling advection field
actfdiscrete

ACTF auto-correlation transformation function for discrete distributions
checkRF

Numerical and visual check of generated random fields
actfdiscreteInv

Inverse of ACTF auto-correlation transformation function
checkTS

Check generated timeseries
advectionF

Advection fields
erfc

Complementary (inverse) error function
disch

Daily streamflow data data
advectionF2

Advection fields
advectionFhyperbolic

Hyperbolic advection field
advectionFradial

Radial advection field
actpnts

AutoCorrelation Transformed Points
anisotropyTswirl

Swirl anisotropy transformation
generateMTS

Simulation of multiple time series with given marginals and spatiotemporal properties
acti

ACTI - autocorrelation transformation integral function
fitDist

Distribution fitting
anisotropyTwave

Wave anisotropy transformation
fitactf

Fit the AutoCorrelation Transformation Function
analyzeTS

The Functions analyzeTS, reportTS, and simulateTS
rMSE

Ratio mean square error
anisotropyT

Anisotropy transformation
anisotropyTaffine

Affine anisotropy transformation
anisotropyT2

Anisotropy transformation
plot.fitDist

Plot method for fitDist
generateMTSFast

Faster simulation of multiple time series with approximately separable spatiotemporal correlation structure
stcfclayton

Clayton SpatioTemporal Correlation Structure
precip

Hourly station precipitation data
seasonalAR

Seasonal AR model
plot.checkTS

Plot method for check results
stcfgneiting16

Gneiting-16 SpatioTemporal Correlation Structure
generateRF

Simulation of random field with given marginals and spatiotemporal properties
stcfgneiting14

Gneiting-14 SpatioTemporal Correlation Structure
plot.acti

AutoCorrelation Transformation Function visualisation
quickTSPlot

Quick visualization of basic timeseries properties
regenerateTS

Bulk Timeseries generation
stratifySeasonData

Stratify timeseries by season
generateRFFast

Faster simulation of random fields with approximately separable spatiotemporal correlation structure
fitVAR

VAR model parameters to simulate correlated parent Gaussian random vectors and fields
plot.cosmosts

Plot generated Timeseries
generateTS

Generate timeseries
getACSArg

Get names of autocorrelation structure (ACS) function arguments
stcs

SpatioTemporal Correlation Structure
plot.fitACS

Plot method for fitACS
stcs2

SpatioTemporal Correlation Structure
fitACS

Autocorrelation structure fit
getDistArg

Get names of distribution function arguments
lmom

L-Moments calculation
seasonalACF

Calculate seasonal ACF
moments

Numerical estimation of moments
sample.moments

Estimation of sample moments
GGamma

Generalized gamma distribution
acs

AutoCorrelation Structure
BurrIII

Burr Type III distribution
actf

ACTF auto-correlation transformation function
ParetoII

Pareto type II distribution
ECDF

Empirical cummulative distrubution function
BurrXII

Burr Type XII distribution
CoSMoS-package

CoSMoS: Complete Stochastic Modelling Solution
AR1

Autoregressive model of first order
YW

Yule-Walker solver
N

Norm - function to be minimized during distrubution fit
ARp

Autoregressive model of order p
PopulationStat

Population statistics
ACSfunctions

Autocorrelation structure functions
GEV

Generalized extreme value distribution
advectionFspiralCE

Spiraling advection field satisfying continuity equation
actfInv

Inverse of ACTF auto-correlation transformation function
advectionFuniform

Uniform advection field
advectionFrotation

Rotational advection field