Wednesday, 6 February 2013

Financial Candlestick chart for archaeological purposes: preliminary tests

Candlesticks chart is a plot used primarily in finance for describing price movements of quoted stock, derivative or currency over time. It is a combination of a line-chart and a bar-chart:

Chart made by R package "Quantmod"

the wick (i.e. one or two lines coming out from the polygon) illustrates the highest and lowest traded prices during the time interval represented; the body (i.e. the polygon) illustrates the opening and closing trades. Candlesticks chart seems apparently similar to box plots, but they are totally different (source: Wikipedia, 05/02/2013).
I often saw this kind of chart in newspapers or in TV, but only now I have undertaken to understand how it works; and so I had the “crazy” idea of applying candlesticks chart to archaeological data.
More specifically I thought about archaeological finds. For many of them - in particular for ceramic types - we know a starting date, i.e. the period in which a specific production begins, a time range of maximum diffusion, defined by an initial moment and a final one, and an end date after which there are no more traces of our object.
If we replace the 4 financial values of higest, lowest, opening and closing price with these 4 chronological value (starting date, initial and final moments of maximum diffusion's range, end date), we could use profitably candle plot for describing the life's path of each archaeological material found in a stratigraphic unit (US); the goal is to date the same US by comparing the candlesticks of all materials contained therein.

In R Candlesticks chart is provided by Quantmod package, Quantitative Financial Modelling & Trading Framework for R ( But this package is very specific for financial purposes and requires specific data types like time series (xts): so I put aside the idea of using the Quantmod package and I tried to build a new R function for plotting candlesticks with non-financial data.
This is a first (simplified) example of my preliminary tests (for which I have to thank R-help mailing list:

I built a table like this:

find, min, int_1, int_2, max
find_a, 250, 300, 400, 550
find_b, 200, 350, 400, 450
find_c, 350, 400, 450, 500
find_d, 250, 350, 450, 500
find_e, 200, 400, 500, 600

For each archaeological object (find_a, find_b, find_c, …) is given the starting date (min), the initial and final moments of maximum presence range (int_1, int_2) and the end date (max), all in approximate years.
I plotted this dataframe in R using “with()” function that enables to build a personal environment from data. Here is the source code:

> US1 <- read.table("../example.txt", header=TRUE, sep=",")
> with(US1, symbols(find, (int_1 + int_2)/2, boxplots=cbind(.4,int_2-int_1,int_1-min,max-int_2,0), inches=F, ylim=range(US1[,-1]), xaxt="n", ylab="Years (AD)", xlab="Findings", main="Findings chronological distribution of US 1", fg="brown", bg="orange", col="brown"))

and here is the result:

Analyzing this plot it is possible to deduce that the layer US1 probably dates back to the first half of 5th century A.D.; the materials find_a and find_b could be residuals of previous ages.

As I said, this is just a simple example, but potentialities are clear. This method enables to plot the duration of archaeological materials and to compare the datings of objects found in stratigraphic units for assigning them a chronological information. The statistical environment could provide other advantages like probabilistic analyses, confidence intervals, etc., giving a mathematical-statistical support to the usual (and often subjective) dating of the archaeological layers.
The next steps will be the building of a specific R function for “archaeological” candle plot, starting from the simple code written above, and tests to plot the duration of archeological finds with other statistical techniques like seriation, boxplot, etc.

Any suggestions, websites, literature and bibliographic references about this topic, advice on R packages different from Quantmod that provide candlesticks chart without financial data are welcomed.

by Denis Francisci
BlogItalia - La directory italiana dei blog Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.