Learn R Programming

fractaldim (version 0.8-5)

fd.estimate: Estimating Fractal Dimensions of Time Series and Two-dimensional Data

Description

The functions compute a set of fractal dimensions \(D\) for time series and two-dimensional data via various methods using a sliding window technique. There is one \(D\) computed for each method and for each sliding window of a given size that is moved along the data.

Usage

# S3 method for numeric
fd.estimate (data, methods = "madogram", window.size = length(data), 
    step.size = window.size, trim = TRUE, keep.data = FALSE, 
    keep.loglog = FALSE, parallel = FALSE, nr.nodes = NULL, 
    debuglevel = 0, …)
	
# S3 method for matrix
fd.estimate (data, methods = "transect.var", window.size = ncol(data),
    step.size = window.size, trim = TRUE, keep.data = FALSE, 
    keep.loglog = FALSE, parallel = FALSE, nr.nodes = NULL, 
    debuglevel = 0, ...)

Arguments

data

Vector, matrix or data frame.

methods

Vector of character strings specifying methods for which \(D\) is estimated. Possible values for one-dimensional data are “variogram”, “madogram”, “rodogram”, “variation”, “incr1”, “boxcount”, “hallwood”, “periodogram”, “wavelet”, “dctII”, and “genton”. For matrix or data frame the function accepts methods “transect.var”, “transect.incr1”, “isotropic”, “squareincr”, and “filter1” (see fd.get.available.methods). Alternatively, it can be a list of lists where each list item contains an entry “name” being the method name and entries corresponding to arguments passed to the specific methods (see Example and fd.estim.method for details.)

window.size

Size (in number of data points) of the sliding window. It should be between 2 and length of data.

step.size

Number of data points by which the sliding window is moved.

trim

Logical. If TRUE, the estimates are trimmed into the theoretically permissible interval, i.e. between 1 and 2 in one-dimensional case and between 2 and 3 in two-dimensional case.

keep.data

Logical. If TRUE, the data are kept in the resulting object.

keep.loglog

Logical. If TRUE, the resulting object contains a list with objects of class FDloglog used for the estimation in each iteration and for each method.

parallel

Logical determining if the process should run in parallel. If TRUE, the package snowFT is required. In such a case, all local library paths must be included in the environment variable R_LIBS. In the one-dimensional case, the granularity of the process is given by the number of sliding windows. In the two-dimensional case, the number of spawn processes is equal to the number of sliding windows in the vertical direction.

nr.nodes

Number of nodes on which the computation should be processed if parallel is TRUE.

debuglevel

Controls the amount of debugging messages. The functions produce messages on levels 1 - 4.

Arguments passed to lower level functions (defined in fd.estim.method).

Value

An object of class FractalDim which consists of the following components:

dim

Dimension of the resulting arrays fd and scale (see below). In the one-dimensional case, possible values are 1 and 2. dim = 1 means that there has been only one iteration and there is one element in the above arrays per each method used. If dim = 2, rows correspond to iterations and columns correspond to methods. Estimation on two-dimensional data can in addition result in dim = 3, in which case the first and second dimensions correspond to vertical and horizontal iterations, respectively, and the third dimension corresponds to methods.

fd

A dim-dimensional array of fractal dimensions.

scale

A dim-dimensional array of scales, derived from the intercept of the log-log plots on which fd were computed. Values are transformed to the scale of the original data.

methods

Vector of methods given in the methods argument. The order of the elements corresponds to the order of estimates in the “method”-dimension of the above dim-dimensional arrays.

methods.coding

Vector of internal coding of methods. The order of the elements corresponds to the order in methods.

data

Value of the argument data, if keep.data = TRUE, otherwise NULL.

data.dim

Dimension of data.

window.size

Size of the actual sliding window used in the computation.

step.size

Step size by which the sliding window was moved in the computation.

loglog

If keep.loglog=TRUE, this is a list containing for each iteration a lists of FDloglog objects used in the estimation, one per method. The numbering of the methods corresponds to the method order in methods.

Details

In case of one-dimensional time series, the function initiates a sliding window of the given size at the beginning of the time series. The window is moved along the data by the given step size. If parallel is TRUE, computation on each window happens in parallel. In the two-dimensional case, the window is initiated in the top left corner of the data matrix and moved horizontally by the given step size, as well as vertically by the same step size. If the process is running in parallel, processing each row is done in parallel. In both cases, in each iteration estimates of fractal dimension for data within the sliding window are computed using the given estimation methods.

Note that the estimation results are NA for any sliding window that contains NA values.

Arguments that are to be passed to specific methods can be given either directly, if they applies to all given methods. Or, they can be given as a list via the methods argument: There is one list per method that must contain the entry “name” being the method name. Remaining entries in the list corespond to one argument each (see Example below).

See Also

fd.estim.method, fd.get.available.methods, FDloglog, fd.get

Examples

Run this code
# NOT RUN {
library(RandomFields)
n <- 10000
# generate a time series
rf <- GaussRF(x = c(0, 1, 1/n), model = "stable", 
       grid = TRUE, gridtriple = TRUE,
       param = c(mean=0, variance=1, nugget=0, scale=100, kappa=1))

# Plots for two sliding windows of each of the four methods below.
# Argument nlags is common to all methods;
# the 'variation' method has in addition argument p.index
par(mfrow=c(2,4)) # one row per window
fd <- fd.estimate(rf, 
       methods = list(list(name="variation", p.index=0.5), 
       					"variogram", "hallwood", "boxcount"),
       window.size = 5000, step.size = 5000, plot.loglog = TRUE, nlags = 10)
    
# 2d random fields
n <- 200
rf2d <- GaussRF(x = c(0,1, 1/n), y = c(0,1, 1/n), model = "stable", 
         grid = TRUE, gridtriple = TRUE,
         param = c(mean=0, variance=1, nugget=0, scale=1, kappa=1))
par(mfrow=c(2,2))
# plots for 4 sliding windows (2 horizontal, 2 vertical)
fd2d <- fd.estimate(rf2d, methods="filter1",
         window.size = 100, step.size=100, plot.loglog = TRUE)
# }

Run the code above in your browser using DataLab