### Install nonlinearTseries from various sources Source: https://constantino-garcia.r-universe.dev/nonlinearTseries Commands for installing the package from CRAN, GitHub, or the R-universe repository. ```R # You can install the he latest released version from CRAN: install.packages("nonlinearTseries") # Or the the development version from GitHub: # devtools::install_github("constantino-garcia/nonlinearTseries") install.packages("nonlinearTseries", repos = c('https://constantino-garcia.r-universe.dev', 'https://cloud.r-project.org')) ``` -------------------------------- ### Install nonlinearTseries in R Source: https://constantino-garcia.r-universe.dev/nonlinearTseries Use this command to install the package from the R-universe repository or CRAN. ```R install.packages('nonlinearTseries', repos = c('https://constantino-garcia.r-universe.dev', 'https://cloud.r-project.org')) ``` -------------------------------- ### Estimate Maximal Lyapunov Exponent for Henon and Rossler Systems Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Examples demonstrating the calculation of the maximal Lyapunov exponent for Henon and Rossler chaotic systems. These examples require the maxLyapunov and estimate functions to process time series data. ```R ## Not run: ## Henon System h=henon(n.sample= 5000,n.transient= 100, a = 1.4, b = 0.3, start = c(0.63954883, 0.04772637), do.plot = FALSE) my.ts=h$x ml=maxLyapunov(time.series=my.ts, min.embedding.dim=2, max.embedding.dim=5, time.lag=1, radius=0.001,theiler.window=4, min.neighs=2,min.ref.points=500, max.time.steps=40,do.plot=FALSE) plot(ml) ml.estimation = estimate(ml,regression.range = c(0,15), use.embeddings=4:5, do.plot = TRUE) # The max Lyapunov exponent of the Henon system is 0.41 cat("expected: ",0.41," calculated: ",ml.estimation,"\n") ## Rossler system r=rossler(a=0.15,b=0.2,w=10,start=c(0,0,0), time=seq(0,1000,0.1), do.plot=FALSE) my.ts=r$x use.cols = c("#999999","#E69F00","#56B4E9") ml=maxLyapunov(time.series=my.ts,min.embedding.dim=5,max.embedding.dim = 7, time.lag=12,radius=0.1,theiler.window=50, min.neighs=5,min.ref.points=length(r), max.time.steps=300,number.boxes=NULL, sampling.period=0.1,do.plot=TRUE, col=use.cols) # The max Lyapunov exponent of the Rossler system is 0.09 ml.est=estimate(ml,col=use.cols,do.plot=T, fit.lty=1, fit.lwd=5) cat("expected: ",0.090," calculated: ",ml.est,"\n") ## End(Not run) ``` -------------------------------- ### GET /windowSizes Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Retrieves the window sizes used for Detrended Fluctuation Analysis (DFA) from a dfa object. ```APIDOC ## GET /windowSizes ### Description Returns the window sizes used to detrend the time series in a DFA object. ### Method GET ### Parameters #### Query Parameters - **x** (object) - Required - A dfa object. ### Response #### Success Response (200) - **windowSizes** (vector) - The window sizes used for detrending the time series. ``` -------------------------------- ### Calculate Lyapunov Exponents for Dynamical Systems Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Examples demonstrating the calculation and estimation of maximum Lyapunov exponents for Henon and Rossler systems. ```R h=henon(n.sample= 5000,n.transient= 100, a = 1.4, b = 0.3, start = c(0.63954883, 0.04772637), do.plot = FALSE) my.ts=h$x ml=maxLyapunov(time.series=my.ts, min.embedding.dim=2, max.embedding.dim=5, time.lag=1, radius=0.001,theiler.window=4, min.neighs=2,min.ref.points=500, max.time.steps=40,do.plot=FALSE) plot(ml) ml.estimation = estimate(ml,regression.range = c(0,15), use.embeddings=4:5, do.plot = TRUE) # The max Lyapunov exponent of the Henon system is 0.41 cat("expected: ",0.41," calculated: ",ml.estimation,"\n") ``` ```R r=rossler(a=0.15,b=0.2,w=10,start=c(0,0,0), time=seq(0,1000,0.1), do.plot=FALSE) my.ts=r$x use.cols = c("#999999","#E69F00","#56B4E9") ml=maxLyapunov(time.series=my.ts,min.embedding.dim=5,max.embedding.dim = 7, time.lag=12,radius=0.1,theiler.window=50, min.neighs=5,min.ref.points=length(r), max.time.steps=300,number.boxes=NULL, sampling.period=0.1,do.plot=TRUE, col=use.cols) # The max Lyapunov exponent of the Rossler system is 0.09 ml.est=estimate(ml,col=use.cols,do.plot=T, fit.lty=1, fit.lwd=5) cat("expected: ",0.090," calculated: ",ml.est,"\n") ``` -------------------------------- ### Generate Sinai Map and Calculate Mutual Information Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html This example demonstrates generating a time series using the `sinaiMap` function and then calculating its mutual information. It is marked as 'Not run', indicating it's for illustrative purposes or requires specific conditions to execute. ```R ## Not run: sx = sinaiMap(a=0.3,n.sample=5000,start=c(0.23489,0.8923),do.plot=FALSE)$x mutinf = mutualInformation(sx, n.partitions = 20, units = "Bits") ## End(Not run) ``` ```R ## Not run: sx = sinaiMap(a=0.3,n.sample=5000,start=c(0.23489,0.8923),do.plot=FALSE)$x mutinf = mutualInformation(sx, n.partitions = 20, units = "Bits") ## End(Not run) ``` -------------------------------- ### Generate Ikeda Map Time Series Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Generates a time series using the Ikeda map. Parameters 'a', 'b', 'cc', and 'k' control the system's behavior. The 'start' argument specifies initial values, and 'n.sample' and 'n.transient' control the series length and discarded transient points. ```R ikeda.map=ikedaMap(n.sample = 1000, n.transient=10, do.plot=TRUE) ``` -------------------------------- ### Get the order of the nonlinear chaotic invariant API Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Retrieves the order of the nonlinear chaotic invariant from the provided information. ```APIDOC ## Get the order of the nonlinear chaotic invariant ### Description Get the order of the nonlinear chaotic invariant. ### Method `nlOrder(x)` ### Arguments - **x** (object) - An object containing all the information needed for the estimate of the chaotic invariant. ### Value A numeric vector with the radius of the neighborhoods used for the computations of a chaotic invariant. ### Author(s) Constantino A. Garcia ### References H. Kantz and T. Schreiber: Nonlinear Time series Analysis (Cambridge university press) ### See Also `corrDim`, `sampleEntropy` ``` -------------------------------- ### GET /lorenz Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Generates a 3-dimensional time series using the Lorenz system of ordinary differential equations. ```APIDOC ## GET /lorenz ### Description Generates a 3-dimensional time series using the Lorenz equations. ### Parameters #### Query Parameters - **sigma** (numeric) - Optional - The sigma parameter. Default: 10 - **beta** (numeric) - Optional - The beta parameter. Default: 8/3 - **rho** (numeric) - Optional - The rho parameter. Default: 28 - **start** (array) - Optional - A 3-dimensional numeric vector indicating the starting point. - **time** (array) - Optional - The temporal interval at which the system will be generated. - **do.plot** (boolean) - Optional - If TRUE, a plot of the generated system is shown. ### Response #### Success Response (200) - **time** (array) - The time components. - **x** (array) - The x-components. - **y** (array) - The y-components. - **z** (array) - The z-components. ``` -------------------------------- ### GET /divergence Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Retrieves the rate of divergence of close trajectories for maximum Lyapunov exponent estimation. ```APIDOC ## divergence ### Description Returns the rate of divergence of close trajectories needed for the maximum Lyapunov exponent estimation. ### Parameters #### Request Body - **x** (maxLyapunov object) - Required - A maxLyapunov object. ### Response #### Success Response (200) - **matrix** (numeric) - A matrix where rows represent embedding dimensions and columns represent time points. ``` -------------------------------- ### Get Window Sizes from DFA Object Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html The windowSizes function retrieves the window sizes used in a 'dfa' object. ```R windowSizes(x) ``` -------------------------------- ### GET /sinaiMap Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Generates a 2-dimensional time series using the Sinai map, which is a deterministic chaotic system. ```APIDOC ## GET /sinaiMap ### Description Generates a 2-dimensional time series using the Sinai map. ### Parameters #### Query Parameters - **a** (numeric) - Optional - The a parameter. Default: 0.1 - **start** (vector) - Optional - A 2-dimensional vector indicating the starting values for the x and y Sinai coordinates. - **n.sample** (integer) - Optional - Length of the generated time series. Default: 5000 - **n.transient** (integer) - Optional - Number of transient samples that will be discarded. Default: 500 - **do.plot** (boolean) - Optional - If TRUE, a plot of the generated Sinai system is shown. ### Response #### Success Response (200) - **x** (vector) - The x-components of the Sinai map. - **y** (vector) - The y-components of the Sinai map. ``` -------------------------------- ### GET /ikedaMap Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Generates a time series using the Ikeda map, which is defined by a specific set of recursive equations. ```APIDOC ## GET /ikedaMap ### Description Generates a time series using the Ikeda map. ### Parameters #### Query Parameters - **a** (numeric) - Optional - The a parameter. Default: 0.85. - **b** (numeric) - Optional - The b parameter. Default: 0.9. - **cc** (numeric) - Optional - The c parameter. Default: 7.7. - **k** (numeric) - Optional - The k parameter. Default: 0.4. - **start** (vector) - Optional - A 2-dimensional numeric vector indicating the starting value. - **n.sample** (integer) - Optional - Length of the generated time series. Default: 5000. - **n.transient** (integer) - Optional - Number of transient samples to discard. Default: 500. - **do.plot** (boolean) - Optional - If TRUE, plots the generated system. ### Response #### Success Response (200) - **x** (vector) - The x-components of the Ikeda map. - **y** (vector) - The y-components of the Ikeda map. ``` -------------------------------- ### GET /sampleEntropyFunction Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Retrieves the sample entropy function hq(m,r) used for computations based on a provided sampleEntropy object. ```APIDOC ## GET /sampleEntropyFunction ### Description Returns the sample entropy function hq(m,r) used for the computations of the sample entropy. ### Parameters #### Request Body - **x** (sampleEntropy object) - Required - A sampleEntropy object. ### Response #### Success Response (200) - **result** (numeric matrix) - A numeric matrix representing the sample entropy function hq(m,r). ``` -------------------------------- ### Generate and Plot Henon Map Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Generates a time series using the Henon map and plots its x-coordinate. Requires specifying sample size, transient points, and starting values. ```R henon.map=henon(n.sample = 1000, n.transient=10,do.plot=TRUE, start=c(-0.006423277,-0.473545134)) # accessing the x coordinate and plotting it plot(ts(henon.map$x)) ``` -------------------------------- ### embeddingDims Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Gets the embedding dimensions used for computing a chaotic invariant. ```APIDOC ## embeddingDims ### Description Get the embedding dimensions used for compute a chaotic invariant. ### Usage ```R embeddingDims(x) ``` ### Arguments * `x` (object): An object containing all the information needed for the estimate. ### Value A numeric vector with the embedding dimensions used for compute a chaotic invariant. ### Author(s) Constantino A. Garcia ### References H. Kantz and T. Schreiber: Nonlinear Time series Analysis (Cambridge university press) ``` -------------------------------- ### Perform Detrended Fluctuation Analysis and Estimate Scaling Exponents Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Demonstrates how to use dfa and estimate functions on white noise, fractional Gaussian noise, and fractional Brownian motion. ```R ## Not run: white.noise = rnorm(5000) dfa.analysis = dfa(time.series = white.noise, npoints = 10, window.size.range=c(10,1000), do.plot=FALSE) white.estimation = estimate(dfa.analysis,do.plot=TRUE) cat("Theorical: 0.5---Estimated: ",white.estimation ,"\n") library(fArma) fgn = as.numeric(fArma::fgnSim(n = 2000, H = 0.75)) dfa.analysis = dfa(time.series = fgn, npoints = 30, window.size.range=c(10,1000), do.plot=FALSE) fgn.estimation = estimate(dfa.analysis, do.plot = TRUE, fit.col="blue",fit.lwd=2,fit.lty=2, main="Fitting DFA to fGn") cat("Theorical: 0.75---Estimated: ",fgn.estimation ,"\n") fbm = as.numeric(fArma::fbmSim(n = 2000, H = 0.25)) dfa.analysis = dfa(time.series = fbm, npoints = 50, window.size.range=c(10,300), do.plot=FALSE) fbm.estimation = estimate(dfa.analysis,do.plot = TRUE, add.legend=F, main="DFA of fBm") cat("Theorical: 1.25 ---Estimated: ",fbm.estimation ,"\n") ## End(Not run) ## Not run: white.noise = rnorm(5000) dfa.analysis = dfa(time.series = white.noise, npoints = 10, window.size.range=c(10,1000), do.plot=FALSE) white.estimation = estimate(dfa.analysis,do.plot=TRUE) cat("Theorical: 0.5---Estimated: ",white.estimation ,"\n") library(fArma) fgn = as.numeric(fArma::fgnSim(n = 2000, H = 0.75)) dfa.analysis = dfa(time.series = fgn, npoints = 30, window.size.range=c(10,1000), do.plot=FALSE) fgn.estimation = estimate(dfa.analysis, do.plot = TRUE, fit.col="blue",fit.lwd=2,fit.lty=2, main="Fitting DFA to fGn") cat("Theorical: 0.75---Estimated: ",fgn.estimation ,"\n") fbm = as.numeric(fArma::fbmSim(n = 2000, H = 0.25)) dfa.analysis = dfa(time.series = fbm, npoints = 50, window.size.range=c(10,300), do.plot=FALSE) fbm.estimation = estimate(dfa.analysis,do.plot = TRUE, add.legend=F, main="DFA of fBm") cat("Theorical: 1.25 ---Estimated: ",fbm.estimation ,"\n") ## End(Not run) ``` -------------------------------- ### Get Radius of Neighborhoods Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Retrieves the radius of neighborhoods used in chaotic invariant computations. ```APIDOC ## Get Radius of Neighborhoods ### Description Get the radius of the neighborhoods used for the computations of a chaotic invariant. ### Method `radius(x)` ### Arguments - **x** (object) - An object containing all the information needed for the estimate of the chaotic invariant. ### Value A numeric vector with the radius of the neighborhoods used for the computations of a chaotic invariant. ### Example ```r # Assuming 'chaotic_invariant_object' is an object containing the necessary information radii = radius(chaotic_invariant_object) ``` ``` -------------------------------- ### GET /logRadius Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Obtains the average log(radius) computed on the information dimension algorithm. ```APIDOC ## GET /logRadius ### Description Obtain the average log(radius) computed on the information dimension algorithm. ### Parameters #### Query Parameters - **x** (object) - Required - An infDim object. ### Response #### Success Response (200) - **value** (array) - A numeric vector representing the average log(radius). ``` -------------------------------- ### Get Chaotic Invariant Radius Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Retrieves the radius of neighborhoods used for chaotic invariant computations. ```R radius(x) radius(x) ``` -------------------------------- ### Henon System Analysis Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Analysis of the Henon system using maxLyapunov and estimation functions. ```APIDOC ## Henon System ### Description Simulates and analyzes the Henon system to estimate the maximum Lyapunov exponent. ### Usage ```R h = henon(n.sample = 5000, n.transient = 100, a = 1.4, b = 0.3, start = c(0.63954883, 0.04772637), do.plot = FALSE) my.ts = h$x ml = maxLyapunov(time.series = my.ts, min.embedding.dim = 2, max.embedding.dim = 5, time.lag = 1, radius = 0.001, theiler.window = 4, min.neighs = 2, min.ref.points = 500, max.time.steps = 40, do.plot = FALSE) ml.estimation = estimate(ml, regression.range = c(0, 15), use.embeddings = 4:5, do.plot = TRUE) cat("expected: ", 0.41, " calculated: ", ml.estimation, "\n") ``` ### Parameters #### Henon Function Parameters - **n.sample** (numeric) - Number of samples to generate. - **n.transient** (numeric) - Number of transient points to discard. - **a** (numeric) - Parameter 'a' for the Henon map. - **b** (numeric) - Parameter 'b' for the Henon map. - **start** (numeric vector) - Starting values for the system. - **do.plot** (logical) - Whether to plot the generated series. #### maxLyapunov Function Parameters - **time.series** (numeric vector) - The time series data. - **min.embedding.dim** (numeric) - Minimum embedding dimension. - **max.embedding.dim** (numeric) - Maximum embedding dimension. - **time.lag** (numeric) - Time lag for embedding. - **radius** (numeric) - Radius for neighbor search. - **theiler.window** (numeric) - Theiler window size. - **min.neighs** (numeric) - Minimum number of neighbors. - **min.ref.points** (numeric) - Minimum reference points. - **max.time.steps** (numeric) - Maximum time steps for calculation. - **do.plot** (logical) - Whether to plot the results. #### estimate Function Parameters - **ml** (object) - Output from `maxLyapunov`. - **regression.range** (numeric vector) - Range for regression. - **use.embeddings** (numeric vector) - Embeddings to use for estimation. - **do.plot** (logical) - Whether to plot the estimation. ### Returns - **h$x** (numeric vector) - The time series generated by the Henon system. - **ml** (object) - An object containing Lyapunov exponent calculation results. - **ml.estimation** (numeric) - The estimated maximum Lyapunov exponent. ``` -------------------------------- ### Statistical Tests and Preprocessing Source: https://constantino-garcia.r-universe.dev/nonlinearTseries Functions for nonlinearity testing, surrogate data generation, and time series preprocessing. ```APIDOC ## Statistical Tests and Preprocessing ### Description Tools for testing nonlinearity, generating surrogate data, and performing noise reduction. ### Methods - **FFTsurrogate**: Generate surrogate data using Fourier transform. - **surrogateTest**: Perform surrogate data testing. - **nonlinearityTest**: General nonlinearity test. - **keenanTest**: Keenan's test for nonlinearity. - **mcleodLiTest**: McLeod-Li test. - **tsayTest**: Tsay's test. - **nonLinearNoiseReduction**: Perform nonlinear noise reduction. ``` -------------------------------- ### GET /spaceTimePlot Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Generates a space-time separation plot to detect non-stationarity and temporal correlations in a time series. ```APIDOC ## GET /spaceTimePlot ### Description The space time separation is a method of detecting non-stationarity and temporal correlations in the time series being analyzed. ### Parameters #### Query Parameters - **takens** (object) - Optional - Takens object. - **time.series** (vector) - Optional - The time series to analyze. - **embedding.dim** (integer) - Optional - Embedding dimension. Default: 2 - **time.lag** (integer) - Optional - Time lag. Default: 1 - **max.radius** (numeric) - Optional - Maximum radius. - **time.step** (integer) - Optional - Time step. Default: 1 - **number.time.steps** (integer) - Optional - Number of time steps. - **numberPercentages** (integer) - Optional - Number of percentages. Default: 10 - **do.plot** (boolean) - Optional - If TRUE, plots the result. Default: TRUE ``` -------------------------------- ### Generate Surrogate Data using FFT Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Generates surrogate samples from a time series using phase randomization, preserving the power spectrum and autocorrelation. ```R FFTsurrogate(time.series, n.samples = 1) FFTsurrogate(time.series, n.samples = 1) ``` ```R ## Not run: # generate 20 surrogate sets using as original time series # an arma(1,1) simulation time.series = arima.sim(list(order = c(1,0,1), ar = 0.6, ma = 0.5), n = 200) surrogate = FFTsurrogate(time.series, 20) ## End(Not run) ## Not run: # generate 20 surrogate sets using as original time series # an arma(1,1) simulation time.series = arima.sim(list(order = c(1,0,1), ar = 0.6, ma = 0.5), n = 200) surrogate = FFTsurrogate(time.series, 20) ## End(Not run) ``` -------------------------------- ### Utility Functions Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Functions to retrieve metadata from a sampleEntropy object. ```APIDOC ## Utility Functions ### Methods - **radius(x)**: Returns the radius on which the sample entropy function has been evaluated. - **embeddingDims(x)**: Returns the embedding dimensions on which the sample entropy function has been evaluated. - **nlOrder(x)**: Returns the order of the sample entropy. - **sampleEntropyFunction(x)**: Returns the sample entropy function matrix used for computations. ``` -------------------------------- ### Calculate and Plot Poincare Sections Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Calculates Poincare sections for a Rossler system and visualizes the results in 3D using the rgl package. ```R ## Not run: r=rossler(a = 0.2, b = 0.2, w = 5.7, start=c(-2, -10, 0.2), time=seq(0,300,by = 0.01), do.plot=FALSE) takens=cbind(r$x,r$y,r$z) # calculate poincare sections pm=poincareMap(takens = takens,normal.hiperplane.vector = c(0,1,0), hiperplane.point=c(0,0,0) ) if (requireNamespace("rgl", quietly = TRUE)) { rgl::plot3d(takens,size=0.7) rgl::points3d(pm$pm,col="red") } ## End(Not run) ## Not run: r=rossler(a = 0.2, b = 0.2, w = 5.7, start=c(-2, -10, 0.2), time=seq(0,300,by = 0.01), do.plot=FALSE) takens=cbind(r$x,r$y,r$z) # calculate poincare sections pm=poincareMap(takens = takens,normal.hiperplane.vector = c(0,1,0), hiperplane.point=c(0,0,0) ) if (requireNamespace("rgl", quietly = TRUE)) { rgl::plot3d(takens,size=0.7) rgl::points3d(pm$pm,col="red") } ## End(Not run) ``` -------------------------------- ### Get Contour Lines from Space Time Plot Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Extracts the contour lines from a space-time plot object. ```APIDOC ## getContourLines ### Description Obtain the contour lines of the space time plot. ### Usage ```R getContourLines(x) ``` ### Arguments `x` | A _spaceTimePlot_ object. ---|--- ### See Also `spaceTimePlot` ``` -------------------------------- ### POST /thresholdTest Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Computes the likelihood ratio test for threshold nonlinearity with H0 being an AR process and H1 a TAR model. ```APIDOC ## POST /thresholdTest ### Description Computes the likelihood ratio test for threshold nonlinearity. ### Method POST ### Endpoint /thresholdTest ### Parameters #### Request Body - **time.series** (numeric) - Required - The original time series. - **p** (integer) - Required - The order of the AR process. - **d** (integer) - Optional - Delay used for the threshold value. Default is 1. - **lower.percent** (numeric) - Optional - Lower bound for threshold search. Default is 0.25. - **upper.percent** (numeric) - Optional - Upper bound for threshold search. Default is 0.75. ### Response #### Success Response (200) - **p.value** (numeric) - The p-value of the test. - **test.statistic** (numeric) - Likelihood ratio test statistic. - **percentiles** (list) - Effective lower and upper percents used in the search. ``` -------------------------------- ### S3 method plotLocalScalingExp for class 'infDim' Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Visualizes the local scaling exponents d1(p) for an 'infDim' object. ```APIDOC ## S3 method plotLocalScalingExp(x, ...) ### Description Plots the local scaling exponents d1(p) for an 'infDim' object. ### Method S3 Method ### Parameters #### Path Parameters - **x** (infDim) - Required - The infDim object to plot. #### Request Body - **main** (string) - Optional - Title for the plot. - **xlab** (string) - Optional - Label for the x axis. - **ylab** (string) - Optional - Label for the y axis. - **type** (string) - Optional - Type of plot. - **log** (string) - Optional - Logarithmic axis specification. - **ylim** (numeric vector) - Optional - Y coordinates range. - **col** (vector) - Optional - Colors for dimensions. - **pch** (vector) - Optional - Symbols for dimensions. - **add.legend** (boolean) - Optional - Whether to add a legend. ``` -------------------------------- ### GET /logisticMap Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Generates a time series using the logistic map, which is known to produce deterministic chaotic behavior. ```APIDOC ## GET /logisticMap ### Description Generates a time series using the logistic map. ### Parameters #### Query Parameters - **r** (numeric) - Optional - The r parameter. Default: 4 - **start** (numeric) - Optional - Starting value for the time series. If not specified, it is generated randomly. - **n.sample** (integer) - Optional - Length of the generated time series. Default: 5000 - **n.transient** (integer) - Optional - Number of transient samples to discard. Default: 500 - **do.plot** (boolean) - Optional - If TRUE, a plot of the generated system is shown. ### Response #### Success Response (200) - **value** (array) - A vector containing the values of the generated time series. ``` -------------------------------- ### Plot local scaling exponents Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Visualizes local scaling exponents for correlation sums or Shannon information. ```R plotLocalScalingExp(x, ...) plotLocalScalingExp(x, ...) ``` -------------------------------- ### Simulate Rossler System Time Series Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Generates a time series for the Rossler system. Some initial values may lead to an unstable system. ```R ## Not run: r.ts = rossler(time=seq(0,30,by = 0.01)) ## End(Not run) ``` ```R ## Not run: r.ts = rossler(time=seq(0,30,by = 0.01)) ## End(Not run) ``` -------------------------------- ### GET /corrMatrix Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Retrieves the correlation matrix storing correlation sums computed for all embedding dimensions from a corrDim object. ```APIDOC ## GET /corrMatrix ### Description Returns the correlation sums stored in the corrDim object. ### Parameters #### Request Body - **x** (corrDim object) - Required - A corrDim object. ### Response #### Success Response (200) - **matrix** (array) - The correlations matrix storing the correlation sums. ``` -------------------------------- ### Perform Recurrence Quantification Analysis (RQA) Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Quantifies recurrences in phase space using a time series. Requires specifying embedding dimension, time lag, and recurrence radius. The recurrence matrix computation can be computationally expensive. ```R rqa( takens = NULL, time.series = NULL, embedding.dim = 2, time.lag = 1, radius, lmin = 2, vmin = 2, distanceToBorder = 2, save.RM = TRUE, do.plot = FALSE, ... ) ``` ```R rqa( takens = NULL, time.series = NULL, embedding.dim = 2, time.lag = 1, radius, lmin = 2, vmin = 2, distanceToBorder = 2, save.RM = TRUE, do.plot = FALSE, ... ) ``` ```R ## Not run: rossler.ts = rossler(time=seq(0, 10, by = 0.01),do.plot=FALSE)$x rqa.analysis=rqa(time.series = rossler.ts, embedding.dim=2, time.lag=1, radius=1.2,lmin=2,do.plot=FALSE,distanceToBorder=2) plot(rqa.analysis) ## End(Not run) ``` ```R ## Not run: rossler.ts = rossler(time=seq(0, 10, by = 0.01),do.plot=FALSE)$x rqa.analysis=rqa(time.series = rossler.ts, embedding.dim=2, time.lag=1, radius=1.2,lmin=2,do.plot=FALSE,distanceToBorder=2) plot(rqa.analysis) ## End(Not run) ``` -------------------------------- ### Get Fluctuation Function from DFA Object Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html The fluctuationFunction function extracts the calculated fluctuation function from a 'dfa' object. ```R fluctuationFunction(x) ``` -------------------------------- ### Generate Surrogate Data using Fourier Transform Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Generates surrogate samples from the original time series using the Fourier transform method. ```APIDOC ## POST /api/FFTsurrogate ### Description Generates surrogate samples from the original time series using phase randomization. ### Method POST ### Endpoint /api/FFTsurrogate ### Parameters #### Request Body - **time.series** (numeric vector) - Required - The original time series from which the surrogate data is generated. - **n.samples** (integer) - Optional - The number of surrogate data sets to generate. Defaults to 1. ### Request Example ```json { "time.series": [1, 2, 3, 4, 5, 4, 3, 2, 1], "n.samples": 20 } ``` ### Response #### Success Response (200) - **surrogate_data** (matrix) - A matrix containing the generated surrogate data (one time series per row). #### Response Example ```json { "surrogate_data": [ [1.1, 2.2, 3.3, 4.4, 5.5, 4.4, 3.3, 2.2, 1.1], [1.0, 2.1, 3.2, 4.3, 5.4, 4.3, 3.2, 2.1, 1.0] ] } ``` ``` -------------------------------- ### Build Takens Embedding Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Builds a Takens embedding from a time series. This is a crucial step for reconstructing the phase space of a dynamical system. ```APIDOC ## buildTakens ### Description Builds a Takens embedding from a time series. ### Usage ```R buildTakens(x, embedding.dim = 2, time.lag = 1) ``` ### Arguments `x` | A numeric vector or time series. ---|--- `embedding.dim` | The embedding dimension. `time.lag` | The time lag. ### Value A matrix representing the Takens embedding. ``` -------------------------------- ### Rossler System Analysis Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Analysis of the Rossler system using maxLyapunov and estimation functions. ```APIDOC ## Rossler System ### Description Simulates and analyzes the Rossler system to estimate the maximum Lyapunov exponent. ### Usage ```R r = rossler(a = 0.15, b = 0.2, w = 10, start = c(0, 0, 0), time = seq(0, 1000, 0.1), do.plot = FALSE) my.ts = r$x ml = maxLyapunov(time.series = my.ts, min.embedding.dim = 5, max.embedding.dim = 7, time.lag = 12, radius = 0.1, theiler.window = 50, min.neighs = 5, min.ref.points = length(r), max.time.steps = 300, number.boxes = NULL, sampling.period = 0.1, do.plot = TRUE, col = use.cols) ml.est = estimate(ml, col = use.cols, do.plot = T, fit.lty = 1, fit.lwd = 5) cat("expected: ", 0.090, " calculated: ", ml.est, "\n") ``` ### Parameters #### Rossler Function Parameters - **a** (numeric) - Parameter 'a' for the Rossler system. - **b** (numeric) - Parameter 'b' for the Rossler system. - **w** (numeric) - Parameter 'w' for the Rossler system. - **start** (numeric vector) - Starting values for the system. - **time** (numeric vector) - Time points for simulation. - **do.plot** (logical) - Whether to plot the generated series. #### maxLyapunov Function Parameters - **time.series** (numeric vector) - The time series data. - **min.embedding.dim** (numeric) - Minimum embedding dimension. - **max.embedding.dim** (numeric) - Maximum embedding dimension. - **time.lag** (numeric) - Time lag for embedding. - **radius** (numeric) - Radius for neighbor search. - **theiler.window** (numeric) - Theiler window size. - **min.neighs** (numeric) - Minimum number of neighbors. - **min.ref.points** (numeric) - Minimum reference points. - **max.time.steps** (numeric) - Maximum time steps for calculation. - **number.boxes** (numeric) - Number of boxes for calculation (NULL by default). - **sampling.period** (numeric) - Sampling period of the time series. - **do.plot** (logical) - Whether to plot the results. - **col** (character vector) - Colors for plotting. #### estimate Function Parameters - **ml** (object) - Output from `maxLyapunov`. - **col** (character vector) - Colors for plotting. - **do.plot** (logical) - Whether to plot the estimation. - **fit.lty** (numeric) - Line type for the fit. - **fit.lwd** (numeric) - Line width for the fit. ### Returns - **r$x** (numeric vector) - The time series generated by the Rossler system. - **ml** (object) - An object containing Lyapunov exponent calculation results. - **ml.est** (numeric) - The estimated maximum Lyapunov exponent. ``` -------------------------------- ### Poincare Map API Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Computes the Poincare map for reconstructed trajectories in phase space, a technique for analyzing dynamical systems. ```APIDOC ## POST /api/poincareMap ### Description Computes the Poincare map of reconstructed trajectories in phase space. This function replaces n-dimensional trajectories with an (n-1)-dimensional discrete-time map by intersecting trajectories with a hyperplane. ### Method POST ### Endpoint /api/poincareMap ### Parameters #### Request Body - **time.series** (numeric array) - Optional - The original time series for phase space reconstruction. - **embedding.dim** (integer) - Optional - The dimension for phase space embedding. Defaults to 2. - **time.lag** (integer) - Optional - The time lag for constructing Takens' vectors. Defaults to 1. - **takens** (matrix or array) - Optional - Pre-computed Takens' vectors, can be used instead of time.series, embedding.dim, and time.lag. - **normal.hiperplane.vector** (numeric array) - Optional - The normal vector of the hyperplane. If not specified, defaults to (0,0,...,1). - **hiperplane.point** (numeric array) - Required - A point lying on the hyperplane. ### Request Example ```json { "time.series": [0.1, 0.2, 0.3, 0.4, 0.5, ...], "embedding.dim": 2, "time.lag": 1, "hiperplane.point": [0, 0] } ``` ### Response #### Success Response (200) - **poincare_points** (array of arrays) - A list of points representing the Poincare map. #### Response Example ```json { "poincare_points": [[0.1, 0.2], [0.3, 0.4], ...] } ``` ``` -------------------------------- ### Henon Map Time Series Generation Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Generates a 2-dimensional time series using the Henon map, a classic example of a chaotic system. ```APIDOC ## henon ### Description Generates a 2-dimensional time series using the Henon map. ### Usage ```R henon(start = runif(min = -0.5, max = 0.5, n = 2), a = 1.4, b = 0.3, n.sample = 5000, n.transient = 500, do.plot = deprecated()) ``` ### Arguments `start` | A 2-dimensional vector indicating the starting values for the x and y Henon coordinates. If not specified, it is generated randomly. ---|--- `a` | The _a_ parameter. Default: 1.4. `b` | The _b_ parameter. Default: 0.3. `n.sample` | Length of the generated time series. Default: 5000 samples. `n.transient` | Number of transient samples to discard. Default: 500 samples. `do.plot` | Logical value. If TRUE, a plot of the generated Henon system is shown. ### Details The Henon map is defined as: `xn = 1 - a * xn-1^2 + yn-1` `yn = b * xn-1` ### Value A list with two vectors named _x_ and _y_ containing the x-components and the y-components of the Henon map, respectively. ### Note Some initial values may lead to an unstable system that will tend to infinity. ``` -------------------------------- ### Get Contour Lines for Space Time Plot Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Obtains the contour lines for a space time plot. This function is used in conjunction with a 'spaceTimePlot' object. ```R getContourLines(x) ``` -------------------------------- ### Nonlinear Maps and Systems Source: https://constantino-garcia.r-universe.dev/nonlinearTseries Functions to generate data from various nonlinear maps and dynamical systems. ```APIDOC ## Nonlinear Maps and Systems ### Description Generate time series data using standard nonlinear maps and dynamical systems. ### Available Systems - **henon**: Henon map. - **lorenz**: Lorenz system. - **rossler**: Rossler system. - **logisticMap**: Logistic map. - **cliffordMap**: Clifford map. - **gaussMap**: Gauss map. - **ikedaMap**: Ikeda map. - **sinaiMap**: Sinai map. ``` -------------------------------- ### Reconstruct Henon map state space Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Demonstrates building Takens' vectors for the Henon map and plotting the resulting state space reconstruction. ```R ## Not run: # Build the Takens vector for the Henon map using the x-coordinate time series h = henon(n.sample= 3000,n.transient= 100, a = 1.4, b = 0.3, start = c(0.73954883, 0.04772637), do.plot = FALSE) takens = buildTakens(h$x,embedding.dim=2,time.lag=1) # using the x-coordinate time series we are able to reconstruct # the state space of the Henon map plot(takens) ## End(Not run) ``` -------------------------------- ### Build Takens vector for Henon map Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Reconstructs the state space of the Henon map using the x-coordinate time series. ```R h = henon(n.sample= 3000,n.transient= 100, a = 1.4, b = 0.3, start = c(0.73954883, 0.04772637), do.plot = FALSE) takens = buildTakens(h$x,embedding.dim=2,time.lag=1) # using the x-coordinate time series we are able to reconstruct # the state space of the Henon map plot(takens) ## End(Not run) ``` -------------------------------- ### Generate Henon Map Data Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Generates a time series from the Henon map, a common example used in chaos theory. Parameters control the sample size, transient points, and map coefficients. ```R x=henon(n.sample= 3000,n.transient= 100, a = 1.4, b = 0.3, start = c(0.8253681, 0.6955566), do.plot = FALSE)$x ``` -------------------------------- ### Estimate Sample Entropy for Henon Map Source: https://constantino-garcia.r-universe.dev/nonlinearTseries/doc/manual.html Calculates sample entropy for a Henon map time series and estimates the K2 entropy value. ```R ## Not run: x=henon(n.sample = 15000, n.transient = 100, a = 1.4, b = 0.3, start = c(0.78,0.8165), do.plot = FALSE)$x cd=corrDim(time.series=x, min.embedding.dim=2,max.embedding.dim=9, corr.order=2,time.lag=1, min.radius=0.05,max.radius=1, n.points.radius=100, theiler.window=20, do.plot=TRUE) use.col = c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7") se=sampleEntropy(cd,do.plot=TRUE,col=use.col, type="l",xlim=c(0.1,1), add.legend=T) se.est = estimate(se, regression.range = c(0.4,0.6), use.embeddings = 6:9,col=use.col,type="b") print(se.est) cat("Expected K2 = ",0.325," Estimated = ",mean(se.est),"\n") ## End(Not run) ```