| modelTest | R Documentation |
Use a Monte Carlo significance test to assess whether the measured orientations of a group of structures are compatible with a specified null model in azimuth or declination. The model can be shared across sites or specific to each site.
modelTest(
pdf,
model,
unc = NULL,
nsims = 1000,
conf = 0.95,
tails = 2,
normalise = FALSE,
.res = 0.01,
ncores = NULL,
verbose = TRUE,
hor = NULL,
.transform.res = 0.1,
.prec = 0.1,
.output.res = 0.01
)
pdf |
Empirical skyscapeR.pdf from |
model |
One shared data frame or an ordered list with one table per observation. The first column contains candidate coordinates in degrees and the second contains nonnegative discrete sampling weights, with at least one positive weight. On equally spaced grids, density heights can serve as weights. |
unc |
Optional replacement width in degrees of the input coordinate (azimuth on route 3). Use a standard deviation for normal, half the total span for triangular, or the family-specific half-width documented in |
nsims |
Number of simulations, at least two. Default is 1000. |
conf |
Confidence level as a fraction. |
tails |
1 for upper excesses, 2 for excesses and deficits. |
normalise |
Scale each summed density to unit area before comparison. |
.res |
Spacing of the empirical and simulated comparison grids in degrees. Default 0.01. |
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 |
Display simulation progress. |
hor |
Optional shared skyscapeR.horizon or an ordered list matching the empirical observations. With azimuth inputs, selects a declination test using individual coordinate transformations. Omit for routes 1 and 2. |
.transform.res |
Internal declination transformation spacing, as .res in coordtrans. Default 0.1 degrees. |
.prec |
Azimuth integration spacing for route 3, as in coordtrans. Default 0.1 degrees. |
.output.res |
Stored declination PDF spacing for route 3, as in coordtrans. Default 0.01 degrees. |
A proposed topographical or astronomical explanation can predict some orientations more frequently than others. Testing that explanation requires simulating its predicted distribution at the sites under study.
Silva and Lomsdalen (2025) extended the random-orientation framework of Silva (2020) to test specific hypotheses about temple orientations in Malta, including topographical and astronomical explanations. Here the hypothesis specifies the relative probability of each candidate orientation. A small global p-value is evidence against that particular model.
Input routes. There are three routes:
modelTest(Az, az.model) compares azimuth inputs in azimuth.
modelTest(Dec, dec.model) compares declination inputs in declination.
modelTest(Az, az.model, hor=hor) compares azimuth inputs in declination.
A shared horizon or an ordered list of one horizon per observation is accepted.
Each observed azimuth density is transformed individually with coordtrans.
Each simulation draws azimuth centres, reconstructs their measurement densities,
and transforms each density through its corresponding horizon before summing.
This propagates changes in width, asymmetry and peaks with azimuth, latitude and skyline.
The function never shifts a fixed declination template on this route and does not
transform the summed azimuth density as a shortcut.
Express model coordinates and uncertainties in the input coordinate. Supplying
hor selects route 3 and requires azimuth empirical and model inputs.
Transformation spacings are controlled by .transform.res, .prec
and .output.res; .res controls only the final comparison grid.
Atmospheric settings come from skyscapeR.vars and are recorded in the result.
A uniform azimuth null matches the individual-transformation route of
randomTest when candidate grids, measurement families, horizons,
transformation settings and simulated draws match. Uniform declination weights
generally describe a different null hypothesis.
Each simulation draws one centre per observation according to the weights in its model table. The function constructs an azimuth or declination density around each centre and sums these densities on the same comparison grid as the observed SPD. The observed measurement curves are used as supplied.
Measurement uncertainty. Direct measurement PDFs reuse the family selected in
az.pdf or dec.pdf, including the observation's
taper, survey error and triangular asymmetry. A direct triangular model is
positioned by its mode. Overriding unc rescales its two sides in
proportion; for the two softened uniform families the taper or survey-error
SD stays fixed in degrees.
On route 2, for declinations from coordtrans, omit unc to use each observation's own density as a template.
A model draw represents the expected mean declination for that observation. The function calculates the
density-weighted mean of its piecewise-linear curve and adds (draw minus mean) to every declination.
For example, a curve with mean -17.6 degrees shifts by -4.4 degrees for a draw of -22 degrees.
The shift preserves the curve's width, asymmetry and peaks before interpolation onto the comparison grid.
It requires only the stored declination curve and assumes its shape applies at the modelled mean.
A positive-weight candidate that would shift density beyond -90 or +90 degrees raises an error.
An explicit unc selects a normal density around each simulated centre for transformed input.
With normalise=TRUE, each final SPD has unit area.
Reading the result. The global p-value compares the departure of the entire
observed curve with departures under the specified model. Local results use the largest
qualifying cluster per simulation to adjust for searching the grid. Boundaries describe
where departures were observed. The envelope is pointwise. Both tests use inclusive
Monte Carlo ranks, with minimum p-value 1/(nsims + 1).
See randomTest for the shared scoring rules, width threshold, treatment
of ties and zero variance, and assumptions behind the adjustment. When a model was
fitted to the same observations, its fitting procedure must be accounted for separately.
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 with settings and global/local results in metadata, empirical density and null envelope in data.
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 S02, identical candidate bearings produced identical directly constructed observed and simulated densities on build 2.0.9008. Global rejection at the 5 percent level ranged from 4.35 to 5.50 percent under the six matched null designs. See the S02 check in the technical manual.
Weights are discrete sampling probabilities up to proportionality. If a continuous model is evaluated on an uneven coordinate grid, density heights alone do not represent probability mass; construct weights that account for the bin widths before calling the function. Put site-specific model tables in the same order as the observed measurements.
A large p-value does not prove the proposed explanation or measure its
probability. The test asks whether the specified model is incompatible with
the observed departure statistic. Alternative models can remain compatible.
The simulations do not automatically represent dependence between sites,
selection after viewing the data, or uncertainty in fitted model parameters.
See randomTest for study-design and Monte Carlo limitations.
In six direct-input matched nulls, global rejection at nominal 5 percent ranged from 4.35 to 5.50 percent. The study separately quantifies effects of dependence and skyline transformation. S02 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. \Sexpr[results=rd]{tools:::Rd_expr_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. \Sexpr[results=rd]{tools:::Rd_expr_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. \Sexpr[results=rd]{tools:::Rd_expr_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. \Sexpr[results=rd]{tools:::Rd_expr_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. \Sexpr[results=rd]{tools:::Rd_expr_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. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1086/341527")}.
az.pdf, dec.pdf, coordtrans, spd, randomTest, plot.skyscapeR.sigTest
d <- dec.pdf(dec = c(-18, 12), unc = c(0.8, 1.4))
m <- list(data.frame(x = -20:-16, w = 1), data.frame(x = 10:14, w = 1))
set.seed(42)
fit <- modelTest(d, m, nsims = 10, .res = 0.5,
verbose = FALSE)
print(fit)
## Not run:
set.seed(42)
fit <- modelTest(d, m, nsims = 5000, ncores = 2)
# For transformed observations, model coordinates specify mean declinations.
Az <- az.pdf(az = c(87, 110), unc = 2)
hor <- createHor(az = c(0, 360), alt = c(0, 0), alt.unc = 0.1, loc = c(35, -8))
# Route 3: both inputs in azimuth, test in declination.
az.model <- data.frame(x = seq(0, 359.9, by = 0.1), w = 1)
fit <- modelTest(Az, az.model, hor = hor, nsims = 100, ncores = 1)
# Route 2: both inputs in declination, shift the transformed templates.
Dec <- coordtrans(Az, hor)
fit <- modelTest(Dec, data.frame(x = c(-22, 18), w = c(1, 1)))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.