| bits.test | R Documentation |
Performs a Balanced Independent Two-Stage Monte Carlo test of goodness-of-fit for spatial pattern.
bits.test(X, ...,
exponent = 2, nsim=19,
alternative=c("two.sided", "less", "greater"),
leaveout=1, interpolate = FALSE,
savefuns=FALSE, savepatterns=FALSE,
verbose = TRUE)
X |
Either a point pattern dataset (object of class |
... |
Arguments passed to |
exponent |
Exponent used in the test statistic. Use |
nsim |
Number of replicates in each stage of the test.
A total of |
alternative |
Character string specifying the alternative hypothesis.
The default ( |
leaveout |
Optional integer 0, 1 or 2 indicating how to calculate the deviation between the observed summary function and the nominal reference value, when the reference value must be estimated by simulation. See Details. |
interpolate |
Logical value indicating whether to interpolate the distribution of the test statistic by kernel smoothing, as described in Dao and Genton (2014, Section 5). |
savefuns |
Logical flag indicating whether to save the simulated function values (from the first stage). |
savepatterns |
Logical flag indicating whether to save the simulated point patterns (from the first stage). |
verbose |
Logical value indicating whether to print progress reports. |
Performs the Balanced Independent Two-Stage Monte Carlo test proposed by Baddeley et al (2017), an improvement of the Dao-Genton (2014) test.
If X is a point pattern, the null hypothesis is CSR.
If X is a fitted model, the null hypothesis is that model.
The argument use.theory passed to envelope
determines whether to compare the summary function for the data
to its theoretical value for CSR (use.theory=TRUE)
or to the sample mean of simulations from CSR
(use.theory=FALSE).
The argument leaveout specifies how to calculate the
discrepancy between the summary function for the data and the
nominal reference value, when the reference value must be estimated
by simulation. The values leaveout=0 and
leaveout=1 are both algebraically equivalent (Baddeley et al, 2014,
Appendix) to computing the difference observed - reference
where the reference is the mean of simulated values.
The value leaveout=2 gives the leave-two-out discrepancy
proposed by Dao and Genton (2014).
A hypothesis test (object of class "htest"
which can be printed to show the outcome of the test.
The result of bits.test is an object of
class "htest" representing the outcome of the hypothesis test.
The p-value is contained in the component p.value
and is printed when the test object is printed.
The test outcome is statistically significant (that is, the null hypothesis is
rejected) at significance level \alpha if the
p value is less than or equal to \alpha,
where \alpha should be a multiple of 1/(nsim+1).
Programmers are warned that the wrong answer may be obtained
from the comparison p.value <= alpha
due to numerical error.
For bits.test,
these numerical comparison errors are very unlikely to occur
if alpha is coded as a ratio of integers k/(nsim+1)
rather than being given in decimal notation
(for example, write alpha=1/20 rather than
alpha=0.05).
Numerical comparison errors can be prevented by replacing the
floating point comparison p.value <= alpha with
the integer comparison
round(p.value * (nsim+1)) <= round(alpha * (nsim+1))
where nsim can be retrieved as attr(result, "nsim").
Alternatively use the floating point comparison
p.value <= alpha + .Machine$double.eps.
Adrian Baddeley, Andrew Hardegen, Tom Lawrence, Robin Milne, Gopalan Nair and Suman Rakshit. Implemented by \spatstatAuthors.
Dao, N.A. and Genton, M. (2014) A Monte Carlo adjusted goodness-of-fit test for parametric models describing spatial point patterns. Journal of Graphical and Computational Statistics 23, 497–517.
Baddeley, A., Diggle, P.J., Hardegen, A., Lawrence, T., Milne, R.K. and Nair, G. (2014) On tests of spatial pattern based on simulation envelopes. Ecological Monographs 84 (3) 477–489.
Baddeley, A., Hardegen, A., Lawrence, L., Milne, R.K., Nair, G.M. and Rakshit, S. (2017) On two-stage Monte Carlo tests of composite hypotheses. Computational Statistics and Data Analysis 114, 75–87.
Simulation envelopes: bits.envelope.
Other tests:
dg.test,
dclf.test,
mad.test.
ns <- if(interactive()) 19 else 4
bits.test(cells, nsim=ns)
bits.test(cells, alternative="less", nsim=ns)
bits.test(cells, nsim=ns, interpolate=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.