The R script in this repository does Local Density Analysis, as implemented in the LDEN.exe program in Keith Kintigh's Tools for Quantitative Archaeology (TFQA). The method is described in Johnson (1984:83-85) and Kintigh (1990), as well as in the TFQA documentation. The original description of the method is apparently in Johnson's (1976) thesis from the University of Bordeaux, but I have not been able to obtain a copy.
The R script currently includes five functions that produce a dataframe containing local density coefficients (generated by lda(), which depends on the other functions). The other functions return various forms of intermediate data:
distance_matrix() returns a square matrix of the distances from every point in the data file to every other point;
local_counts() returns a dataframe with the counts, by type, of points within the specified distance of each point (the distance is specified by the argument 'radius')
local_density() returns a dataframe (formatted the same as the one produced by local_counts) in which the counts are divided by the area of the circle defined by the specified radius
glb_density() returns a vector of the global densities of points of each type. The global density is the number of points of the type divided by the total site area.
lda() directly uses the dataframe from local_density() and the vector of global densities from gld_density() to calculate intratype and between-type local density coefficients, with the local density coefficient from Type A to Type B defined as the mean density of points of Type B within the specified radius of points of Type A, divided by the global density of points of Type B.
====================================================================
Resources for Testing the Code
The repository also includes two data files, and output from the original TFQA program LDEN.exe for the data in the files.
One of the data files, LDEN.csv was included with TFQA as a test file. It has data for 16 points and seven types (types are designated using the numbers 0, 2, 4, 10, 11, 12, and 13). As far as I know, the data is made up.
#'AZ_A1020_BLM_point_plots.csv' contains point location and type data for 358 "diagnostic" surface artifacts from an Ancestral Pueblo site on the Shivwits Plateau in northwestern Arizona. In the Arizona site numbering system, the site number is formally "AZ A:10:20 (BLM)", so part of the overly long file name is a actually simplification of that. This is real data, although somewhat simplified here, and not organized quite as I would organize it for a real analysis. There are five types (three of them rare), and the two most common 'types' group artifacts that have more detailed identifications ("ceramics" = either painted potsherds or sherds from vessel rims; "stone tool" = any flaked stone tool except for projectile points).
For each data file there are four matching files of output from LDEN.exe: the .txt files contain the local density coefficients for radii of 1, 2, and 5 meters. The .out files have the counts for the local neighborhoods of each point. The R script formats the output differently, but if you run the code at the end of the script, lda_test should have the same local density coefficients as the .txt file that used the same data. Similarly, counts_test should have the same counts as the .out file that uses the same data and radius.
LDEN.exe expects the type designations to be numbers, so the AZ_A1020... output from LDEN.exe shows types 1-5 rather than descriptive type names. The numbers correspond to the types in the .csv in alphabetical order (1 = bead, 2 = ceramic, 3 = groundstone, 4 = projectile point, 5 = stone tool). The types should be in the same order in all the output files.
==================================================================== References
Johnson, Ian 1976 Contribution méthodologique a l'étude de la répartition des vestiges dans des niveaux archéologiques. DES (Diplome des Études Superieurs) Thesis, Universite de Bordeaux I.
1984 Cell Frequency Recording and Analysis of Artifact Distributions. In Intrasite Spatial Analysis in Archaeology, edited by Harold Hietala, pp. 75-96. University of Cambridge Press.
Kintigh, Keith W. 1990 Intrasite Spatial Analysis: A Commentary on Major Methods. In Mathematics and Information Science in Archaeology: A Flexible Framework, edited by Albertus Voorrips, pp. 165-200. Holos, Bonn.