Use a Monte Carlo significance test to assess whether the measured orientations of a group of structures are compatible with uniformly random azimuths, taking their uncertainties and, for a declination comparison, their horizons into account.
randomTest(
pdf,
az,
hor,
nsims = 1000,
conf = 0.95,
tails = 2,
normalise = F,
.res = 0.1,
ncores = NULL,
verbose = T
)
pdf |
A skyscapeR.pdf object created with either |
az |
Original azimuth skyscapeR.pdf; required only when |
hor |
For azimuth input, optionally supply one shared skyscapeR.horizon
to test in declination. For declination input, required: the original shared
horizon or an ordered list matching the distributions in |
nsims |
Number of simulations, at least two. Default is 1000. |
conf |
Confidence level as a fraction. For example, 0.95 requests a 95 percent envelope. |
tails |
1 for upper excesses, 2 for excesses and deficits (default). |
normalise |
Logical to control whether to normalize SPDs. Default is FALSE |
.res |
Resolution with which to output probability distribution(s). Default is 0.1 degrees. |
ncores |
Worker count. By default use half the detected available logical cores, rounded down with a minimum of one. Set ncores=1 for serial execution. The simulation count and memory batch size can further limit workers. Verbose output reports the effective count. |
verbose |
Logical. Display progress or informational messages. Default |
Following Silva (2020), the test combines the observed measurement densities into a summed probability density (SPD).
For each simulated dataset, the function draws one azimuth per measurement with replacement
from the uniform grid from 0 to 360 degrees at the source azimuth spacing. It applies the
source density family and measurement uncertainties and constructs a comparable SPD.
All six families from az.pdf are supported. Simulated centres are
uniformly distributed under the null. At each centre the original observation's
taper, survey error or triangular left/right proportions are reused. For a
triangle the sampled bearing is its mode.
For a declination test, random azimuths are transformed using the site geometry; the
resulting null distribution in declination depends on latitude and horizon.
A new transformation takes its atmosphere from skyscapeR.vars. A saved declination PDF supplies its original settings. The fit records these in metadata$atmosphere for declination tests.
Input coordinates. With azimuth input alone, all curves are compared in azimuth. With azimuth input and one
shared horizon, the function sums the azimuth densities before transforming the SPD.
With a transformed declination PDF, supply its original az and hor in measurement
order. Simulated measurements are then transformed individually before summation, using the
stored refraction and atmosphere settings. Newer PDFs store the
transformation grid spacings; older PDFs use the legacy defaults. The comparison grid uses
.res. The two transformation routes can give different results.
If normalise=TRUE, each final curve has unit trapezoidal area. Each parallel worker
receives its own copy of the required horizons.
Scoring the curves. At each angle, the observed summed density and all simulated summed densities jointly define a pointwise envelope at confidence
level conf. An upper-tail test scores excesses; a two-tailed test also scores deficits,
using equal tail probabilities for the bounds. For every curve, each departure beyond a bound
is divided by the standard deviation of all B+1 curves at that angle. Ties at a bound contribute zero.
The global statistic sums the departure magnitudes across the grid. A small global p-value
means that few simulated datasets depart from the envelope as much as the observed dataset.
Interpreting local intervals. Local results identify contiguous clusters of departures on the stored linear grid. At least two consecutive points must cross the same bound and span at least 0.5 degrees, inclusive. The same selection and width filter apply to every simulated curve. Each observed cluster's summed departure magnitude is compared with the largest qualifying cluster in each simulation (zero if none), across both signs in a two-tailed test. The inclusive rank gives a maximum-cluster adjusted p-value. Under the complete specified null and exchangeable curves this controls the probability of reporting any cluster as significant, accounting for the interval search. It is not strong error control for arbitrary mixtures of true and false local nulls, and does not establish that every angle inside a cluster is significant or that its endpoints are confidence limits. Azimuth scoring counts each direction once and joins qualifying excursions across north for both observed and simulated curves. A start greater than the end denotes a wrapped interval. Declination retains its two endpoints. The filter does not change the global test. The maximum-cluster principle is adapted from Maris and Oostenveld (2007); cluster interpretation follows Sassenhagen and Draschkow (2019).
If all B+1 curves agree at an angle, its standard deviation is zero and it contributes zero.
When only the simulations agree, a differing observation remains in the pooled calculation
and can contribute to the score. Such points are also listed in
result$data$constant.departures with coordinate x (degrees), observed
and simulated densities and direction (above or below), for either tail setting.
Monte Carlo ranks. Global and local Monte Carlo p-values use (b+1)/(B+1), where B is the number of simulations and b counts simulated scores at least as large as the observed score, including ties (North, Curtis and Sham, 2002). The minimum is 1/(B+1); all ties give 1. The observation enters the pooled bounds, mean and standard deviation once. The envelope describes each grid point separately. The rank test assumes that observed and simulated curves are exchangeable under the specified null (Dufour, 2006). Apply the same uncertainty and transformation procedures to both. If you estimate the null model from these observations, account for that fitting when interpreting the test.
Running simulations. With a fixed seed, sampling in the calling session gives the same result for different worker counts. For grids larger than 16 MiB, allow about eight bytes of temporary disk space per simulation per grid point. Temporary files are removed on return or error.
A skyscapeR.sigTest list containing metadata (test settings, global and local p-values) and data (empirical SPD and null confidence envelope). No original PDFs or horizon objects are attached.
In S03, independent scoring reproduced the azimuth and declination ranks on their respective grids. Build 2.0.9006 counts north once and reports one interval for a qualifying excess across north. Refit earlier azimuth tests to obtain the revised probabilities. See S03 validation in the technical manual.
In S01, at a nominal 5 percent level the global rejection rate was 4.25 to 5.85 percent across the tested uniform-null settings with sufficient Monte Carlo resolution. Build 2.0.9007 uses the source azimuth density spacing and cutoff for simulations and matches the observed SPD spacing on the shared-horizon route. Refit earlier analyses that used different settings. See the S01 calibration in the technical manual.
The 500-simulation Ggantija-phase workflow in W02 reproduced the bundled global probability, local intervals and adjusted probabilities. See the W02 check in the technical manual.
The simulated null describes independently sampled orientations with the specified site geometry and measurement model. It does not automatically model shared construction episodes, correlated measurement errors, geographical clustering or selection of sites after inspecting their orientations. Such structure needs a justified sampling model or separate sensitivity analysis.
The pointwise envelope is not a simultaneous confidence band. A significant
global result rejects the specified random-orientation model; it does not
identify a celestial target. Refine the comparison grid and increase
nsims to assess borderline results, preserving the seed and inputs.
More simulations improve Monte Carlo resolution, not the validity of the
archaeological sampling design. Repeated searches over alternative subsets or
models are not included in the within-fit local-cluster adjustment.
At nominal 5 percent, global rejection across tested uniform nulls with attainable ranks ranged from 4.25 to 5.85 percent. S01 study.
The fixed uniform-null example returned a global probability of 0.4375 and an adjusted probability of 0.1875 for its cluster crossing north. S03 study.
The field-to-sky replay recovered the Gacrux position between the Skorba West entrance edges, 2.41 degrees above the measured skyline at the illustrated instant. W02 study.
Silva, F. (2020). A probabilistic framework and significance test for the analysis of structural orientations in skyscape archaeology. Journal of Archaeological Science, 118, 105138. doi:10.1016/j.jas.2020.105138.
Silva, F. and Lomsdalen, T. (2025). ‘No easy way from the earth to the stars’: a new statistical approach to the orientation of the Maltese temples. Archaeological and Anthropological Sciences, 17, 96. doi:10.1007/s12520-025-02208-4.
Maris, E. and Oostenveld, R. (2007). Nonparametric statistical testing of EEG- and MEG-data. Journal of Neuroscience Methods. doi:10.1016/j.jneumeth.2007.03.024.
Sassenhagen, J. and Draschkow, D. (2019). Cluster-based permutation tests of MEG/EEG data do not establish significance of effect latency or location. Psychophysiology. doi:10.1111/psyp.13335.
Dufour, J.-M. (2006). Monte Carlo tests with nuisance parameters: A general approach to finite-sample inference and nonstandard asymptotics. Journal of Econometrics, 133, 443-477. doi:10.1016/j.jeconom.2005.06.007.
North, B. V., Curtis, D. and Sham, P. C. (2002). A note on the calculation of empirical P values from Monte Carlo procedures. American Journal of Human Genetics, 71, 439-441. doi:10.1086/341527.
az.pdf, coordtrans, spd, hpdi, modelTest
## Not run:
# significance test for azimuth
Az <- az.pdf(az=c(87,93,90,110), unc=3)
st1 <- randomTest(Az, nsims=1000)
plot(st1)
# significance test for declination
hor <- createHor(az=c(0,360), alt=c(0,0), loc=c(35,-8,25)) # flat horizon
Dec <- coordtrans(Az, hor)
st2 <- randomTest(Dec, az=Az, hor=hor, nsims=1000)
plot(st2)
## End(Not run)