fractal: Create time series based on fractal generators

Description Usage Arguments Value Author(s) References Examples

View source: R/framework.R

Description

The fractal function generates a time series of points using basic principles of fractal patterns. Fractal generation can be used to simulate a time series of asset prices, which has been shown to better reflect the distribution of returns than using a Gaussian random walk. Any number of points can be generated based on specifying the total count or by running over a number of epochs. The range of the data is defined by the given seed for the generation plus the available patterns.

Usage

1
2
3
4
5
6
7
fractal(seeds, patterns, count = NULL, epochs = NULL, ..., type = "uniform")

fractal.uniform(seed, patterns, count = NULL, epochs = NULL, origin = '1970-01-01', date.fun = as.Date, only = NULL)

fractal.random(seed, patterns, count = NULL, epochs = NULL, origin = '1970-01-01', date.fun = as.Date, only = NULL)

next.seeds(old.seed, new.seed, pattern, idx, epoch)

Arguments

seeds

A list of seed patterns to use for generating the time series

seed

The seed pattern to use for generating the time series

patterns

A single pattern or list of patterns that get randomly selected for each segment being replaced

count

The total number of points to create. Either count or epochs must be provided. Specifying count indirectly sets the number of epochs to run and truncates the data appropriately to get the specified number of points.

epochs

The total number of epochs to run. Either count or epochs must be populated. Using epochs is good for experimentation to visualize what happens at every stage of the generation.

origin

The starting date for the generated time series

date.fun

The function to use to parse dates and/or times

only

Only use the nth pattern instead of randomly choosing from patterns

...

Additional arguments to pass to underlying function

type

The type of generation to perform. Uniform descends each level in a uniform manner (meaning all segments get replaced) whereas the random generation will randomly select segments to replace during each epoch.

old.seed

(Internal) Previous seed used to generate pattern

new.seed

(Internal) Next seed used to generate pattern

pattern

(Internal) Available patterns to use

idx

(Internal) Index of current iteration

epoch

(Internal) Current epoch

Value

An xts object containing a time series of values representing asset prices

Author(s)

Brian Lee Yung Rowe

References

M. Frame, B. Mandelbrot, N. Neger. Fractal Geometry. 2009. http://classes.yale.edu/fractals/

Examples

1
2
3
4
5
data(generators)
series <- fractal(sampleInitiators, sampleGenerators, count=10)

# View the results of a single iteration using the second pattern
series <- fractal(sampleInitiators, sampleGenerators, epochs=1, only=2)

Example output

Loading required package: futile.any
Loading required package: lambda.r
Loading required package: futile.logger
Loading required package: timeDate
Loading required package: quantmod
Loading required package: xts
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: TTR
Version 0.4-0 included new data defaults. See ?getSymbols.

fractalrock documentation built on May 29, 2017, 7:10 p.m.