# NOT RUN {
quadrat.test(simdat)
quadrat.test(simdat, 4, 3)
quadrat.test(simdat, alternative="regular")
quadrat.test(simdat, alternative="clustered")
## Likelihood ratio test
quadrat.test(simdat, CR=0)
## Power divergence tests
quadrat.test(simdat, CR=-1)$p.value
quadrat.test(simdat, CR=-2)$p.value
# Using Monte Carlo p-values
quadrat.test(swedishpines) # Get warning, small expected values.
# quadrat.test(swedishpines, method="M", nsim=4999)
# quadrat.test(swedishpines, method="M", nsim=4999, conditional=FALSE)
# }
# NOT RUN {
# quadrat counts
qS <- quadratcount(simdat, 4, 3)
quadrat.test(qS)
# fitted model: inhomogeneous Poisson
fitx <- ppm(simdat ~ x)
quadrat.test(fitx)
# an equivalent test (results differ due to discretisation effects):
quadrat.test(simdat, lambda=predict(fitx), df.est=length(coef(fitx)))
te <- quadrat.test(simdat, 4)
residuals(te) # Pearson residuals
plot(te)
plot(simdat, pch="+", cols="green", lwd=2)
plot(te, add=TRUE, col="red", cex=1.4, lty=2, lwd=3)
sublab <- eval(substitute(expression(p[chi^2]==z),
list(z=signif(te$p.value,3))))
title(sub=sublab, cex.sub=3)
# quadrats of irregular shape
B <- dirichlet(runifpoint(6, Window(simdat)))
qB <- quadrat.test(simdat, tess=B)
plot(simdat, main="quadrat.test(simdat, tess=B)", pch="+")
plot(qB, add=TRUE, col="red", lwd=2, cex=1.2)
# }
Run the code above in your browser using DataLab