Title: | Generalized Polynomial Modelling |
---|---|
Description: | Platform dedicated to the Global Modelling technique. Its aim is to obtain ordinary differential equations of polynomial form directly from time series. It can be applied to single or multiple time series under various conditions of noise, time series lengths, sampling, etc. This platform is developped at the Centre d'Etudes Spatiales de la Biosphere (CESBIO), UMR 5126 UPS/CNRS/CNES/IRD, 18 av. Edouard Belin, 31401 TOULOUSE, FRANCE. The developments were funded by the French program Les Enveloppes Fluides et l'Environnement (LEFE, MANU, projets GloMo, SpatioGloMo and MoMu). The French program Defi InFiNiTi (CNRS) and PNTS are also acknowledged (projects Crops'IChaos and Musc & SlowFast). The method is described in the article : Mangiarotti S. and Huc M. (2019) <doi:10.1063/1.5081448>. |
Authors: | Sylvain Mangiarotti [aut], Mireille Huc [cre, aut], Flavie Le Jean [ctb], Malika Chassan [ctb], Laurent Drapeau [ctb], Institut de Recherche pour le Développement [fnd], Centre National de la Recherche Scientifique [fnd] |
Maintainer: | Mireille Huc <[email protected]> |
License: | CeCILL-2 |
Version: | 1.4 |
Built: | 2024-12-13 06:57:55 UTC |
Source: | CRAN |
GPoM is a platform dedicated to the Global Modelling technique. Its aim is to obtain deterministic models of Ordinary Differential Equations from observational time series. It applies to single and to multiple time series. With single time series, it can be used: to detect low-dimnesional determinism and low-dimensional (deterministic) chaos. It can also be used to characterize the observed behavior, using the obtained models as a proxy of the original dynamics, as far as the model validation could be checked. With multiple time series, it can be used: to detect couplings between observed variables, to infer causal networks, and to reformulate the original equations of the observed system (retro-modelling). The present package focuses on models in Ordinary Differential Equations of polynomial form. The package was designed to model weakly predictable dynamical behaviors (such as chaotic behaviors). Of course, it can also apply to more of fully predictable behavior, either linear or nonlinear. Several vignettes are associated to the package which can be used as a tutorial, and it also provides an overlook of the diversity of applications and at the performances of the tools. Users are kindly asked to quote the corresponding references when using the package (see hereafter).
FOR USERS
This package was developped at Centre d'Etudes Spatiales de
la Biosphere (Cesbio, UMR 5126, UPS-CNRS-CNES-IRD,
http://www.cesbio.ups-tlse.fr).
An important part of the developments were funded by
the French program Les Enveloppes Fluides et l'Environnement
(LEFE, MANU, projets GloMo, SpatioGloMo and MoMu).
The French program Défi InFiNiTi (CNRS) and PNTS
are also acknowledged (projects Crops'IChaos and Musc & SlowFast).
If you apply this package to single time series, please quote [6]. If you apply it to multivariate time series, please quote [10]. If you apply it to infer couplings among time series, please quote [8]. If you apply it to classification, please quote [11].
HISTORICAL BACKGROUND
The global modelling technique was initiated during
the early 1990s [1-3]. It takes its background from
the Theory of Nonlinear Dynamical Systems.
Earlier investigations can also be found in the fields
of Electrical Engineering and Statistics but these
mainly focused on linear problems [4].
The approach became applicable to the analysis of real world
environmental behaviours by the end of the 2000s [5-7].
Recent works have shown that the approach could be applied to
numerous other dynamical behaviors [8-10].
Global modelling aims to obtain deterministic models
directly from observed time series.
Sylvain Mangiarotti, Flavie Le Jean, Malika Chassan, Laurent Drapeau, Mireille Huc.
Maintainer: M. Huc <[email protected]>
[1] J. P. Crutchfield and B. S. McNamara, 1987.
Equations of motion from a data series,
Complex Systems. 1, 417-452.
[2] Gouesbet G., Letellier C., 1994.
Global vector-field reconstruction by using a multivariate
polynomial L2 approximation on nets,
Physical Review E, 49 (6), 4955-4972.
[3] C. Letellier, L. Le Sceller, E. Marechal, P. Dutertre, B. Maheu,
G. Gouesbet, Z. Fei, and J. L. Hudson, 1995.
Global vector field reconstruction from a chaotic experimental
signal in copper electrodissolution,
Physical Review E, 51, 4262-4266.
[4] L. A. Aguirre & C. Letellier,
Modeling nonlinear dynamics and chaos: A review,
Mathematical Problems in Engineering, 2009, 238960.
C. Letellier, L. Le Sceller, E. Marechal, P. Dutertre, B. Maheu,
G. Gouesbet, Z. Fei, and J. L. Hudson, 1995.
Global vector field reconstruction from a chaotic experimental
signal in copper electrodissolution,
Physical Review E 51, 4262-4266.
[5] J. Maquet, C. Letellier, and L. A. Aguirre, 2007.
Global models from the Canadian Lynx cycles as a first evidence
for chaos in real ecosystems,
Juornal of Mathematical Biology. 55(1), 21-39.
[6] Mangiarotti S., Coudret R., Drapeau L., & Jarlan L., 2012.
Polynomial search and global modeling : Two algorithms for
modeling chaos,
Physical Review E, 86, 046205.
[7] Mangiarotti S., Drapeau L. & Letellier C., 2014.
Two chaotic models for cereal crops observed from satellite in
northern Morocco.
Chaos, 24(2), 023130.
[8] Mangiarotti S., 2015. Low dimensional chaotic models for the
plague epidemic in Bombay (1896-1911).
Chaos, Solitons and Fractals, 81A, 184-186.
[9] Mangiarotti S., Peyre M. & Huc M.,
A chaotic model for the epidemic of Ebola Virus Disease in West Africa (2013-2016).
Chaos, 26, 113112, 2016.
[10] Mangiarotti S., 2014. Modelisation globale et Caracterisation
Topologique de dynamiques environnementales - de l'analyse des
enveloppes fluides et du couvert de surface de la Terre a la
caracterisation topolodynamique du chaos.
Habilitation to Direct Research,
University of Toulouse 3, France.
[11] Mangiarotti S., Sharma A.K., Corgne S., Hubert-Moy L., Ruiz L., Sekhar M., Kerr Y.,
Can the global modelling technique be used for crop classification?
Chaos, Solitons & Fractals, in press.
7_Retro-Modelling
)A list named allMod_nVar3_dMax2
of matrix
providing the numerical description of eighteen three-dimensional
chaotic systems:
Lorenz-1963 ($L63
), Rössler-1976 ($R76
), Burke & shaw 1981 ($BS81
),
Lorenz-1984 ($L84
), Nosé & Hooer 1986 ($NH86
), Genesio & Tosi 1992 ($GT92
),
Spott systems 1994 ($SprF
, $SprH
, $SprK
, $SprO
, $SprP
, $SprG
,
$SprM
, $SprQ
, $SprS
),
Chlouverakis & Sprott 2004 ($CS2004
), Li 2007 ($Li2007
)
and the Cord system by Aguirre & Letellier 2012 ($Cord2012
).
Each dynamical system is provided as a matrix:
each column corresponds to one equation,
each lines to the polynomial coefficients
which order is following the convetion defined
by function poLabs(nVar = 3, dMax = 2)
.
allMod_nVar3_dMax2
allMod_nVar3_dMax2
An object of class list
of length 18.
Sylvain Mangiarotti, Mireille Huc.
All the references are provided in
vignette 7_retro-modelling
.
autoGPoMoTest
.List of 6 models available for tests (by autoGPoMoTest
).
Each model ($mToTest1
, $mToTest2
, etc.) is provided as a matrix
of dimension 10 * 3. Each column corresponds to one equation.
The order of the coefficients follows the conventions defined
by poLabs(nVar = 3, dMax = 2)
.
allToTest
allToTest
An object of class list
of length 6.
Sylvain Mangiarotti, Mireille Huc
########### # example # ########### data("allToTest") # 6 models are available in this list: names(allToTest) # The parameter of their formulation (nVar and dMax) # can be retrieved: nVar <- dim(allToTest$mToTest6)[2] dMax <- p2dMax(nVar = 3, pMaxKnown = dim(allToTest$mToTest6)[1]) # Their equation can be edited as follows: visuEq(allToTest$mToTest6, nVar, dMax, approx = 2)
########### # example # ########### data("allToTest") # 6 models are available in this list: names(allToTest) # The parameter of their formulation (nVar and dMax) # can be retrieved: nVar <- dim(allToTest$mToTest6)[2] dMax <- p2dMax(nVar = 3, pMaxKnown = dim(allToTest$mToTest6)[1]) # Their equation can be edited as follows: visuEq(allToTest$mToTest6, nVar, dMax, approx = 2)
This algorithm aims to get an ensemble of possible
models which integrability will be tested later with function
autoGPoMoTest
. By default, all the terms are considered
available (Some of the terms can be excluded intentionally
using the option filterReg
).
The maximum size of the equation depends on the model dimension
nVar
, and on the maximum polynomial degree dMax
.
The algorithm removes polynomial terms one by one using a
leave-one-out method.
autoGPoMoSearch( data, dt, nVar, dMax, dMin = 0, weight = NULL, show = 0, underSamp = NULL, filterReg = NULL )
autoGPoMoSearch( data, dt, nVar, dMax, dMin = 0, weight = NULL, show = 0, underSamp = NULL, filterReg = NULL )
data |
Input Time series: Each column is one time series that corresponds to one variable. |
dt |
Time sampling of the input series. |
nVar |
Number of variables considered in the polynomial formulation. |
dMax |
Maximum degree of the polynomial formulation. |
dMin |
The minimum negative degree of the polynomial formulation (0 by default). |
weight |
A vector providing the binary weighting function of the input data series (0 or 1). By default, all the values are set to 1. |
show |
Provide (2) or not (0-1) visual output during the running process. |
underSamp |
Number of points used for undersampling the data.
For |
filterReg |
A vector that specifies the template for
the equation structure (for one single equation).
The convention defined by |
A list of two matrices:
$filtMemo
describes the selected terms
(1 if the term is used, 0 if not)
$KMemo
provides the corresponding coefficients
Sylvain Mangiarotti, Flavie Le Jean
autoGPoMoTest
, gPoMo
,
findAllSets
, poLabs
# Load data data('RosYco') # Search for potential models filt = autoGPoMoSearch(RosYco[,2], nVar = 3, dMax = 2, dt = 1/125, show = 1) # As an example, the equations of the fourth line has the following terms: poLabs(nVar = 3, dMax = 2)[filt$filtMemo[5,] != 0] # which coefficients correspond to cbind(filt$KMemo[5,], poLabs(nVar = 3, dMax = 2))[filt$filtMemo[5,] != 0,]
# Load data data('RosYco') # Search for potential models filt = autoGPoMoSearch(RosYco[,2], nVar = 3, dMax = 2, dt = 1/125, show = 1) # As an example, the equations of the fourth line has the following terms: poLabs(nVar = 3, dMax = 2)[filt$filtMemo[5,] != 0] # which coefficients correspond to cbind(filt$KMemo[5,], poLabs(nVar = 3, dMax = 2))[filt$filtMemo[5,] != 0,]
Tests the numerical integrability of
provided models (these may have been obtained with
function autoGPoMoSearch
),
and classify these models as Divergent, Fixed Points,
Periodic or not Unclassified (potentially chaotic).
autoGPoMoTest( data, nVar, dMax, dMin = 0, tin = NULL, dt = NULL, show = 1, verbose = 1, allKL = allKL, numValidIC = 1, weight = NULL, IstepMin = 10, IstepMax = 10000, tooFarThr = 4, FxPtThr = 1e-08, LimCyclThr = 1e-06, method = "rk4" )
autoGPoMoTest( data, nVar, dMax, dMin = 0, tin = NULL, dt = NULL, show = 1, verbose = 1, allKL = allKL, numValidIC = 1, weight = NULL, IstepMin = 10, IstepMax = 10000, tooFarThr = 4, FxPtThr = 1e-08, LimCyclThr = 1e-06, method = "rk4" )
data |
Input Time series: Each column is one time series that corresponds to one variable. |
nVar |
Number of variables considered in the polynomial formulation. |
dMax |
Maximum degree of the polynomial formulation. |
dMin |
The minimum negative degree of the polynomial formulation (0 by default). |
tin |
Input date vector which length should correspond to the input time series. |
dt |
Sampling time of the input time series. |
show |
Provide (2) or not (0-1) visual output during the running process. |
verbose |
Gives information (if set to 1) about the algorithm progress and keeps silent if set to 0. |
allKL |
A list of all the models |
numValidIC |
Line number of the first valid initial conditions, that is, such as weight is not equal to zero. |
weight |
A vector providing the binary weighting function of the input data series (0 or 1). By default, all the values are set to 1. |
IstepMin |
The minimum number of integration step to start
of the analysis (by default |
IstepMax |
The maximum number of integration steps for
stopping the analysis (by default |
tooFarThr |
Divergence threshold, maximum value of the model trajectory compared to the data standard deviation. By default a trjactory is too far if the distance to the center is larger than four times the variance of the input data. |
FxPtThr |
Threshold used to detect fixed points. |
LimCyclThr |
Threshold used to detect the limit cycle. |
method |
The integration technique used for the numerical
integration. By default, the fourth-order Runge-Kutta method
( |
A list containing:
$okMod
A vector classifying the models: diverging models (0),
periodic models of period-1 (-1), unclassified models (1).
$okMod
A matrix classifying the model variables: diverging variable (0),
period-1 variable (-1), period-2 variable (-2), fixed point variable (2), unclassified models (1).
$coeff
A matrix with the coefficients of one selected model
$models
A list of all the models to be tested $mToTest1
,
$mToTest2
, etc. and of all selected models $model1
, $model2
, etc.
$tout
The time vector of the output time series (vector length
corresponding to the longest numerical integration duration)
$stockoutreg
A list of matrices with the integrated trajectories
(variable X1
in column 1, X2
in 2, etc.) for all the models
$model1
, $model2
, etc.
Sylvain Mangiarotti, Flavie Le Jean
autoGPoMoSearch
, gPoMo
, poLabs
#Example # Load data: data('RosYco') # Structure choice data('allToTest') # Test the models outGPT <- autoGPoMoTest(RosYco, nVar= 3, dMax = 2, dt = 1/125, show=1, allKL = allToTest, IstepMax = 60)
#Example # Load data: data('RosYco') # Structure choice data('allToTest') # Test the models outGPT <- autoGPoMoTest(RosYco, nVar= 3, dMax = 2, dt = 1/125, show=1, allKL = allToTest, IstepMax = 60)
Build the Savitzky-Golay derivative filter (Savitzky-Golay, 1964).
bDrvFilt(nDrv, tstep, winL = 9)
bDrvFilt(nDrv, tstep, winL = 9)
nDrv |
The number of derivatives to be computed. |
tstep |
Sampling time. |
winL |
The local window length to be used for computing the derivatives [1]. |
dFlt A matrix of size (nDrv+1) * winL
Sylvain Mangiarotti
[1] Savitzky, A.; Golay, M.J.E.,
Smoothing and Differentiation of Data by Simplified Least Squares Procedures.
Analytical Chemistry 36 (8), 1627-1639, 1964.
Converts the vectorial formulation of canonical models
into a matrix formulation (that is, including explicitely all the
equations). For both input, the list of terms follows the convention
defined by poLabs
.
cano2M(nVar, dMax, poly, dMin = 0)
cano2M(nVar, dMax, poly, dMin = 0)
nVar |
The number of variables |
dMax |
The maximum degree allowed in the formulation |
poly |
A vector of coefficients corresponding to the regressor of the canonical function |
dMin |
The minimum negative degree of the polynomial formulation (0 by default). |
Kmod
A matrix with nVar columns of the complete description of the equations.
The first columns relates to the canonical part dX1/dt = X2, dX2/dt = X3 etc. and
the column is the polynomial term itself
Sylvain Mangiarotti, Mireille Huc
# A vector of polynomial terms corresponding to a canonical form: polyTerms <- c(0.2,0,-1,0.5,0,0,0,0,0,0) # Convert this vector into a matrix formulation with all the equations: K <- cano2M(3,2,polyTerms) # Visualize the equations: visuEq(K,3,2)
# A vector of polynomial terms corresponding to a canonical form: polyTerms <- c(0.2,0,-1,0.5,0,0,0,0,0,0) # Convert this vector into a matrix formulation with all the equations: K <- cano2M(3,2,polyTerms) # Visualize the equations: visuEq(K,3,2)
Combines equations of different sources
into a single system. During this combination, the polynomial
maximal degree can be either imposed or optimized to reduce
the model size. All the input have to follow
the convention defined by poLabs
.
combiEq(allKL, eqOrder = NULL, dMaxOut = NULL)
combiEq(allKL, eqOrder = NULL, dMaxOut = NULL)
allKL |
A list of models, each provided as a matrix. A single matrix can also be provided, it will be transformed into a list containing a single matrix. |
eqOrder |
A list of vector, providing each the equations number (relating to the input models) to be kept in the output equation system. If not provided, all the equations are kept. A single matrix can also be provided, it will be transformed into a list containing a single matrix. |
dMaxOut |
The maximal polynomial degree of the output equation system (if not provided, this degree is deduced from the input models) |
KLout A matrix of the combined model
Sylvain Mangiarotti
# Load models data("allMod_nVar3_dMax2") # Display equations of system 1 visuEq(nVar = 3, dMax = 2, K = allMod_nVar3_dMax2$NH86, substit = 1) # Display equations of system 2 visuEq(nVar = 3, dMax = 2, K = allMod_nVar3_dMax2$R76, substit = 1) # put the two systems in a list allK <- list() allK[[1]] <- allMod_nVar3_dMax2$NH86 allK[[2]] <- allMod_nVar3_dMax2$R76 # Example 1: reformulate two autonomous system in a single matrix visuEq(K = allK[[1]], substit = c('u', 'v', 'w')) visuEq(K = allK[[2]], substit = c('X', 'Y', 'Z')) Knew <- combiEq(allK) visuEq(K = Knew, substit = c('u', 'v', 'w', 'X', 'Y', 'Z')) # Example 2 inXnote = list() inXnote[[1]] <- c('u', 'v', 'w') inXnote[[2]] <- c('X', 'Y', 'Z') visuEq(K = allK[[1]], substit = inXnote[[1]]) visuEq(K = allK[[2]], substit = inXnote[[2]]) XnoteOut = c('X', 'Y', 'Z', 'u', 'v', 'w') Knew2 <- combiEq(allK, eqOrder=c(4,5,6,1,2,3)) visuEq(K = Knew2, substit = XnoteOut) # Example 3 inXnote = list() inXnote[[1]] <- c('u', 'v', 'w') inXnote[[2]] <- c('X', 'Y', 'Z') visuEq(K = allK[[1]], substit = inXnote[[1]]) visuEq(K = allK[[2]], substit = inXnote[[2]]) XnoteOut = c('u', 'X', 'v', 'Y', 'w', 'Z') Knew3 <- combiEq(allK, eqOrder=c(1,4,2,5,3,6), dMaxOut = 3) visuEq(K = Knew3, substit = XnoteOut)
# Load models data("allMod_nVar3_dMax2") # Display equations of system 1 visuEq(nVar = 3, dMax = 2, K = allMod_nVar3_dMax2$NH86, substit = 1) # Display equations of system 2 visuEq(nVar = 3, dMax = 2, K = allMod_nVar3_dMax2$R76, substit = 1) # put the two systems in a list allK <- list() allK[[1]] <- allMod_nVar3_dMax2$NH86 allK[[2]] <- allMod_nVar3_dMax2$R76 # Example 1: reformulate two autonomous system in a single matrix visuEq(K = allK[[1]], substit = c('u', 'v', 'w')) visuEq(K = allK[[2]], substit = c('X', 'Y', 'Z')) Knew <- combiEq(allK) visuEq(K = Knew, substit = c('u', 'v', 'w', 'X', 'Y', 'Z')) # Example 2 inXnote = list() inXnote[[1]] <- c('u', 'v', 'w') inXnote[[2]] <- c('X', 'Y', 'Z') visuEq(K = allK[[1]], substit = inXnote[[1]]) visuEq(K = allK[[2]], substit = inXnote[[2]]) XnoteOut = c('X', 'Y', 'Z', 'u', 'v', 'w') Knew2 <- combiEq(allK, eqOrder=c(4,5,6,1,2,3)) visuEq(K = Knew2, substit = XnoteOut) # Example 3 inXnote = list() inXnote[[1]] <- c('u', 'v', 'w') inXnote[[2]] <- c('X', 'Y', 'Z') visuEq(K = allK[[1]], substit = inXnote[[1]]) visuEq(K = allK[[2]], substit = inXnote[[2]]) XnoteOut = c('u', 'X', 'v', 'Y', 'w', 'Z') Knew3 <- combiEq(allK, eqOrder=c(1,4,2,5,3,6), dMaxOut = 3) visuEq(K = Knew3, substit = XnoteOut)
Computes the successive derivatives from one single time series, with the Savitzky-Golay approach (1964).
compDeriv(TS, nDrv, tstep, winL = 9)
compDeriv(TS, nDrv, tstep, winL = 9)
TS |
A single time series provided as a single vector. |
nDrv |
The number of derivatives to be computed from the input
|
tstep |
Sampling Time of the input time series |
winL |
The local window length used for computing the derivatives [1-2]. |
drv A matrix containing the original variable (smoothed by the
filtering process) in the first comlumn and its nDrv
+1 first derivatives
in the next columns (note that winL
values of the original time series
will be lost both at the begining and the end of the time series due to boundary
effect).
Sylvain Mangiarotti
[1] Savitzky, A.; Golay, M.J.E.,
Smoothing and Differentiation of Data by Simplified Least Squares Procedures.
Analytical Chemistry 36 (8), 1627-1639, 1964.
[2] Steinier J., Termonia Y., Deltour, J.
Comments on smoothing and differentiation of data by simplified least square procedure.
Analytical Chemistry 44 (11): 1906-1909, 1972.
# load data: data(NDVI) # Compute the derivatives: drv <- compDeriv(NDVI[,1], nDrv = 3, tstep = 1/125)
# load data: data(NDVI) # Compute the derivatives: drv <- compDeriv(NDVI[,1], nDrv = 3, tstep = 1/125)
The aim of this code is to provide, from a set of multiple time series, a single concatenated time series for applying the global modeling technique to all the time time series in association.
concat(svrlTS, winL = 9)
concat(svrlTS, winL = 9)
svrlTS |
All separated time series. |
winL |
Total number of points used for computing the derivatives
of the input time series. This parameter will be used as an
input in function |
concaTS
The concatenated time series.
Sylvain Mangiarotti, Mireille Huc
S. Mangiarotti, F. Le Jean, M. Huc & C. Letellier, 2016. Global modeling of aggregated and associated chaotic dynamics, Chaos, Solitons & Fractals, 83, 82-96.
# load data data("svrlTS") # Concatenate the data set into a single time series winL = 55 concaTS <- concat(svrlTS, winL = winL) # Plot the concatenated time series plot(concaTS$sglTS$TS[,1], concaTS$sglTS$TS[,2], main = 'Concatenated time series', xlab = 'Time (concatenated)', ylab = 'y(t)', type = 'l', col = 'gray') lines(concaTS$sglTS$TS[concaTS$sglTS$W == 1,1], concaTS$sglTS$TS[concaTS$sglTS$W == 1,2], type = 'p', col = 'green', cex = 0.5) lines(concaTS$sglTS$TS[concaTS$sglTS$W == 0,1], concaTS$sglTS$TS[concaTS$sglTS$W == 0,2], type = 'p', col = 'red', cex = 0.5) lines(concaTS$sglTS$TS[,1], concaTS$sglTS$W, type = 'l') # The concatenated data set can be used for global modelling: GPout1 <- gPoMo(data = concaTS$sglTS$TS[,2], tin = concaTS$sglTS$TS[,1], dMax = 2, nS = 3, winL = winL, weight = concaTS$sglTS$W, show = 1, IstepMin = 10, IstepMax = 6000, nPmin = 11, nPmax = 11, method = 'rk4')
# load data data("svrlTS") # Concatenate the data set into a single time series winL = 55 concaTS <- concat(svrlTS, winL = winL) # Plot the concatenated time series plot(concaTS$sglTS$TS[,1], concaTS$sglTS$TS[,2], main = 'Concatenated time series', xlab = 'Time (concatenated)', ylab = 'y(t)', type = 'l', col = 'gray') lines(concaTS$sglTS$TS[concaTS$sglTS$W == 1,1], concaTS$sglTS$TS[concaTS$sglTS$W == 1,2], type = 'p', col = 'green', cex = 0.5) lines(concaTS$sglTS$TS[concaTS$sglTS$W == 0,1], concaTS$sglTS$TS[concaTS$sglTS$W == 0,2], type = 'p', col = 'red', cex = 0.5) lines(concaTS$sglTS$TS[,1], concaTS$sglTS$W, type = 'l') # The concatenated data set can be used for global modelling: GPout1 <- gPoMo(data = concaTS$sglTS$TS[,2], tin = concaTS$sglTS$TS[,1], dMax = 2, nS = 3, winL = winL, weight = concaTS$sglTS$W, show = 1, IstepMin = 10, IstepMax = 6000, nPmin = 11, nPmax = 11, method = 'rk4')
The aim of this code is to provide, from multiple sets of (single or multiple) time series, a single concatenated set of time series for applying the global modeling technique to all the time time series in association.
concatMulTS(svrlTS, winL = 9)
concatMulTS(svrlTS, winL = 9)
svrlTS |
All separated sets of time series. |
winL |
Total number of points used for computing the derivatives
of the input time series. This parameter will be used as an
input in function |
concaTS
A single set of concatenated time series.
Sylvain Mangiarotti, Mireille Huc
S. Mangiarotti, F. Le Jean, M. Huc & C. Letellier, 2016. Global modeling of aggregated and associated chaotic dynamics, Chaos, Solitons & Fractals, 83, 82-96.
# load data data("svrlTS") # Concatenate the data set into a single time series winL = 55 concaTS <- concat(svrlTS, winL = winL) # Plot the concatenated time series plot(concaTS$sglTS$TS[,1], concaTS$sglTS$TS[,2], main = 'Concatenated time series', xlab = 'Time (concatenated)', ylab = 'y(t)', type = 'l', col = 'gray') lines(concaTS$sglTS$TS[concaTS$sglTS$W == 1,1], concaTS$sglTS$TS[concaTS$sglTS$W == 1,2], type = 'p', col = 'green', cex = 0.5) lines(concaTS$sglTS$TS[concaTS$sglTS$W == 0,1], concaTS$sglTS$TS[concaTS$sglTS$W == 0,2], type = 'p', col = 'red', cex = 0.5) lines(concaTS$sglTS$TS[,1], concaTS$sglTS$W, type = 'l') # The concatenated data set can be used for global modelling: GPout1 <- gPoMo(data = concaTS$sglTS$TS[,2], tin = concaTS$sglTS$TS[,1], dMax = 2, nS = 3, winL = winL, weight = concaTS$sglTS$W, show = 1, IstepMin = 10, IstepMax = 6000, nPmin = 11, nPmax = 11, method = 'rk4')
# load data data("svrlTS") # Concatenate the data set into a single time series winL = 55 concaTS <- concat(svrlTS, winL = winL) # Plot the concatenated time series plot(concaTS$sglTS$TS[,1], concaTS$sglTS$TS[,2], main = 'Concatenated time series', xlab = 'Time (concatenated)', ylab = 'y(t)', type = 'l', col = 'gray') lines(concaTS$sglTS$TS[concaTS$sglTS$W == 1,1], concaTS$sglTS$TS[concaTS$sglTS$W == 1,2], type = 'p', col = 'green', cex = 0.5) lines(concaTS$sglTS$TS[concaTS$sglTS$W == 0,1], concaTS$sglTS$TS[concaTS$sglTS$W == 0,2], type = 'p', col = 'red', cex = 0.5) lines(concaTS$sglTS$TS[,1], concaTS$sglTS$W, type = 'l') # The concatenated data set can be used for global modelling: GPout1 <- gPoMo(data = concaTS$sglTS$TS[,2], tin = concaTS$sglTS$TS[,1], dMax = 2, nS = 3, winL = winL, weight = concaTS$sglTS$W, show = 1, IstepMin = 10, IstepMax = 6000, nPmin = 11, nPmax = 11, method = 'rk4')
pMax
given dMax
and nVar
Computes the number of polynomial terms pMax
used to formulate an equation given
the maximal polynomial degree dMax
and the number of variables nVar
following the conventions as defined by fuction poLabs
.
d2pMax(nVar, dMaxKnown, dMin = 0)
d2pMax(nVar, dMaxKnown, dMin = 0)
nVar |
Number of variables considered in the polynomial formulation. |
dMaxKnown |
The maximum polynomial degree |
dMin |
The minimum negative degree of the polynomial formulation (0 by default). |
The number pMax
of polynomial terms used to code
a polynomial equation
Sylvain Mangiarotti
############# # Example 1 # ############# # Maximum polynomial degree ? # number of variables: nVar <- 3 # polynomial degree: dMax <- 3 # The maximal polynomial degree used for coding the polynomial is: d2pMax(nVar,dMax)
############# # Example 1 # ############# # Maximum polynomial degree ? # number of variables: nVar <- 3 # polynomial degree: dMax <- 3 # The maximal polynomial degree used for coding the polynomial is: d2pMax(nVar,dMax)
III_Modelling
To reduce the computation time, the outputs of the simulations presented in vignette VI have been run beforehand and saved in this file.
data_vignetteIII
data_vignetteIII
An object of class list
of length 12.
Sylvain Mangiarotti, Mireille Huc.
VI_Sensitivity
To reduce the computation time, the outputs of the simulations presented in vignette VI have been run beforehand and saved in this file.
data_vignetteVI
data_vignetteVI
An object of class list
of length 6.
Sylvain Mangiarotti, Mireille Huc.
VII_Retro-Modelling
To reduce the computation time, the outputs of the simulations presented in vignette VII have been run beforehand and saved in this file.
data_vignetteVII
data_vignetteVII
An object of class list
of length 29.
Sylvain Mangiarotti, Mireille Huc.
poLabs
.This function provides the one step integration of
polynomial Ordinary Differential Equations (ODE). This function
requires the function ode
(deSolve
package).
derivODE2(t, x, K, dMin = 0, regS = NULL)
derivODE2(t, x, K, dMin = 0, regS = NULL)
t |
All the dates for which the result of the numerical integration of the model must be provided |
x |
Current state vector (input from which the next state will be estimated) |
K |
A matrix providing the model description:
each column corresponds to one equation which polynomial organisation
is following the convention defined by function |
dMin |
The minimum negative degree of the polynomial formulation (0 by default). |
regS |
Current states of each polynomial terms used
in |
Sylvain Mangiarotti
poLabs
and with External Forcing F(t)This function provides the one step integration of
polynomial Ordinary Differential Equations (ODE). This function
requires the function ode
("deSolve" package).
This function has to be run with the Runge-Kutta method (method = 'rk4')
derivODEwMultiX(t, x, K, extF, regS = NULL)
derivODEwMultiX(t, x, K, extF, regS = NULL)
t |
All the dates for which the result of the numerical integration of the model will have to be provided |
x |
Current state vector (input from which the next state will be estimated) |
K |
is the model: each column corresponds to one equation
which organisation is following the convention given by function
|
extF |
is the external forcing. It is defined by two columns. The first colomn correspond to time t. The second column to F(t) the forcing at time t. Note that when launching the integration function ode, the forcing F(t) should be provided with a sampling time twice the sampling time used in t (because rk4 method will always use an intermediate time step). |
regS |
Current states of each polynomial terms used
in |
xxx
Sylvain Mangiarotti
# build a non autonomous model nVar = 4 dMax = 3 omega = 0.2 gamma = 0.05 KDf=matrix(0, nrow = d2pMax(nVar = nVar, dMax = dMax), ncol = nVar) KDf[11,1] = 1 KDf[2,2] = 1 KDf[5,2] = 1 KDf[11,2] = -gamma KDf[35,2] = -1 KDf[2,3] = NA KDf[2,4] = NA visuEq(K = KDf, substit = c('x', 'y', 'u', 'v')) # # Prepare the external forcing # number of integration time step Istep <- 500 # time step smpl <- 1 / 20 # output time vector dater <- (0:Istep) * smpl # hald step time vector (for Runge-Kutta integration) daterdbl <- (0:(Istep*2 + 1)) * smpl / 2 # generate the forcing (here variables u and v) extF = cbind(daterdbl, -0.1 * cos(daterdbl * omega), 0.05 * cos(daterdbl * 16/3*omega)) # # Initial conditions to be used (external variables can be set to 0) etatInit <- c(-0.616109362 , -0.126882584 , 0, 0) # # Numerical integration reconstr2 <- ode(etatInit, dater, derivODEwMultiX, KDf, extF = extF, method = 'rk4') # Reconstruction of the output nVarExt <- dim(extF)[2] - 1 reconstr2[,(nVar - nVarExt + 2):(nVar + 1)] <- extF[(0:Istep+1)*2, 2:(nVarExt+1)]
# build a non autonomous model nVar = 4 dMax = 3 omega = 0.2 gamma = 0.05 KDf=matrix(0, nrow = d2pMax(nVar = nVar, dMax = dMax), ncol = nVar) KDf[11,1] = 1 KDf[2,2] = 1 KDf[5,2] = 1 KDf[11,2] = -gamma KDf[35,2] = -1 KDf[2,3] = NA KDf[2,4] = NA visuEq(K = KDf, substit = c('x', 'y', 'u', 'v')) # # Prepare the external forcing # number of integration time step Istep <- 500 # time step smpl <- 1 / 20 # output time vector dater <- (0:Istep) * smpl # hald step time vector (for Runge-Kutta integration) daterdbl <- (0:(Istep*2 + 1)) * smpl / 2 # generate the forcing (here variables u and v) extF = cbind(daterdbl, -0.1 * cos(daterdbl * omega), 0.05 * cos(daterdbl * 16/3*omega)) # # Initial conditions to be used (external variables can be set to 0) etatInit <- c(-0.616109362 , -0.126882584 , 0, 0) # # Numerical integration reconstr2 <- ode(etatInit, dater, derivODEwMultiX, KDf, extF = extF, method = 'rk4') # Reconstruction of the output nVarExt <- dim(extF)[2] - 1 reconstr2[,(nVar - nVarExt + 2):(nVar + 1)] <- extF[(0:Istep+1)*2, 2:(nVarExt+1)]
This algorithm aim to detect period-1 limit cycles from trajectories in the phase sapce considered in a bidimensional projection.
detectP1limCycl(data, LimCyclThreshold = 0.01, show = 2)
detectP1limCycl(data, LimCyclThreshold = 0.01, show = 2)
data |
A matrix of the trajectory in a 2D space (if more than two columns are provided, only the two first columns are considered) |
LimCyclThreshold |
The detection threshold |
show |
Indicates the deepness of the feedback (from 0 to 2) |
Indicates if a limit cycle is detected (1) or not (0)
Sylvain Mangiarotti
Computes the successive derivatives from one single time series, using the Savitzky-Golay algorithm (1964).
drvSucc(tin = NULL, serie, nDeriv, weight = NULL, tstep = NULL, winL = 9)
drvSucc(tin = NULL, serie, nDeriv, weight = NULL, tstep = NULL, winL = 9)
tin |
Input date vector which length should correspond to the input time series. |
serie |
A single time series provided as a single vector. |
nDeriv |
The number of derivatives to be computed from
the input time series. The resulting number of
time series obtained in output will be |
weight |
A vector providing the binary weighting function of the input data series (0 or 1). By default, all the values are set to 1. |
tstep |
Sampling time of the input time series. Used
only if time vector |
winL |
Number (exclusively odd number) of points of the local window used for computing the derivatives along the input time series. The Savitzky-Golay filter is used for this purpose [1,2]. |
A list containing:
$serie The original time serie
$tin The time vector containing the dates corresponding to the original time series
$tstep The time step (assumed to be regular)
$tout The time vector of the output series
seriesDeriv A matrix containing the original time series
(smoothed by the filtering process) in the first column
and its nDeriv + 1
successive derivatives in the next ones.
Note that winL
values of the original time series will be lost,
that is (winL - 1)/2
at the begining and (winL - 1)/2
at the end of the time series due to a computation boundary effect).
Sylvain Mangiarotti, Mireille Huc
[1] Savitzky, A.; Golay, M.J.E.,
Smoothing and Differentiation of Data by Simplified Least Squares Procedures.
Analytical Chemistry 36 (8), 1627-1639, 1964.
[2] Steinier J., Termonia Y., Deltour, J.
Comments on smoothing and differentiation of data by simplified least square procedure.
Analytical Chemistry 44 (11): 1906-1909, 1972.
gloMoId
, gPoMo
, poLabs
, compDeriv
############# # Example 1 # ############# # Generate a time series: tin <- seq(0, 5, by = 0.01) data <- 2 * sin(5*tin) dev.new() oldpar <- par(no.readonly = TRUE) on.exit(par(oldpar)) par(mfrow = c(3, 1)) # Compute its derivatives: drv <- drvSucc(tin = tin, nDeriv = 2, serie = data, winL = 5) # # plot original and filtered series plot(tin, data, type='l', col = 'black', xlab = 't', ylab = 'x(t)') lines(drv$tout, drv$seriesDeriv[,1], lty = 3, lwd = 3, col = 'green') # # analytic 1st derivative firstD <- 10 * cos(5 * tin) # plot both plot(tin, firstD, type = 'l', col = 'black', xlab = 't', ylab = 'dx/dt') lines(drv$tout, drv$seriesDeriv[,2], lty = 3, lwd = 3, col = 'green') # # analytic 2nd derivative scdD <- -50 * sin(5 * tin) # plot both plot(tin, scdD, type = 'l', col = 'black', xlab = 't', ylab = 'd2x/dt2') lines(drv$tout, drv$seriesDeriv[,3], lty=3, lwd = 3, col = 'green') ############# # Example 2 # ############# # load data: data("Ross76") tin <- Ross76[,1] data <- Ross76[,2] # Compute the derivatives drvOut <- drvSucc(tin, data, nDeriv=4) dev.new() oldpar <- par(no.readonly = TRUE) on.exit(par(oldpar)) par(mfrow = c(3, 1)) # original and smoothed variable: plot(drvOut$tin, drvOut$serie, type='p', cex = 1, xlab = 'time', ylab = 'x(t)') lines(drvOut$tout, drvOut$seriesDeriv[,1], type='p', col='red') lines(drvOut$tout, drvOut$seriesDeriv[,1], type='l', col='red') # 1st derivative: plot(drvOut$tout, drvOut$seriesDeriv[,2], type='p', col='red', xlab = 'time', ylab = 'dx(t)/dt') lines(drvOut$tout, drvOut$seriesDeriv[,2], type='l', col='red') # 2nd derivative: plot(drvOut$tout, drvOut$seriesDeriv[,3], type='p', col='red', xlab = 'time', ylab = 'd2x(t)/dt2') lines(drvOut$tout, drvOut$seriesDeriv[,3], type='l', col='red')
############# # Example 1 # ############# # Generate a time series: tin <- seq(0, 5, by = 0.01) data <- 2 * sin(5*tin) dev.new() oldpar <- par(no.readonly = TRUE) on.exit(par(oldpar)) par(mfrow = c(3, 1)) # Compute its derivatives: drv <- drvSucc(tin = tin, nDeriv = 2, serie = data, winL = 5) # # plot original and filtered series plot(tin, data, type='l', col = 'black', xlab = 't', ylab = 'x(t)') lines(drv$tout, drv$seriesDeriv[,1], lty = 3, lwd = 3, col = 'green') # # analytic 1st derivative firstD <- 10 * cos(5 * tin) # plot both plot(tin, firstD, type = 'l', col = 'black', xlab = 't', ylab = 'dx/dt') lines(drv$tout, drv$seriesDeriv[,2], lty = 3, lwd = 3, col = 'green') # # analytic 2nd derivative scdD <- -50 * sin(5 * tin) # plot both plot(tin, scdD, type = 'l', col = 'black', xlab = 't', ylab = 'd2x/dt2') lines(drv$tout, drv$seriesDeriv[,3], lty=3, lwd = 3, col = 'green') ############# # Example 2 # ############# # load data: data("Ross76") tin <- Ross76[,1] data <- Ross76[,2] # Compute the derivatives drvOut <- drvSucc(tin, data, nDeriv=4) dev.new() oldpar <- par(no.readonly = TRUE) on.exit(par(oldpar)) par(mfrow = c(3, 1)) # original and smoothed variable: plot(drvOut$tin, drvOut$serie, type='p', cex = 1, xlab = 'time', ylab = 'x(t)') lines(drvOut$tout, drvOut$seriesDeriv[,1], type='p', col='red') lines(drvOut$tout, drvOut$seriesDeriv[,1], type='l', col='red') # 1st derivative: plot(drvOut$tout, drvOut$seriesDeriv[,2], type='p', col='red', xlab = 'time', ylab = 'dx(t)/dt') lines(drvOut$tout, drvOut$seriesDeriv[,2], type='l', col='red') # 2nd derivative: plot(drvOut$tout, drvOut$seriesDeriv[,3], type='p', col='red', xlab = 'time', ylab = 'd2x(t)/dt2') lines(drvOut$tout, drvOut$seriesDeriv[,3], type='l', col='red')
Combines equations of different sources
into a single system. During this combination, the polynomial
maximal degree can be either imposed or optimized to reduce
the model size. All the input have to follow
the convention defined by poLabs
.
extractEq(KL, eqVect)
extractEq(KL, eqVect)
KL |
A model, provided as a matrix. |
eqVect |
A vector of integers, providing the equations numbers to be kept in the output equation system. |
Mireille Huc
For each equation to be retrieved, an ensemble of potential formulation is given. For instance, if three possible formulations are provided for equation (1), one for equation (2) and two for equation (3). In this case, six (i.e. 3*1*2) possible sets of equations can be obtained from these potential formulations. The aim of this program is to formulate all the potential systems from the individual formulations provided of the individual equations.
findAllSets(allFilt, nS = c(3), nPmin = 1, nPmax = 14)
findAllSets(allFilt, nS = c(3), nPmin = 1, nPmax = 14)
allFilt |
A list with:
(1) A matrix |
nS |
A vector providing the number of dimensions used for each
input variables (see Examples 1 and 2). The dimension of the resulting
model will be |
nPmin |
Corresponds to the minimum number of parameters (and thus of polynomial term) allowed. |
nPmax |
Corresponds to the maximum number of parameters (and thus of polynomial) allowed. |
SetsNp A list of two matrices $Sets A matrix defining all the sets the equation combination (each line provides a combination, for instance, a line with 1,2,2 means the first equation of allFilt$X1, the second one of allFilt$X2 and the second one of allFilt$X3) $Np A matrix providing the number of parameters of all equation combination (each line provides the number of parameter of the selected equations)
Sylvain Mangiarotti
############# # Example 1 # ############# # We build an example allFilt <- list() # For equation 1 (variable X1) allFilt$Np1 <- 1 # only one formulation with one single parameter # For equation 2 (variable X2) allFilt$Np2 <- c(3, 2) # two potential formulations, with respectively three and four parameters # For equation 3 (variable X3) allFilt$Np3 <- c(4, 2) # two potential formulations, with respectively two and four parameters # Formulations for variables Xi: # For X1: allFilt$X1 <- t(as.matrix(c(0,0,0,1,0,0,0,0,0,0))) # For X2: allFilt$X2 <- t(matrix(c(0,-0.85,0,-0.27,0,0,0,0.46,0,0, 0,-0.64,0,0,0,0,0,0.43,0,0), ncol=2, nrow=10)) # For X3: allFilt$X3 <- t(matrix(c(0, 0.52, 0, -1.22e-05, 0, 0, 0.99, 5.38e-05, 0, 0, 0, 0.52, 0, 0, 0, 0, 0.99, 0, 0, 0), ncol=2, nrow=10)) # From these individual we can retrieve all possible formulations findAllSets(allFilt, nS=c(3), nPmin=1, nPmax=14) # if only formulations with seven maximum number of terms are expected: findAllSets(allFilt, nS=c(3), nPmin=1, nPmax=7)
############# # Example 1 # ############# # We build an example allFilt <- list() # For equation 1 (variable X1) allFilt$Np1 <- 1 # only one formulation with one single parameter # For equation 2 (variable X2) allFilt$Np2 <- c(3, 2) # two potential formulations, with respectively three and four parameters # For equation 3 (variable X3) allFilt$Np3 <- c(4, 2) # two potential formulations, with respectively two and four parameters # Formulations for variables Xi: # For X1: allFilt$X1 <- t(as.matrix(c(0,0,0,1,0,0,0,0,0,0))) # For X2: allFilt$X2 <- t(matrix(c(0,-0.85,0,-0.27,0,0,0,0.46,0,0, 0,-0.64,0,0,0,0,0,0.43,0,0), ncol=2, nrow=10)) # For X3: allFilt$X3 <- t(matrix(c(0, 0.52, 0, -1.22e-05, 0, 0, 0.99, 5.38e-05, 0, 0, 0, 0.52, 0, 0, 0, 0, 0.99, 0, 0, 0), ncol=2, nrow=10)) # From these individual we can retrieve all possible formulations findAllSets(allFilt, nS=c(3), nPmin=1, nPmax=14) # if only formulations with seven maximum number of terms are expected: findAllSets(allFilt, nS=c(3), nPmin=1, nPmax=7)
Algorithm for global modelling in
polynomial and canonical formulation of Ordinary
Differential Equations.
Univariate Global modeling aims to obtain multidimensional
models from single time series (Gouesbet & Letellier 1994,
Mangiarotti et al. 2012).
An example of such application can be found in
Mangiarotti et al. (2014)
For a multivariate application, see GPoMo
(Mangiarotti 2015, Mangiarotti et al. 2016).
Example:
For a model dimension nVar=3, the global model will read:
gloMoId( series, tin = NULL, dt = NULL, nVar = NULL, dMax = 1, dMin = 0, weight = NULL, show = 1, filterReg = NULL, winL = 9 )
gloMoId( series, tin = NULL, dt = NULL, nVar = NULL, dMax = 1, dMin = 0, weight = NULL, show = 1, filterReg = NULL, winL = 9 )
series |
The original data set: either a single vector
corresponding to the original variable; Or a matrix containing
the original variable in the first column and its successive
derivatives in the next columns. In the latter case, for the
construction of n-dimensional model, |
tin |
Input date vector which length should correspond to the input time series. |
dt |
Sampling time of the input time series. |
nVar |
Number of variables considered in the polynomial formulation. |
dMax |
Maximum degree of the polynomial formulation. |
dMin |
The minimum negative degree of the polynomial formulation (0 by default). |
weight |
A vector providing the binary weighting function of the input data series (0 or 1). By default, all the values are set to 1. |
show |
Provide (2) or not (0-1) visual output during the running process. |
filterReg |
A vector that specifies the template for
the equation structure (for one single equation).
The convention defined by |
winL |
Total number of points used for computing the derivatives
of the input time series. This parameter will be used as an
input in function |
A
list of five elements :
$init
The original time series and the successive derivatives used
for the modeling.
$filterReg
The structure of the output model. Value is 1 if the
regressor is available, 0 if it is not. The terms order is
given by function poLabs
.
$K
Values of the identified coefficients corresponding to
the regressors defined in filterReg
.
$resTot
The variance of the residual signal of the model.
$resSsMod
The variance of the residual signal of the closer submodels.
$finalWeight
Weighting series after boundary values
were removed.
Sylvain Mangiarotti, Laurent Drapeau, Mireille Huc
[1] Gouesbet G., Letellier C.,
Global vector-field reconstruction by using a multivariate polynomial
L2 approximation on nets,
Physical Review E, 49 (6), 4955-4972, 1994.
[2] Mangiarotti S., Coudret R., Drapeau L., & Jarlan L.,
Polynomial search and global modeling : Two algorithms for modeling chaos,
Physical Review E, 86, 046205, 2012.
[3] Mangiarotti S., Drapeau L. & Letellier C.,
Two chaotic models for cereal crops observed from satellite in northern Morocco.
Chaos, 24(2), 023130, 2014.
[4] Mangiarotti S.,
Low dimensional chaotic models for the plague epidemic in Bombay (1896-1911),
Chaos, Solitons & Fractals, 81(A), 184-196, 2015.
[5] Mangiarotti S., Peyre M. & Huc M.,
A chaotic model for the epidemic of Ebola Virus Disease in West Africa (2013-2016).
Chaos, 26, 113112, 2016.
gPoMo
, autoGPoMoSearch
,
autoGPoMoTest
, poLabs
############# # Example 1 # ############# # load data data("Ross76") tin <- Ross76[,1] data <- Ross76[,2:3] # Polynomial identification reg <- gloMoId(data[0:500,2], dt=1/100, nVar=2, dMax=2, show=0) ############# # Example 2 # ############# # load data data(NDVI) # Definition of the Model structure terms <- c(1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1) poLabs(3,3)[terms==1] reg <- gloMoId(NDVI [,1:1], dt=1/125, nVar=3, dMax=3, show=0, filterReg=terms==1) ############# # Example 3 # ############# # load data data("Ross76") # time vector tin <- Ross76[1:500,1] # single time series series <- Ross76[1:500,3] # some noise is added series[1:100] <- series[1:100] + 0.01 * runif(1:100, min = -1, max = 1) series[301:320] <- series[301:320] + 0.05 * runif(1:20, min = -1, max = 1) # weighting function W <- tin * 0 + 1 W[1:100] <- 0 # the first hundred values will not be considered W[301:320] <- 0 # twenty other values will not be considered either reg <- gloMoId(series, dt=1/100, weight = W, nVar=3, dMax=2, show=1) visuEq(reg$K, 3, 2, approx = 4) # first weight which value not equal to zero: i1 = which(reg$finalWeight == 1)[1] v0 <- reg$init[i1,1:3] reconstr <- numicano(nVar=3, dMax=2, Istep=5000, onestep=1/250, PolyTerms=reg$K, v0=v0, method="ode45") plot(reconstr$reconstr[,2], reconstr$reconstr[,3], type='l', lwd = 3, main='phase portrait', xlab='time t', ylab = 'x(t)', col='orange') # original data: lines(reg$init[,1], reg$init[,2], type='l', main='phase portrait', xlab='x', ylab = 'dx/dt', col='black') # initial condition lines(v0[1], v0[2], type = 'p', col = 'red')
############# # Example 1 # ############# # load data data("Ross76") tin <- Ross76[,1] data <- Ross76[,2:3] # Polynomial identification reg <- gloMoId(data[0:500,2], dt=1/100, nVar=2, dMax=2, show=0) ############# # Example 2 # ############# # load data data(NDVI) # Definition of the Model structure terms <- c(1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1) poLabs(3,3)[terms==1] reg <- gloMoId(NDVI [,1:1], dt=1/125, nVar=3, dMax=3, show=0, filterReg=terms==1) ############# # Example 3 # ############# # load data data("Ross76") # time vector tin <- Ross76[1:500,1] # single time series series <- Ross76[1:500,3] # some noise is added series[1:100] <- series[1:100] + 0.01 * runif(1:100, min = -1, max = 1) series[301:320] <- series[301:320] + 0.05 * runif(1:20, min = -1, max = 1) # weighting function W <- tin * 0 + 1 W[1:100] <- 0 # the first hundred values will not be considered W[301:320] <- 0 # twenty other values will not be considered either reg <- gloMoId(series, dt=1/100, weight = W, nVar=3, dMax=2, show=1) visuEq(reg$K, 3, 2, approx = 4) # first weight which value not equal to zero: i1 = which(reg$finalWeight == 1)[1] v0 <- reg$init[i1,1:3] reconstr <- numicano(nVar=3, dMax=2, Istep=5000, onestep=1/250, PolyTerms=reg$K, v0=v0, method="ode45") plot(reconstr$reconstr[,2], reconstr$reconstr[,3], type='l', lwd = 3, main='phase portrait', xlab='time t', ylab = 'x(t)', col='orange') # original data: lines(reg$init[,1], reg$init[,2], type='l', main='phase portrait', xlab='x', ylab = 'dx/dt', col='black') # initial condition lines(v0[1], v0[2], type = 'p', col = 'red')
Algorithm for a Generalized Polynomial formulation of multivariate Global Modeling. Global modeling aims to obtain multidimensional models from single time series [1-2]. In the generalized (polynomial) formulation provided in this function, it can also be applied to multivariate time series [3-4].
Example:
Note that nS
provides the number of dimensions used from each variable
case I
For nS=c(2,3)
means that 2 dimensions are reconstructed from variable 1:
the original variable X1
and its first derivative X2
), and
3 dimensions are reconstructed from variable 2: the original
variable X3
and its first and second derivatives X4
and X5
.
The generalized model will thus be such as:
case II
For nS=c(1,1,1,1)
means that only the original variables
X1
, X2
, X3
and X4
will be used.
The generalized model will thus be such as:
gPoMo( data, tin = NULL, dtFixe = NULL, dMax = 2, dMin = 0, nS = c(3), winL = 9, weight = NULL, show = 1, verbose = 1, underSamp = NULL, EqS = NULL, AndManda = NULL, OrMandaPerEq = NULL, IstepMin = 2, IstepMax = 2000, nPmin = 1, nPmax = 14, tooFarThr = 4, FxPtThr = 1e-08, LimCyclThr = 1e-06, nPminPerEq = 1, nPmaxPerEq = NULL, method = "rk4" )
gPoMo( data, tin = NULL, dtFixe = NULL, dMax = 2, dMin = 0, nS = c(3), winL = 9, weight = NULL, show = 1, verbose = 1, underSamp = NULL, EqS = NULL, AndManda = NULL, OrMandaPerEq = NULL, IstepMin = 2, IstepMax = 2000, nPmin = 1, nPmax = 14, tooFarThr = 4, FxPtThr = 1e-08, LimCyclThr = 1e-06, nPminPerEq = 1, nPmaxPerEq = NULL, method = "rk4" )
data |
Input Time series: Each column is one time series that corresponds to one variable. |
tin |
Input date vector which length should correspond to the input time series. |
dtFixe |
Time step used for the analysis. It should correspond to the sampling time of the input data. Note that for very large and very small time steps, alternative units may be used in order to stabilize the numerical computation. |
dMax |
Maximum degree of the polynomial formulation. |
dMin |
The minimum negative degree of the polynomial formulation (0 by default). |
nS |
A vector providing the number of dimensions used for each
input variables (see Examples 1 and 2). The dimension of the resulting
model will be |
winL |
Total number of points used for computing the derivatives
of the input time series. This parameter will be used as an
input in function |
weight |
A vector providing the binary weighting function of the input data series (0 or 1). By default, all the values are set to 1. |
show |
Provide (2) or not (0-1) visual output during the running process. |
verbose |
Gives information (if set to 1) about the algorithm progress and keeps silent if set to 0. |
underSamp |
Number of points used for undersampling the data.
For |
EqS |
Model template including all allowed regressors.
Each column corresponds to one equation. Each line corresponds to one
polynomial term as defined by function |
AndManda |
AND-mandatory terms in the equations (all the provided terms should be in the equations). |
OrMandaPerEq |
OR-mandatory terms per equations (at least one of the provided terms should be in each equation). |
IstepMin |
The minimum number of integration step to start
of the analysis (by default |
IstepMax |
The maximum number of integration steps for
stopping the analysis (by default |
nPmin |
Corresponds to the minimum number of parameters (and thus of polynomial term) allowed. |
nPmax |
Corresponds to the maximum number of parameters (and thus of polynomial) allowed. |
tooFarThr |
Divergence threshold, maximum value of the model trajectory compared to the data standard deviation. By default a trjactory is too far if the distance to the center is larger than four times the variance of the input data. |
FxPtThr |
Threshold used to detect fixed points. |
LimCyclThr |
Threshold used to detect the limit cycle. |
nPminPerEq |
Corresponds to the minimum number of parameters (and thus of polynomial term) allowed per equation. |
nPmaxPerEq |
Corresponds to the maximum number of parameters (and thus of polynomial) allowed per equation. |
method |
The integration technique used for the numerical
integration. By default, the fourth-order Runge-Kutta method
( |
A list containing:
$tin
The time vector of the input time series
$inputdata
The input time series
$tfiltdata
The time vector of the filtered time series (boudary removed)
$filtdata
A matrix of the filtered time series with its derivatives
$okMod
A vector classifying the models: diverging models (0), periodic
models of period-1 (-1), unclassified models (1).
$coeff
A matrix with the coefficients of one selected model
$models
A list of all the models to be tested $mToTest1
,
$mToTest2
, etc. and all selected models $model1
, $model2
, etc.
$tout
The time vector of the output time series (vector length
corresponding to the longest numerical integration duration)
$stockoutreg
A list of matrices with the integrated trajectories
(variable X1
in column 1, X2
in 2, etc.) of all the models $model1
,
$model2
, etc.
Sylvain Mangiarotti, Flavie Le Jean, Mireille Huc
[1] Gouesbet G. & Letellier C., 1994. Global vector-field reconstruction by using a
multivariate polynomial L2 approximation on nets, Physical Review E, 49 (6),
4955-4972.
[2] Mangiarotti S., Coudret R., Drapeau L. & Jarlan L., Polynomial search and
Global modelling: two algorithms for modeling chaos. Physical Review E, 86(4),
046205.
[3] Mangiarotti S., Le Jean F., Huc M. & Letellier C., Global Modeling of aggregated
and associated chaotic dynamics. Chaos, Solitons and Fractals, 83, 82-96.
[4] S. Mangiarotti, M. Peyre & M. Huc, 2016.
A chaotic model for the epidemic of Ebola virus disease
in West Africa (2013-2016). Chaos, 26, 113112.
gloMoId
, autoGPoMoSearch
,
autoGPoMoTest
autoGPoMoSearch
, autoGPoMoTest
, visuOutGP
,
poLabs
, predictab
, drvSucc
#Example 1 data("Ross76") tin <- Ross76[,1] data <- Ross76[,3] dev.new() out1 <- gPoMo(data, tin = tin, dMax = 2, nS=c(3), show = 1, IstepMax = 1000, nPmin = 9, nPmax = 11) visuEq(out1$models$model1, approx = 4) #Example 2 data("Ross76") tin <- Ross76[,1] data <- Ross76[,3] # if some data are not valid (vector 'weight' with zeros) W <- tin * 0 + 1 W[1:100] <- 0 W[700:1500] <- 0 W[2000:2800] <- 0 W[3000:3500] <- 0 dev.new() out2 <- gPoMo(data, tin = tin, weight = W, dMax = 2, nS=c(3), show = 1, IstepMax = 6000, nPmin = 9, nPmax = 11) visuEq(out2$models$model3, approx = 4) #Example 3 data("Ross76") tin <- Ross76[,1] data <- Ross76[,2:4] dev.new() out3 <- gPoMo(data, tin=tin, dMax = 2, nS=c(1,1,1), show = 1, IstepMin = 10, IstepMax = 3000, nPmin = 7, nPmax = 8) # the simplest model able to reproduce the observed dynamics is model #5 visuEq(out3$models$model5, approx = 3, substit = 1) # the original Rossler system is thus retrieved #Example 4 data("Ross76") tin <- Ross76[,1] data <- Ross76[,2:3] # model template: EqS <- matrix(1, ncol = 3, nrow = 10) EqS[,1] <- c(0,0,0,1,0,0,0,0,0,0) EqS[,2] <- c(1,1,0,1,0,1,1,1,1,1) EqS[,3] <- c(0,1,0,0,0,0,1,1,0,0) visuEq(EqS, substit = c('X','Y','Z')) dev.new() out4 <- gPoMo(data, tin=tin, dMax = 2, nS=c(2,1), show = 1, EqS = EqS, IstepMin = 10, IstepMax = 2000, nPmin = 9, nPmax = 11) visuEq(out4$models$model2, approx = 2, substit = c("Y","Y2","Z")) #Example 5 # load data data("TSallMod_nVar3_dMax2") #multiple (six) time series tin <- TSallMod_nVar3_dMax2$SprK$reconstr[1:400,1] TSRo76 <- TSallMod_nVar3_dMax2$R76$reconstr[,2:4] TSSprK <- TSallMod_nVar3_dMax2$SprK$reconstr[,2:4] data <- cbind(TSRo76,TSSprK)[1:400,] dev.new() # generalized Polynomial modelling out5 <- gPoMo(data, tin = tin, dMax = 2, nS = c(1,1,1,1,1,1), show = 0, method = 'rk4', IstepMin = 2, IstepMax = 3, nPmin = 13, nPmax = 13) # the original Rossler (variables x, y and z) and Sprott (variables u, v and w) # systems are retrieved: visuEq(out5$models$model347, approx = 4, substit = c('x', 'y', 'z', 'u', 'v', 'w')) # to check the robustness of the model, the integration duration # should be chosen longer (at least IstepMax = 4000)
#Example 1 data("Ross76") tin <- Ross76[,1] data <- Ross76[,3] dev.new() out1 <- gPoMo(data, tin = tin, dMax = 2, nS=c(3), show = 1, IstepMax = 1000, nPmin = 9, nPmax = 11) visuEq(out1$models$model1, approx = 4) #Example 2 data("Ross76") tin <- Ross76[,1] data <- Ross76[,3] # if some data are not valid (vector 'weight' with zeros) W <- tin * 0 + 1 W[1:100] <- 0 W[700:1500] <- 0 W[2000:2800] <- 0 W[3000:3500] <- 0 dev.new() out2 <- gPoMo(data, tin = tin, weight = W, dMax = 2, nS=c(3), show = 1, IstepMax = 6000, nPmin = 9, nPmax = 11) visuEq(out2$models$model3, approx = 4) #Example 3 data("Ross76") tin <- Ross76[,1] data <- Ross76[,2:4] dev.new() out3 <- gPoMo(data, tin=tin, dMax = 2, nS=c(1,1,1), show = 1, IstepMin = 10, IstepMax = 3000, nPmin = 7, nPmax = 8) # the simplest model able to reproduce the observed dynamics is model #5 visuEq(out3$models$model5, approx = 3, substit = 1) # the original Rossler system is thus retrieved #Example 4 data("Ross76") tin <- Ross76[,1] data <- Ross76[,2:3] # model template: EqS <- matrix(1, ncol = 3, nrow = 10) EqS[,1] <- c(0,0,0,1,0,0,0,0,0,0) EqS[,2] <- c(1,1,0,1,0,1,1,1,1,1) EqS[,3] <- c(0,1,0,0,0,0,1,1,0,0) visuEq(EqS, substit = c('X','Y','Z')) dev.new() out4 <- gPoMo(data, tin=tin, dMax = 2, nS=c(2,1), show = 1, EqS = EqS, IstepMin = 10, IstepMax = 2000, nPmin = 9, nPmax = 11) visuEq(out4$models$model2, approx = 2, substit = c("Y","Y2","Z")) #Example 5 # load data data("TSallMod_nVar3_dMax2") #multiple (six) time series tin <- TSallMod_nVar3_dMax2$SprK$reconstr[1:400,1] TSRo76 <- TSallMod_nVar3_dMax2$R76$reconstr[,2:4] TSSprK <- TSallMod_nVar3_dMax2$SprK$reconstr[,2:4] data <- cbind(TSRo76,TSSprK)[1:400,] dev.new() # generalized Polynomial modelling out5 <- gPoMo(data, tin = tin, dMax = 2, nS = c(1,1,1,1,1,1), show = 0, method = 'rk4', IstepMin = 2, IstepMax = 3, nPmin = 13, nPmax = 13) # the original Rossler (variables x, y and z) and Sprott (variables u, v and w) # systems are retrieved: visuEq(out5$models$model347, approx = 4, substit = c('x', 'y', 'z', 'u', 'v', 'w')) # to check the robustness of the model, the integration duration # should be chosen longer (at least IstepMax = 4000)
Computes regressors coefficients using the Gram-Schmidt procedure.
GSproc(polyK, ivec, weight = NULL)
GSproc(polyK, ivec, weight = NULL)
polyK |
One list including |
ivec |
Defines i, the current vector of |
weight |
The weighing vector. |
uNew
The model parameterization, that is:
The residual orthogonal vector that can be included into
the current orthogonal base. If the current base is empty,
uNew
is equal to the input vector of $Y
;
if the base is complete, uNew
equals 0.
Sylvain Mangiarotti
A time series of 28 years of Normalized Difference Vegetation Index measured from space by the Advanced Very High Resolution Radiometer (AVHRR) sensor from 1982 to 2008 (see reference [1] for details).
NDVI
NDVI
An object of class data.frame
with 1000 rows and 4 columns.
Sylvain Mangiarotti, Flavie Le Jean
[1] Mangiarotti S., Drapeau L. & Letellier C., 2014.
Two chaotic models for cereal crops observed from satellite in
northern Morocco.
Function for the numerical integration of Ordinary Differential Equations of polynomial form.
numicano( nVar, dMax, dMin = 0, Istep = 1000, onestep = 1/125, KL = NULL, PolyTerms = NULL, v0 = NULL, method = "rk4" )
numicano( nVar, dMax, dMin = 0, Istep = 1000, onestep = 1/125, KL = NULL, PolyTerms = NULL, v0 = NULL, method = "rk4" )
nVar |
Number of variables considered in the polynomial formulation. |
dMax |
Maximum degree of the polynomial formulation. |
dMin |
The minimum negative degree of the polynomial formulation (0 by default). |
Istep |
The number of integration time steps |
onestep |
Time step length |
KL |
Matrix formulation of the model to integrate numerically |
PolyTerms |
Vectorial formulation of the model (only for models of canonical form) |
v0 |
The initial conditions (a vector which length should correspond
to the model dimension |
method |
The integration method (See package |
A list of two variables:
$KL
The model in its matrix formulation
$reconstr
The integrated trajectory (first column is the time,
next columns are the model variables)
Sylvain Mangiarotti
############# # Example 1 # ############# # For a model of general form (here the rossler model) # model dimension: nVar = 3 # maximal polynomial degree dMax = 2 # Number of parameter number (by default) pMax <- d2pMax(nVar, dMax) # convention used for the model formulation poLabs(nVar, dMax) # Definition of the Model Function a = 0.520 b = 2 c = 4 Eq1 <- c(0,-1, 0,-1, 0, 0, 0, 0, 0, 0) Eq2 <- c(0, 0, 0, a, 0, 0, 1, 0, 0, 0) Eq3 <- c(b,-c, 0, 0, 0, 0, 0, 1, 0, 0) K <- cbind(Eq1, Eq2, Eq3) # Edition of the equations visuEq(K, nVar, dMax) # initial conditions v0 <- c(-0.6, 0.6, 0.4) # model integration reconstr <- numicano(nVar, dMax, Istep=1000, onestep=1/50, KL=K, v0=v0, method="ode45") # Plot of the simulated time series obtained dev.new() plot(reconstr$reconstr[,2], reconstr$reconstr[,3], type='l', main='phase portrait', xlab='x(t)', ylab = 'y(t)') ############# # Example 2 # ############# # For a model of canonical form # model dimension: nVar = 4 # maximal polynomial degree dMax = 3 # Number of parameter number (by default) pMax <- d2pMax(nVar, dMax) # Definition of the Model Function PolyTerms <- c(281000, 0, 0, 0, -2275, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 861, 0, 0, 0, -878300, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) # terms used in the model poLabs(nVar, dMax, findIt=(PolyTerms!=0)) # initial conditions v0 <- c(0.54, 3.76, -90, -5200) # model integration reconstr <- numicano(nVar, dMax, Istep=500, onestep=1/250, PolyTerms=PolyTerms, v0=v0, method="ode45") # Plot of the simulated time series obtained plot(reconstr$reconstr[,2], reconstr$reconstr[,3], type='l', main='phase portrait', xlab='x', ylab = 'dx/dt') # Edition of the equations visuEq(reconstr$KL, nVar, dMax) ############# # Example 3 # ############# # For a model of general form (here the rossler model) # model dimension: nVar = 3 # maximal polynomial degree dMax = 2 dMin = -1 # Number of parameter number (by default) pMax <- regOrd(nVar, dMax, dMin)[2] # convention used for the model formulation poLabs(nVar, dMax, dMin) # Definition of the Model Function a = 0.520 b = 2 c = 4 Eq1 <- c(0,-1, 0,-1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0) Eq2 <- c(0, 0, 0, a, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0) Eq3 <- c(b,-c, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0) K <- cbind(Eq1, Eq2, Eq3) # Edition of the equations #visuEq(K, nVar, dMax) # initial conditions v0 <- c(-0.6, 0.6, 0.4) # model integration reconstr <- numicano(nVar, dMax, dMin, Istep=1000, onestep=1/50, KL=K, v0=v0, method="ode45") # Plot of the simulated time series obtained dev.new() plot(reconstr$reconstr[,2], reconstr$reconstr[,3], type='l', main='phase portrait', xlab='x(t)', ylab = 'y(t)')
############# # Example 1 # ############# # For a model of general form (here the rossler model) # model dimension: nVar = 3 # maximal polynomial degree dMax = 2 # Number of parameter number (by default) pMax <- d2pMax(nVar, dMax) # convention used for the model formulation poLabs(nVar, dMax) # Definition of the Model Function a = 0.520 b = 2 c = 4 Eq1 <- c(0,-1, 0,-1, 0, 0, 0, 0, 0, 0) Eq2 <- c(0, 0, 0, a, 0, 0, 1, 0, 0, 0) Eq3 <- c(b,-c, 0, 0, 0, 0, 0, 1, 0, 0) K <- cbind(Eq1, Eq2, Eq3) # Edition of the equations visuEq(K, nVar, dMax) # initial conditions v0 <- c(-0.6, 0.6, 0.4) # model integration reconstr <- numicano(nVar, dMax, Istep=1000, onestep=1/50, KL=K, v0=v0, method="ode45") # Plot of the simulated time series obtained dev.new() plot(reconstr$reconstr[,2], reconstr$reconstr[,3], type='l', main='phase portrait', xlab='x(t)', ylab = 'y(t)') ############# # Example 2 # ############# # For a model of canonical form # model dimension: nVar = 4 # maximal polynomial degree dMax = 3 # Number of parameter number (by default) pMax <- d2pMax(nVar, dMax) # Definition of the Model Function PolyTerms <- c(281000, 0, 0, 0, -2275, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 861, 0, 0, 0, -878300, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) # terms used in the model poLabs(nVar, dMax, findIt=(PolyTerms!=0)) # initial conditions v0 <- c(0.54, 3.76, -90, -5200) # model integration reconstr <- numicano(nVar, dMax, Istep=500, onestep=1/250, PolyTerms=PolyTerms, v0=v0, method="ode45") # Plot of the simulated time series obtained plot(reconstr$reconstr[,2], reconstr$reconstr[,3], type='l', main='phase portrait', xlab='x', ylab = 'dx/dt') # Edition of the equations visuEq(reconstr$KL, nVar, dMax) ############# # Example 3 # ############# # For a model of general form (here the rossler model) # model dimension: nVar = 3 # maximal polynomial degree dMax = 2 dMin = -1 # Number of parameter number (by default) pMax <- regOrd(nVar, dMax, dMin)[2] # convention used for the model formulation poLabs(nVar, dMax, dMin) # Definition of the Model Function a = 0.520 b = 2 c = 4 Eq1 <- c(0,-1, 0,-1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0) Eq2 <- c(0, 0, 0, a, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0) Eq3 <- c(b,-c, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0) K <- cbind(Eq1, Eq2, Eq3) # Edition of the equations #visuEq(K, nVar, dMax) # initial conditions v0 <- c(-0.6, 0.6, 0.4) # model integration reconstr <- numicano(nVar, dMax, dMin, Istep=1000, onestep=1/50, KL=K, v0=v0, method="ode45") # Plot of the simulated time series obtained dev.new() plot(reconstr$reconstr[,2], reconstr$reconstr[,3], type='l', main='phase portrait', xlab='x(t)', ylab = 'y(t)')
Function for the numerical integration of Ordinary Differential Equations of polynomial form including single or Multiple external forcing
numiMultiX( nVar, dMax, Istep = 1000, onestep = 1/125, KDf, extF = extF, v0 = NULL, method = "rk4" )
numiMultiX( nVar, dMax, Istep = 1000, onestep = 1/125, KDf, extF = extF, v0 = NULL, method = "rk4" )
nVar |
Number of variables considered in the polynomial formulation. |
dMax |
Maximum degree of the polynomial formulation. |
Istep |
The number of integration time steps. By default, Istep = 1000 |
onestep |
The time step to be used for numerical integration |
KDf |
The nonautonomous model in its matrix formulation, NA (i.e. not available) values should be provided for forcing variables provided as an external signal |
extF |
A matrix providing the time vector in the first column, and time series of each forcing in the next ones |
v0 |
The initial conditions. Its length should be in agreement with the dynamical system dimension. Therefore, 0 or NA can be provided for external forcing |
method |
integration method. By default 'rk4' is used |
A list of two variables:
$KDf
The nonautonomous model in its matrix formulation
$reconstr
The integrated trajectory (first column is the time,
next columns are the model variables)
Sylvain Mangiarotti
derivODE2
, numicano
, numinoisy
############# # Example 1 # ############# # build a non autonomous model nVar = 4 dMax = 3 gamma = 0.05 KDf=matrix(0, nrow = d2pMax(nVar = nVar, dMax = dMax), ncol = nVar) KDf[11,1] = 1 KDf[2,2] = 1 KDf[5,2] = 1 KDf[11,2] = -gamma KDf[35,2] = -1 KDf[2,3] = NA KDf[2,4] = NA visuEq(K = KDf, substit = c('x', 'y', 'u', 'v')) # build an external forcing # number of integration time step Istep <- 500 # time step smpl <- 1 / 20 # output time vector tvec <- (0:(Istep-1)) * smpl # angular frequency (for periodic forcing) omega = 0.2 # half step time vector (for Runge-Kutta integration) tvecX <- (0:(Istep*2-2)) * smpl / 2 # generate the forcing (here variables u and v) extF = cbind(tvecX, -0.1 * cos(tvecX * omega), 0.05 * cos(tvecX * 16/3*omega)) # decimate the data extFrs <- extF[seq(1,dim(extF)[1],by=50),] extFrs <- rbind(extFrs,extF[dim(extF)[1],]) # Initial conditions to be used (external variables can be set to 0) etatInit <- c(-0.616109362 , -0.126882584 , NA, NA) # model integration out <- numiMultiX(nVar, dMax, Istep=Istep, onestep=smpl, KDf=KDf, extF, v0=etatInit, method="rk4") outrs <- numiMultiX(nVar, dMax, Istep=Istep, onestep=smpl, KDf=KDf, extFrs, v0=etatInit, method="rk4") dev.new oldpar <- par(no.readonly = TRUE) on.exit(par(oldpar)) par(mfrow = c(2, 2), # 2 x 2 pictures on one plot pty = "s") plot(out$reconstr[,2],out$reconstr[,3], xlab = 'x(t)', ylab = 'y(t)', type = 'l', col = 'red') lines(outrs$reconstr[,2],outrs$reconstr[,3], xlab = 'x(t)', ylab = 'y(t)', type = 'l', col = 'green') plot(out$reconstr[,2],out$reconstr[,4], xlab = 'x(t)', ylab = 'u(t)', type = 'l', col = 'red') plot(out$reconstr[,4],out$reconstr[,5], xlab = 'u(t)', ylab = 'v(t)', type = 'l', col = 'red')
############# # Example 1 # ############# # build a non autonomous model nVar = 4 dMax = 3 gamma = 0.05 KDf=matrix(0, nrow = d2pMax(nVar = nVar, dMax = dMax), ncol = nVar) KDf[11,1] = 1 KDf[2,2] = 1 KDf[5,2] = 1 KDf[11,2] = -gamma KDf[35,2] = -1 KDf[2,3] = NA KDf[2,4] = NA visuEq(K = KDf, substit = c('x', 'y', 'u', 'v')) # build an external forcing # number of integration time step Istep <- 500 # time step smpl <- 1 / 20 # output time vector tvec <- (0:(Istep-1)) * smpl # angular frequency (for periodic forcing) omega = 0.2 # half step time vector (for Runge-Kutta integration) tvecX <- (0:(Istep*2-2)) * smpl / 2 # generate the forcing (here variables u and v) extF = cbind(tvecX, -0.1 * cos(tvecX * omega), 0.05 * cos(tvecX * 16/3*omega)) # decimate the data extFrs <- extF[seq(1,dim(extF)[1],by=50),] extFrs <- rbind(extFrs,extF[dim(extF)[1],]) # Initial conditions to be used (external variables can be set to 0) etatInit <- c(-0.616109362 , -0.126882584 , NA, NA) # model integration out <- numiMultiX(nVar, dMax, Istep=Istep, onestep=smpl, KDf=KDf, extF, v0=etatInit, method="rk4") outrs <- numiMultiX(nVar, dMax, Istep=Istep, onestep=smpl, KDf=KDf, extFrs, v0=etatInit, method="rk4") dev.new oldpar <- par(no.readonly = TRUE) on.exit(par(oldpar)) par(mfrow = c(2, 2), # 2 x 2 pictures on one plot pty = "s") plot(out$reconstr[,2],out$reconstr[,3], xlab = 'x(t)', ylab = 'y(t)', type = 'l', col = 'red') lines(outrs$reconstr[,2],outrs$reconstr[,3], xlab = 'x(t)', ylab = 'y(t)', type = 'l', col = 'green') plot(out$reconstr[,2],out$reconstr[,4], xlab = 'x(t)', ylab = 'u(t)', type = 'l', col = 'red') plot(out$reconstr[,4],out$reconstr[,5], xlab = 'u(t)', ylab = 'v(t)', type = 'l', col = 'red')
Generates time series from Ordinary Differential Equations perturbed by dynamical and/or measurement noises
numinoisy( x0, t, K, varData = NULL, txVarBruitA = NULL, txVarBruitM = NULL, varBruitA = NULL, varBruitM = NULL, taux = NULL, freq = NULL, variables = NULL, method = NULL )
numinoisy( x0, t, K, varData = NULL, txVarBruitA = NULL, txVarBruitM = NULL, varBruitA = NULL, varBruitM = NULL, taux = NULL, freq = NULL, variables = NULL, method = NULL )
x0 |
The initial conditions. Should be a vector which size must be equal
to the model dimension |
t |
A vector providing all the dates for which the output are expected. |
K |
The Ordinary Differential Equations used to model the dynamics.
The number of column should correspond to the number of variables, the
number of lines to the number of parameters following the convention
defined by |
varData |
A vector of size |
txVarBruitA |
A vector defining the ratio of ADDITIVE noise for each variable of the dynamical system in ODE. The additive noise is added at the end of the numerical integration process. The ratio is defined relatively to the signal variance of each variable. |
txVarBruitM |
A vector defining the ratio of DYNAMICAL noise for each variable of the dynamical system in ODE. This noise is a perturbation added at each numerical integration step. The ratio is defined relatively to the signal variance of each variable. |
varBruitA |
A vector defining the variance of ADDITIVE noise for each variable of the dynamical system in ODE. The additive noise is added at the end of the numerical integration process. |
varBruitM |
A vector defining the variance of DYNAMICAL noise for each variable of the dynamical system in ODE. This noise is a perturbation added at each numerical integration step. |
taux |
Generates random gaps in time series. Parameter |
freq |
Subsamples the time series. Parameter |
variables |
Defines which variables must be generated. |
method |
Defines the numerical integration method to be used.
The fourth-order Runge-Kutta method is used by default
( |
A list of two variables:
$donnees
The integrated trajectory (first column is the time,
next columns are the model variables)
$bruitM
The level of dynamical noise
$bruitA
The level of additive noise
$vectBruitM
The vector of the dynamical noise used to produce
the time series
$vectBruitA
The vector of the additive noise used to produce
the time series
$ecart_type
The level standard deviation
Sylvain Mangiarotti, Malika Chassan
############# # Example 1 # ############# # Rossler Model formulation # The model dimension nVar = 3 # maximal polynomial degree dMax = 2 a = 0.520 b = 2 c = 4 Eq1 <- c(0,-1, 0,-1, 0, 0, 0, 0, 0, 0) Eq2 <- c(0, 0, 0, a, 0, 0, 1, 0, 0, 0) Eq3 <- c(b,-c, 0, 0, 0, 0, 0, 1, 0, 0) K <- cbind(Eq1, Eq2, Eq3) # Edit the equations visuEq(K, nVar, dMax) # initial conditions v0 <- c(-0.6, 0.6, 0.4) # output time required timeOut = (0:800)/50 # variance of additive noise varBruitA = c(0,0,0)^2 # variance of multiplitive noise varBruitM = c(2E-2, 0, 2E-2)^2 # numerical integration with noise intgr <- numinoisy(v0, timeOut, K, varBruitA = varBruitA, varBruitM = varBruitM, freq = 1) # Plot of the simulated time series obtained dev.new() plot(intgr$donnees[,2], intgr$donnees[,3], type='l', main='phase portrait', xlab='x(t)', ylab = 'y(t)') dev.new() oldpar <- par(no.readonly = TRUE) on.exit(par(oldpar)) par(mfrow = c(3, 1)) plot(intgr$donnees[,1], intgr$donnees[,2], type='l', main='phase portrait', xlab='x(t)', ylab = 'y(t)') lines(intgr$donnees[,1], intgr$vectBruitM[,2]*10, type='l', main='phase portrait', xlab='x(t)', ylab = 'e(t)*10', col='red') plot(intgr$donnees[,1], intgr$donnees[,3], type='l', main='phase portrait', xlab='x(t)', ylab = 'y(t)') lines(intgr$donnees[,1], intgr$vectBruitM[,3]*10, type='l', main='phase portrait', xlab='x(t)', ylab = 'e(t)*10', col='red') plot(intgr$donnees[,1], intgr$donnees[,4], type='l', main='phase portrait', xlab='x(t)', ylab = 'y(t)') lines(intgr$donnees[,1], intgr$vectBruitM[,4]*10, type='l', main='phase portrait', xlab='x(t)', ylab = 'e(t)*10', col='red')
############# # Example 1 # ############# # Rossler Model formulation # The model dimension nVar = 3 # maximal polynomial degree dMax = 2 a = 0.520 b = 2 c = 4 Eq1 <- c(0,-1, 0,-1, 0, 0, 0, 0, 0, 0) Eq2 <- c(0, 0, 0, a, 0, 0, 1, 0, 0, 0) Eq3 <- c(b,-c, 0, 0, 0, 0, 0, 1, 0, 0) K <- cbind(Eq1, Eq2, Eq3) # Edit the equations visuEq(K, nVar, dMax) # initial conditions v0 <- c(-0.6, 0.6, 0.4) # output time required timeOut = (0:800)/50 # variance of additive noise varBruitA = c(0,0,0)^2 # variance of multiplitive noise varBruitM = c(2E-2, 0, 2E-2)^2 # numerical integration with noise intgr <- numinoisy(v0, timeOut, K, varBruitA = varBruitA, varBruitM = varBruitM, freq = 1) # Plot of the simulated time series obtained dev.new() plot(intgr$donnees[,2], intgr$donnees[,3], type='l', main='phase portrait', xlab='x(t)', ylab = 'y(t)') dev.new() oldpar <- par(no.readonly = TRUE) on.exit(par(oldpar)) par(mfrow = c(3, 1)) plot(intgr$donnees[,1], intgr$donnees[,2], type='l', main='phase portrait', xlab='x(t)', ylab = 'y(t)') lines(intgr$donnees[,1], intgr$vectBruitM[,2]*10, type='l', main='phase portrait', xlab='x(t)', ylab = 'e(t)*10', col='red') plot(intgr$donnees[,1], intgr$donnees[,3], type='l', main='phase portrait', xlab='x(t)', ylab = 'y(t)') lines(intgr$donnees[,1], intgr$vectBruitM[,3]*10, type='l', main='phase portrait', xlab='x(t)', ylab = 'e(t)*10', col='red') plot(intgr$donnees[,1], intgr$donnees[,4], type='l', main='phase portrait', xlab='x(t)', ylab = 'y(t)') lines(intgr$donnees[,1], intgr$vectBruitM[,4]*10, type='l', main='phase portrait', xlab='x(t)', ylab = 'e(t)*10', col='red')
A subfunction for the numerical integration of Ordinary
Differential Equations provided in a generic polynomial form.
Model formulation follows the convention defined
by function poLabs
.
odeBruitMult2( x0, t, K, varData = NULL, txVarBruitM = NULL, varBruitM = NULL, method = NULL )
odeBruitMult2( x0, t, K, varData = NULL, txVarBruitM = NULL, varBruitM = NULL, method = NULL )
x0 |
Initial conditions |
t |
All the dates for which the result of the numerical integration of the model must be provided |
K |
A matrix providing the model description:
each column corresponds to one equation which polynomial organisation
is following the convention defined by function |
varData |
A vector of size |
txVarBruitM |
A vector defining the ratio of DYNAMICAL noise for each variable of the dynamical system in ODE. This noise is a perturbation added at each numerical integration step. The ratio is defined relatively to the signal variance of each variable. |
varBruitM |
A vector defining the variance of DYNAMICAL noise for each variable of the dynamical system in ODE. This noise is a perturbation added at each numerical integration step. |
method |
Numerical method used in the integration process.
(see |
Sylvain Mangiarotti, Malika Chassan
A matrix of 6 columns corresponding to six time series, two resulting from a Period-1 limit cycle, two from regime converging to fixed point, and two relating to a chaotic behavior
P1FxCh
P1FxCh
An object of class matrix
(inherits from array
) with 1000 rows and 6 columns.
Sylvain Mangiarotti, Mireille Huc.
Trajectories for testing periodicity. The following regimes are made available: Period-1 in columns 1:2, Fixed Point in 3:4, chaotic in 5:6, Period-2 in 7:8
P1FxChP2
P1FxChP2
An object of class matrix
(inherits from array
) with 1000 rows and 8 columns.
Sylvain Mangiarotti, Mireille Huc.
dMax
given the number of variables nVar
and the number of possible
polynomial terms pMax
.Find the maximum polynomial degree dMax
given the number of polynomial terms pMax
and the system dimension nVar
.
p2dMax(nVar, pMaxKnown, dMin = 0)
p2dMax(nVar, pMaxKnown, dMin = 0)
nVar |
Number of variables considered in the polynomial formulation. |
pMaxKnown |
The number of polynomial terms |
dMin |
The minimum negative degree of the polynomial formulation (0 by default). |
dMax
The maximum polynomial degree
Sylvain Mangiarotti, Laurent Drapeau
############# # Example 1 # ############# # Maximum polynomial degree ? # number of variables: nVar <- 3 # size of the polynomial vector: pMax <- 10 # The maximal polynomial degree used for coding the polynomial is: p2dMax(nVar,pMax) ############# # Example 2 # ############# # for pMax = 462 and nVar = 6, then dMax is: p2dMax(6,462) # indeed: length(poLabs(nVar=6, dMax=5))
############# # Example 1 # ############# # Maximum polynomial degree ? # number of variables: nVar <- 3 # size of the polynomial vector: pMax <- 10 # The maximal polynomial degree used for coding the polynomial is: p2dMax(nVar,pMax) ############# # Example 2 # ############# # for pMax = 462 and nVar = 6, then dMax is: p2dMax(6,462) # indeed: length(poLabs(nVar=6, dMax=5))
Estimate the polynomial coefficients.
paramId(allForK, drv, weight)
paramId(allForK, drv, weight)
allForK |
The list of input parameters |
drv |
The derivative (on the equation left hand) |
weight |
The weighting series |
allForK
The initial list completed with the model parameters.
Sylvain Mangiarotti
Defines the order of the polynomial labels given
the number of variables nVar
and the maximum polynomial
degree dMax
.
poLabs(nVar, dMax, dMin = 0, findIt = NULL, Xnote = "X")
poLabs(nVar, dMax, dMin = 0, findIt = NULL, Xnote = "X")
nVar |
The number of variables |
dMax |
The maximum degree allowed in the formulation |
dMin |
The minimum negative degree of the polynomial formulation (0 by default). |
findIt |
A vector of selected terms. |
Xnote |
Enables to defines the notation used for the variable,
by default |
lbls
A vector of characters. Each element is the
expression of one polynomial term, such as
Sylvain Mangiarotti
#Regressor order for three variables \eqn{(X1,X2,X3)} (nVar = 3) for a maximum #polynomial degree equal to 2 (dMax = 2): poLabs(3,2) #and for two variables only : poLabs(2,2) # For a quadratic equation of two variables, # the polynomial \deqn{P(X1,X2) = 0.5 + 0.3 X1 -0.25 X1 X2} # could thus be written as a vector Pvec such as: Pvec = c(0.5, 0, 0, 0.3, -0.25, 0) # considering the convention corresponding to poLabs(2,2) # Indeed: poLabs(2, 2, findIt = Pvec!=0) # An alternative notation can be used with parameter Xnote poLabs(2, 2, findIt = Pvec!=0, Xnote = 'w') # or also poLabs(2, 2, findIt = Pvec!=0, Xnote = c('x','y'))
#Regressor order for three variables \eqn{(X1,X2,X3)} (nVar = 3) for a maximum #polynomial degree equal to 2 (dMax = 2): poLabs(3,2) #and for two variables only : poLabs(2,2) # For a quadratic equation of two variables, # the polynomial \deqn{P(X1,X2) = 0.5 + 0.3 X1 -0.25 X1 X2} # could thus be written as a vector Pvec such as: Pvec = c(0.5, 0, 0, 0.3, -0.25, 0) # considering the convention corresponding to poLabs(2,2) # Indeed: poLabs(2, 2, findIt = Pvec!=0) # An alternative notation can be used with parameter Xnote poLabs(2, 2, findIt = Pvec!=0, Xnote = 'w') # or also poLabs(2, 2, findIt = Pvec!=0, Xnote = c('x','y'))
GPoMo
in term of predictabilityThe algorithm aims to estimate automatically the forecasting
performances of the models obtained with gPoMo
.
predictab( ogp, fullt = NULL, fulldata = NULL, hp = NULL, Nech = 50, intSimStep = NULL, show = 1, selecmod = NULL, id = 1, selV = 1, na.rm = FALSE )
predictab( ogp, fullt = NULL, fulldata = NULL, hp = NULL, Nech = 50, intSimStep = NULL, show = 1, selecmod = NULL, id = 1, selV = 1, na.rm = FALSE )
ogp |
The output list obtained from function |
fullt |
Time vector of the data set for which predictability will be tested |
fulldata |
Data set for which predictability will be tested |
hp |
Time vector of the horizon of prediction |
Nech |
Number of simulations |
intSimStep |
Internal number of simulation steps |
show |
Provide (2) or not (0-1) visual output during the running process. |
selecmod |
A vector of the model selected. |
id |
The type of model to identify. |
selV |
Selected variable for the analysis |
na.rm |
Indicates if the |
ErrmodAll
A list of matrix $Predmod1
,
$Predmod2
, etc. and $Errmod1
, $Errmod2
, etc.
providing respectively the forecasting and the forecasting error
of models 1, 2, etc.
Each column corresponds to one simulation starting from
a specific initial condition. Each line corresponds to
one horizon of prediction.
Vectors corresponding to the initial condition time tE
and the horizon of prediction hpE
are also provided
in $tE
and $hpE
, respectively.
The percentiles of the distributions of error growth
are provided in qt
(0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95)
and of absolute error growth in qt2
(0.5, 0.75, 0.9, 0.95, 0.98, 0.99).
Sylvain Mangiarotti, Mireille Huc
# load data data("Ross76") # time vector tin <- Ross76[seq(1, 3000, by = 8), 1] # single time series data <- Ross76[seq(1, 3000, by = 8), 3] # dev.new() # plot(tin, data, xlab = 'time', ylab = 'y(t)') # global modelling # results are put in list outputGPoM outputGPoM <- gPoMo(data[1:300], tin = tin[1:300], dMax = 2, nS=c(3), show = 0, method = 'rk4', nPmin = 10, nPmax = 12, IstepMin = 150, IstepMax = 151) # visuOutGP(outputGPoM) ########################### # and test predictability # ########################### outpred <- predictab(outputGPoM, hp = 15, Nech = 30) # manual visualisation of the outputs (e.g. for model 1): dev.new() image(outpred$tE, outpred$hpE, t(outpred$Errmod1), xlab = 't', ylab = 'hp', main = 'Errmod1')
# load data data("Ross76") # time vector tin <- Ross76[seq(1, 3000, by = 8), 1] # single time series data <- Ross76[seq(1, 3000, by = 8), 3] # dev.new() # plot(tin, data, xlab = 'time', ylab = 'y(t)') # global modelling # results are put in list outputGPoM outputGPoM <- gPoMo(data[1:300], tin = tin[1:300], dMax = 2, nS=c(3), show = 0, method = 'rk4', nPmin = 10, nPmax = 12, IstepMin = 150, IstepMax = 151) # visuOutGP(outputGPoM) ########################### # and test predictability # ########################### outpred <- predictab(outputGPoM, hp = 15, Nech = 30) # manual visualisation of the outputs (e.g. for model 1): dev.new() image(outpred$tE, outpred$hpE, t(outpred$Errmod1), xlab = 't', ylab = 'hp', main = 'Errmod1')
Estimate the parameters variations of a model of canonical form considering a sliding window on an external dataset.
pTimEv( TS, nVar, dMax, TSdate, whatTerms = NULL, weight = NULL, wlength = 1000, onestep = 100, removeExtr = 1 )
pTimEv( TS, nVar, dMax, TSdate, whatTerms = NULL, weight = NULL, wlength = 1000, onestep = 100, removeExtr = 1 )
TS |
The time series to be tested |
nVar |
Number of variables considered in the polynomial formulation. |
dMax |
Maximum degree of the polynomial formulation. |
TSdate |
The time vector |
whatTerms |
The terms to be considered in the analysis. Note that these are organised following the convention defined by poLabs(nVar,dMax). Since only the structure is required, if coefficients are provided, these are transformed to 1. |
weight |
A vector providing the binary weighting function of the input data series (0 or 1). By default, all the values are set to 1. |
wlength |
The window length |
onestep |
Step length between two estimations |
removeExtr |
Ratio of estimated values to be removed (if chosen equal to 0.1, only 90 disersion will be kept) |
A list containing:
$slidingoutGM
An n*(pMax+1) matrix presenting
the pMax estimated parameters p1(t), p2(t) etc. column by column.
The residual signal epsilon(t) is provided in the last (i.e. pMax + 1)
column. Each line correspond to one date provided in $TSdate
$TSdate
A time vector relating to the estimates
presented in $slidingoutGM
$W
A vector providing the output values that
can kept (=1) or must be removed (=0)
$whatTerms
A vector recalling the terms
taken into account in the analysis (their order refers
to poLabs(nVar,dMax)
function)
$param
A vector with the parameter values
used to apply the function: nVar, dMax, wlength, onestep,
removeExtr
Sylvain Mangiarotti
autoGPoMoSearch
, gPoMo
, poLabs
#Example data(TS) plot(TS[,1], TS[,2], type='l') nVar <- 3 dMax <- 2 pMax <- choose(nVar+dMax,dMax) whatTerms <- c(1,1,0,1,1,1,1,1,1,1) # apply pTimEv statio <- pTimEv(TS[,2], nVar, dMax, TS[,1], whatTerms = whatTerms, wlength = 1000, onestep = 20, removeExtr = 0.15) # Plot the results dev.new() layout(matrix(1:12, nrow=4, ncol=3, byrow = TRUE)) what <- which(statio$whatTerms!=0) for (i in what) { plot(statio$TSdate[statio$W==1], statio$slidingoutGM[statio$W==1,i], xlab='TSdate', ylab='coeff', main=poLabs(nVar,dMax)[i]) } plot(statio$TSdate[statio$W==1], statio$slidingoutGM[statio$W==1,pMax+1], xlab='date', ylab='Epsilon', main='Resid', log = 'y')
#Example data(TS) plot(TS[,1], TS[,2], type='l') nVar <- 3 dMax <- 2 pMax <- choose(nVar+dMax,dMax) whatTerms <- c(1,1,0,1,1,1,1,1,1,1) # apply pTimEv statio <- pTimEv(TS[,2], nVar, dMax, TS[,1], whatTerms = whatTerms, wlength = 1000, onestep = 20, removeExtr = 0.15) # Plot the results dev.new() layout(matrix(1:12, nrow=4, ncol=3, byrow = TRUE)) what <- which(statio$whatTerms!=0) for (i in what) { plot(statio$TSdate[statio$W==1], statio$slidingoutGM[statio$W==1,i], xlab='TSdate', ylab='coeff', main=poLabs(nVar,dMax)[i]) } plot(statio$TSdate[statio$W==1], statio$slidingoutGM[statio$W==1,pMax+1], xlab='date', ylab='Epsilon', main='Resid', log = 'y')
Generate the conventional order of the polynomial
terms for the polynomial description.
It is formulated as a matrix of exponents: Each
column of the matrix (a,b,c, ...) corresponds to a product
of the nVar
available variables X1, X2, X3, etc.,
that is, , etc.
regOrd(nVar, dMax, dMin = 0)
regOrd(nVar, dMax, dMin = 0)
nVar |
The number of variables |
dMax |
The maximum degree allowed in the formulation |
dMin |
The minimum negative degree of the polynomial formulation (0 by default). |
A matrix of exponents. Each column corresponds to one
polynomial term. Each line correspond to the exponent of one
variable.
For example, a column of three exponents (0,2,1)
corresponds
to the monomial X1^0 * X2^2 * X3^1
, that is .
Sylvain Mangiarotti
Creates time series by multiplying given time series among them.
regSeries(nVar, dMax, series, dMin = 0, pReg = NULL)
regSeries(nVar, dMax, series, dMin = 0, pReg = NULL)
nVar |
Number of variables considered in the polynomial formulation. |
dMax |
Maximum degree of the polynomial formulation. |
series |
A matrix containing the original time series from which the monomials are built. Each column corresponds to one given variable. |
dMin |
The minimum negative degree of the polynomial formulation (0 by default). |
pReg |
A matrix filled, for each column, with powers of time series used to create. |
rpFull
A matrix of time series. Each column corresponds to one
regressor such as
Sylvain Mangiarotti
data(TSallMod_nVar3_dMax2) sprottK <- as.matrix(TSallMod_nVar3_dMax2$SprK$reconstr)[,2:4] dMax <- 2 nVar <- dim(sprottK)[2] #Example 1 polySeries1 <- regSeries(nVar, dMax, sprottK) #Example 2 p <- c(1,3,1) polySeries2 <- regSeries(nVar, dMax, sprottK, pReg=p)
data(TSallMod_nVar3_dMax2) sprottK <- as.matrix(TSallMod_nVar3_dMax2$SprK$reconstr)[,2:4] dMax <- 2 nVar <- dim(sprottK)[2] #Example 1 polySeries1 <- regSeries(nVar, dMax, sprottK) #Example 2 p <- c(1,3,1) polySeries2 <- regSeries(nVar, dMax, sprottK, pReg=p)
The Rössler system is the 3-dimensional chaotic system
,
discovered by Otto E. Rössler in 1976 [1].
The following parameters and initial conditions
were used to produce the present data set:
a = 0.520, b = 2, c = 4
and (x0, y0, z0) = (-0.04298734, 1.025536, 0.09057987).
The following four columns are provided:
(1) time t, (2) x(t), (3) y(t) and (4) z(t).
For this parameterization, the Rössler system produces
a chaotic behavior characterized by a regime
non-coherent in phase (oscillations duration can be
very different from one oscillation to another).
Ross76
Ross76
An object of class deSolve
(inherits from matrix
) with 4000 rows and 4 columns.
Sylvain Mangiarotti, Flavie Le Jean, Malika Chassan, Laurent Drapeau, Mireille Huc.
[1] O. Rössler, 1976. An Equation for Continuous Chaos,
Physics Letters, 71A, 2-3, 155-157.
)Twelve independant Rossler-1976 time series (variable y). The parameters used to generate the time series correspond to a phase coherent behavior. Details can be found in [1]
RosYco
RosYco
An object of class matrix
(inherits from array
) with 3000 rows and 12 columns.
Another set of time series of the Rossler-1976 chaotic system
Sylvain Mangiarotti, Flavie Le Jean.
[1] Mangiarotti S., Le Jean F., Huc M. & Letellier C., Global Modeling of aggregated and associated chaotic dynamics. Chaos, Solitons and Fractals, 83, 82-96.
Detect, disentangle and reformulate Sub-systems from an ensemble of equations.
subSysD(inK, inXnote = NULL)
subSysD(inK, inXnote = NULL)
inK |
A list of models, each provided as a matrix. A single matrix can also be provided, it will be transformed into a list containing a single matrix. |
inXnote |
A vector with the names of the input variables. If not provided, default notation is used: "X1", "X2", etc. |
subS A matrix with the extracted subsystem
Sylvain Mangiarotti
# Load models data("allMod_nVar3_dMax2") # Display equations of system 1 visuEq(nVar = 3, dMax = 2, K = allMod_nVar3_dMax2$NH86, substit = 1) # Display equations of system 2 visuEq(nVar = 3, dMax = 2, K = allMod_nVar3_dMax2$R76, substit = 1) # put the two systems in a list allK <- list() allK[[1]] <- allMod_nVar3_dMax2$NH86 allK[[2]] <- allMod_nVar3_dMax2$R76 # Example 1 (two independant subsystems) # take two separate systems and mix them inXnote = list() inXnote[[1]] <- c('u', 'v', 'w') inXnote[[2]] <- c('X', 'Y', 'Z') visuEq(K = allK[[1]], substit = inXnote[[1]]) visuEq(K = allK[[2]], substit = inXnote[[2]]) XnoteOut = c('u', 'X', 'v', 'Y', 'w', 'Z') Knew3 <- combiEq(allK,dMaxOut = 3, eqOrder = c(1,4,2,5,3,6)) visuEq(K = Knew3, substit = XnoteOut) # Disentangle the subsystems from the mixed equations dstgl <- subSysD(Knew3, inXnote = XnoteOut) ## Optional # library(igraph) # g1<-graph.adjacency(dstgl$FM); # l <- layout_with_fr(g1) # plot(g1, edge.arrow.siez = .4, edge.curved=.4, vertex.label=XnoteOut, layout = l) # Example 2 (one subsystem included in the other) Kduff <- matrix(0, ncol = 4, nrow = 35) Kduff[11,1] <- Kduff[5,2] <- Kduff[2,3] <- 1 Kduff[35,2] <- -1 Kduff[11,2] <- -0.05 Kduff[5,4] <- 2 * acos(-1) / 6.2 Xnote <- c("x", "y", "u", "v") visuEq(Kduff, substit = Xnote) dstgl2 <- subSysD(Kduff, inXnote = Xnote)
# Load models data("allMod_nVar3_dMax2") # Display equations of system 1 visuEq(nVar = 3, dMax = 2, K = allMod_nVar3_dMax2$NH86, substit = 1) # Display equations of system 2 visuEq(nVar = 3, dMax = 2, K = allMod_nVar3_dMax2$R76, substit = 1) # put the two systems in a list allK <- list() allK[[1]] <- allMod_nVar3_dMax2$NH86 allK[[2]] <- allMod_nVar3_dMax2$R76 # Example 1 (two independant subsystems) # take two separate systems and mix them inXnote = list() inXnote[[1]] <- c('u', 'v', 'w') inXnote[[2]] <- c('X', 'Y', 'Z') visuEq(K = allK[[1]], substit = inXnote[[1]]) visuEq(K = allK[[2]], substit = inXnote[[2]]) XnoteOut = c('u', 'X', 'v', 'Y', 'w', 'Z') Knew3 <- combiEq(allK,dMaxOut = 3, eqOrder = c(1,4,2,5,3,6)) visuEq(K = Knew3, substit = XnoteOut) # Disentangle the subsystems from the mixed equations dstgl <- subSysD(Knew3, inXnote = XnoteOut) ## Optional # library(igraph) # g1<-graph.adjacency(dstgl$FM); # l <- layout_with_fr(g1) # plot(g1, edge.arrow.siez = .4, edge.curved=.4, vertex.label=XnoteOut, layout = l) # Example 2 (one subsystem included in the other) Kduff <- matrix(0, ncol = 4, nrow = 35) Kduff[11,1] <- Kduff[5,2] <- Kduff[2,3] <- 1 Kduff[35,2] <- -1 Kduff[11,2] <- -0.05 Kduff[5,4] <- 2 * acos(-1) / 6.2 Xnote <- c("x", "y", "u", "v") visuEq(Kduff, substit = Xnote) dstgl2 <- subSysD(Kduff, inXnote = Xnote)
This data set aims to test the global modelling technique when several time series of different sizes are available. Four time series are provided, all derived from the Rössler-1976 system.
svrlTS
svrlTS
An object of class list
of length 4.
Sylvain Mangiarotti, Mireille Huc.
S. Mangiarotti, F. Le Jean, M. Huc & C. Letellier, 2016. Global modeling of aggregated and associated chaotic dynamics, Chaos, Solitons & Fractals, 83, 82-96.
Tests if a trajectory is periodic.
testP(data, wthresh = 0.1, fxPtThresh = 1e-04, show = 0)
testP(data, wthresh = 0.1, fxPtThresh = 1e-04, show = 0)
data |
Input Time series: Each column is one time series that corresponds to one variable. |
wthresh |
Threshold used to detect the limit cycle. |
fxPtThresh |
Threshold used to detect fixed points. |
show |
Provide (2) or not (0-1) visual output during the running process. |
periodic
An integer classifying the models:
diverging or unclassified trajectory (0),
period-1 trajectory (-1), period-2 trajectory (-2)
and fixed Point (2).
Sylvain Mangiarotti, Flavie Le Jean
#Example # Load data: data('P1FxChP2') # Test a period-1 trajectory testP(P1FxChP2[,1:2], wthresh=0.1, fxPtThresh = 1e-6, show=0) # Test a Fixed Point trajectory testP(P1FxChP2[,3:4], wthresh=0.1, fxPtThresh = 1e-6, show=0) # Test a chaotic trajectory testP(P1FxChP2[,5:6], wthresh=0.1, fxPtThresh = 1e-6, show=0) # Test a period-2 trajectory testP(P1FxChP2[,7:8], wthresh=0.1, fxPtThresh = 1e-6, show=0)
#Example # Load data: data('P1FxChP2') # Test a period-1 trajectory testP(P1FxChP2[,1:2], wthresh=0.1, fxPtThresh = 1e-6, show=0) # Test a Fixed Point trajectory testP(P1FxChP2[,3:4], wthresh=0.1, fxPtThresh = 1e-6, show=0) # Test a chaotic trajectory testP(P1FxChP2[,5:6], wthresh=0.1, fxPtThresh = 1e-6, show=0) # Test a period-2 trajectory testP(P1FxChP2[,7:8], wthresh=0.1, fxPtThresh = 1e-6, show=0)
A 2*6001 matrix with the time vector in column one and a time series resulting from the integration of a non stationary Rössler system – parameter a varying in time: a(t) – in colmn two.
TS
TS
An object of class matrix
(inherits from array
) with 6001 rows and 2 columns.
Sylvain Mangiarotti, Mireille Huc.
VII_Retro-Modelling
)A list of matrix providing the time series
in a list named TSallMod_nVar3_dMax2
of eighteen
three-dimensional chaotic systems:
Lorenz-1963 ($L63), Rössler-1976 ($R76), Burke & shaw 1981 ($BS81),
Lorenz-1984 ($L84), Nosé & Hooer 1986 ($NH86), Genesio & Tosi 1992 ($GT92),
Spott systems 1994 ($SprF, $SprH, $SprK, $SprO, $SprP, $SprG,
$SprM, $SprQ, $SprS),
Chlouverakis & Sprott 2004 ($CS2004), Li 2007 ($Li2007)
and the Cord system by Aguirre & Letellier 2012 ($Cord2012).
Time series are provided in a matrix in which
each column corresponds to one variable of the dynamical systems.
TSallMod_nVar3_dMax2
TSallMod_nVar3_dMax2
An object of class list
of length 18.
Sylvain Mangiarotti, Mireille Huc.
References for the systems are provided in vignette 'VII_retro-modelling'.
Displays the model equations for a polynomial model
which description is provided as a matrix K
, each column
corresponding to one equation. The coefficients of the polynomial
terms are given following the order defined by function poLabs
.
The matrix can also be provided in a list K
,
in this case, the matrix should be located in K$model[[selecmod]]
where selecmod should be provided as input parameter.
visuEq( K, nVar = NULL, dMax = NULL, dMin = 0, substit = 0, approx = FALSE, selecmod = NULL )
visuEq( K, nVar = NULL, dMax = NULL, dMin = 0, substit = 0, approx = FALSE, selecmod = NULL )
K |
A matrix providing the model description:
each column corresponds to one equation which polynomial organisation
is following the convention defined by function |
nVar |
The number of variables |
dMax |
The maximum degree allowed in the formulation |
dMin |
The minimum negative degree of the polynomial formulation (0 by default). |
substit |
Applies subtitutions to the default values:
for |
approx |
The number of extra digits to be used:
for |
selecmod |
An integer providing the number in the sublist when the model matrix is provided in a list. Should not be provided (or NULL) if the model matrix is provided directly. |
N A list of Nvar elements presenting a set of equtions, each equation being an element of this list and written as a character strings
Sylvain Mangiarotti
#EQUATIONS VISUALISATION # number of variables: nVar <- 3 # maximum polynomial degree: dMax <- 2 # polynomial organization: poLabs(nVar,dMax) # model construction KL = matrix(0, ncol = 3, nrow = 10) KL[1,1] <- KL[2,2] <- 1 KL[4,1] <- -1 KL[5,3] <- -0.123456789 # Equations visualisation: # (a) by default, variables names X1, X2, X3 are used visuEq(KL, nVar, dMax) # (b) for susbstit=1, variables names x, y, y are used instead visuEq(KL, nVar, dMax, approx = TRUE, substit=1) # (c) the name of the variables can also be chosen manualy visuEq(KL, nVar, dMax, approx = 3, substit=c('U', 'V', 'W')) # A canonical model can be provided as a single vector polyTerms <- c(0.2,0,-1,0.5,0,0,0,0,0,0) visuEq(polyTerms, 3,2)
#EQUATIONS VISUALISATION # number of variables: nVar <- 3 # maximum polynomial degree: dMax <- 2 # polynomial organization: poLabs(nVar,dMax) # model construction KL = matrix(0, ncol = 3, nrow = 10) KL[1,1] <- KL[2,2] <- 1 KL[4,1] <- -1 KL[5,3] <- -0.123456789 # Equations visualisation: # (a) by default, variables names X1, X2, X3 are used visuEq(KL, nVar, dMax) # (b) for susbstit=1, variables names x, y, y are used instead visuEq(KL, nVar, dMax, approx = TRUE, substit=1) # (c) the name of the variables can also be chosen manualy visuEq(KL, nVar, dMax, approx = 3, substit=c('U', 'V', 'W')) # A canonical model can be provided as a single vector polyTerms <- c(0.2,0,-1,0.5,0,0,0,0,0,0) visuEq(polyTerms, 3,2)
The algorithm aims to get a quick information about the outputs obtained with gPoMo.
visuOutGP( ogp, selecmod = NULL, id = 1, prioMinMax = "data", opt3D = "TRUE", maxPages = NULL, seeEq = 1 )
visuOutGP( ogp, selecmod = NULL, id = 1, prioMinMax = "data", opt3D = "TRUE", maxPages = NULL, seeEq = 1 )
ogp |
The output list obtained from gPoMo. |
selecmod |
A vector of the selected model. Maximum 24 models can be presented at the same time. |
id |
The type of model to identify. |
prioMinMax |
Gives the priority for the plots among: |
opt3D |
Provides a 3D plot (x,y,z) when |
maxPages |
The maximum of pages to be displayed (4 by default, but this may be insufficient when too many models remain) |
seeEq |
Indicates if equations should be displayed (seeEq = 1, by default) or not (seeEq = 0). |
A Matrix describing the terms composing each model by row. The first row corresponds to the model detection (1 unclarified, 2 diverging, 0 is fixed point, -n with n an integer, is period-n cycle' )
Sylvain Mangiarotti
# load data data("Ross76") # # time vector tin <- Ross76[seq(1, 3000, by = 8), 1] # single time series data <- Ross76[seq(1, 3000, by = 8), 3] dev.new() plot(tin, data, type = 'l', main = 'Observed time series') # global modelling # results are put in list outputGPoM outputGPoM <- gPoMo(data, tin=tin, dMax = 2, nS=c(3), show = 0, nPmin = 9, nPmax = 12, method = 'rk4', IstepMin = 200, IstepMax = 201) visuOutGP(outputGPoM)
# load data data("Ross76") # # time vector tin <- Ross76[seq(1, 3000, by = 8), 1] # single time series data <- Ross76[seq(1, 3000, by = 8), 3] dev.new() plot(tin, data, type = 'l', main = 'Observed time series') # global modelling # results are put in list outputGPoM outputGPoM <- gPoMo(data, tin=tin, dMax = 2, nS=c(3), show = 0, nPmin = 9, nPmax = 12, method = 'rk4', IstepMin = 200, IstepMax = 201) visuOutGP(outputGPoM)
Computes weighted inner products.
wInProd(A1, A2, weight = NULL)
wInProd(A1, A2, weight = NULL)
A1 |
The input matrix 1. |
A2 |
The input matrix 2. |
weight |
The weighting vector. |
inP
The weighted inner product.
############ #Example 1 # ############ A1 = c(0,1,2,0,1,3) A2 = c(1,2,0,0,4,1) wInProd(A1, A2) ############ #Example 2 # ############ A1 = c(0,1,2,0,1,3) A2 = c(1,2,0,0,4,1) w = c(0,0,0,1,1,1) wInProd(A1, A2, weight = w)
############ #Example 1 # ############ A1 = c(0,1,2,0,1,3) A2 = c(1,2,0,0,4,1) wInProd(A1, A2) ############ #Example 2 # ############ A1 = c(0,1,2,0,1,3) A2 = c(1,2,0,0,4,1) w = c(0,0,0,1,1,1) wInProd(A1, A2, weight = w)