---
title: "PP Hypothesis Tests"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
knitr::opts_chunk$set(warning = FALSE)
knitr::opts_chunk$set(message = FALSE)
knitr::opts_chunk$set(fig.align= 'center')
knitr::opts_chunk$set(fig.height= 4)
knitr::opts_chunk$set(fig.width = 6)
library(tidyverse)
library(gridExtra)
```

### Hypothesis Tests for CSR

\vfill

\vfill

\vfill

```{r}
set.seed(03312021)
n <- rpois(4, 50)

x <- c(rbeta(n[1], 1, 1), rbeta(n[2], 1, 1), rbeta(n[3], 3, 1),rbeta(n[4], 3, 3))
y <- c(rbeta(n[1], 1, 1), rbeta(n[2], 1, 1), rbeta(n[3], 3, 1),rbeta(n[4], 3, 3))

data.frame(group = c(rep(1, n[1]), rep(2, n[2]), rep(3, n[3]), rep(4, n[4])), x = x, y = y) %>% ggplot(aes(x=x, y=y)) + geom_point(alpha=.6) + facet_wrap(~group) + theme_bw()
```
\vfill
\vfill
\vfill
\newpage

#### G and F Functions

One way to describe a spatial point process, is to consider the probability of being a certain distance from a point or similarly, the number of points expected in a distance from a point.
\vfill


\vfill



\vfill
\vfill

\vfill
A similar statistic is the $F(d)$ function. Whereas $G(d)$ is centered at the observed $\boldsymbol{s}_i$, $F(d)$ is defined at any arbitrary point. *Hence this is a CDF for empty space*.
\vfill

\newpage

Discuss how to create an empirical estimate of $\hat{G}(d)$, given a realization of a point process.

\vfill

With bounded area, edge correction procedures are necessary. 

$$\hat{G}(d) = \frac{\sum_i 1(d_i \leq d < b_i)}{\sum_i 1(d < b_i)},$$

\vfill
The empirical estimates of $G$ or $H$ can be compared with $G$ or $F$ using a QQ-plot.

\vfill

- __Discuss:__ What would be the implications of shorter tails or longer tails than expected under CSR? *shorter tail = clustering/attraction, longer tail = inhibition/repulsion*
\vfill

Describe a natural process that might cluster and another than might repel
\vfill
