# Estimate the fractal dimension of two dimensional data in R

0 down vote favorite

I am trying to estimate the fractal dimension of a list of coordinates, such as:

``````          X1        X2
1  0.6073672 0.6663980
2  0.6837522 0.6080113
3  0.5109583 0.6071990
4  0.4456634 0.2165213
5  0.6773562 0.6667185
6  0.6593706 0.6774323
7  0.5778927 0.7234859
8  0.3655071 0.3496862
9  0.4694057 0.2875728
10 0.4258961 0.4424538
``````

I was hoping to use a package like fractaldim, but it seems that I can not pass my data since it is not a square matrix.

Does anyone have an idea how I can solve this?

Background: I am trying to calculate clusters using the fractal dimension (see "Using Self-Similarity to Cluster Large Data Sets" http://dl.acm.org/citation.cfm?id=635431.635447)

EDIT1 My Data looks like this: You ask the same question in Matrix,Estimate the fractal dimension of two dimensional data in R

I was hoping to use a package like fractaldim, but it seems that I can not pass my data since it is not a square matrix.

``````x = c(0.6073672, 0.6837522, 0.5109583, 0.4456634, 0.6773562, 0.6593706, 0.5778927, 0.3655071, 0.4694057, 0.4258961)
y = c(0.666398, 0.6080113, 0.607199, 0.2165213, 0.6667185, 0.6774323, 0.7234859, 0.3496862, 0.2875728, 0.4424538)
fd.estim.boxcount(cbind(x,y),plot.loglog=TRUE, plot.allpoints=TRUE, nlags="auto")
`````` ``````fd.estim.squareincr (cbind(x,y), p.index = 1, plot.loglog = TRUE, plot.allpoints = TRUE)
`````` And others, but I don't know what you want exactly (How do you use R to find the box counting dimension of a two dimensional set of data, or scatter plot?) and unfortunately there are many "fractal" dimensions.

In Python, look at Fractal Dimension and Box Counting or Fractal Dimension Computation in Python Code

## New

In fractaldim

Implements various methods for estimating fractal dimension of time series and 2 dimensional data.

In each example, there is a command with `# 1d time series` and `# 2d random fields`

``````# for 2d random fields
fd2d = fd.estim.boxcount(cbind(x,y),plot.loglog=TRUE, plot.allpoints=TRUE, nlags="auto")
fd2d['fd'] # fractal dimension
\$fd
 1.295456
``````

The problem is that you must understand the various parameters of the library.

• Thank you for your suggestions. As I get this right, `fd.estim.boxcount` is for timeseries data. I will extend my question in EDIT1 and give more details on my case – user86211 Nov 12 '16 at 19:46
• `fd.estim.boxcount is for timeseries data`, is not true , look above in New – gene Nov 13 '16 at 10:37
• It is important to note that these data do not look fractal. This is borne out by the strong nonlinearity of the second plot. In short, the best advice to give at this juncture might be don't estimate the fractal dimension, because it does not make sense for these data. – whuber Nov 14 '16 at 15:34
• I agree with you. My answer is to clarify the use of `fractaldim` – gene Nov 14 '16 at 17:07

I'm sorry but `fd.estim.boxcount` is indeed for timeseries data only, as it is clearly depicted in the package help file.

You can test this by changing the order of the lines in the x,y vectors and checking the results:

``````x = c(0.6073672, 0.6837522, 0.5109583, 0.4456634, 0.6773562, 0.6593706, 0.5778927, 0.3655071, 0.4694057, 0.4258961)
y = c(0.666398, 0.6080113, 0.607199, 0.2165213, 0.6667185, 0.6774323, 0.7234859, 0.3496862, 0.2875728, 0.4424538)

ordr <- sample(seq_along(x)); fd.estim.boxcount(cbind(x[ordr], y[ordr]))\$fd
#  1.725825
ordr <- sample(seq_along(x)); fd.estim.boxcount(cbind(x[ordr], y[ordr]))\$fd
#  1.347923
``````

I think we can agree that fractal dimensionality should not change depending on the order of the values processed.