Skip to content

Commit

Permalink
renamed area diff to displacement diff
Browse files Browse the repository at this point in the history
  • Loading branch information
TGuillerme committed Mar 12, 2019
1 parent 4bf3b43 commit ae7bfb2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
24 changes: 12 additions & 12 deletions inst/vignettes/Landmark_partition_test.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,17 @@ land_front <- c(2, 11, 12)
The idea is to see whether the landmark variation is greater in the landmarks in the front of the skull and relatively smaller in the back of the skull.
We can measure that using two different statistics:

* The **area difference** that is the proxy of the cumulative landmark variation
* The **displacement difference** that is the proxy of the cumulative landmark variation
* The **Bhattacharyya Coefficient** which is the probability of overlap between two distributions

Of course, any other type of statistics can be used in the test that follows.
These two however are a pretty intuitive proxy for testing our hypothesis above.

### The Area difference
### The Displacement difference

This statistic can be measured as follows:

$\Delta_{area} = \int_{0}^{n-1} (f_{x} - f_{y})d(x,y)$
$\Delta_{displacement} = \int_{0}^{n-1} (f_{x} - f_{y})d(x,y)$

Where _n_ is minimum number of comparable landmarks and $f_{x}$ and $f_{y}$ are ranked functions (i.e. $f_{0} \geq f_{1} \geq f_{2} ...$) for the landmarks in the partition and all the landmarks respectively.
If one of the functions $f_{x}$ or $f_{y}$ have _m_ elements (with $m > n$) $f^{*}_{z}$, a rarefied estimated of the function with _m_ elements is used instead.
Expand All @@ -209,7 +209,7 @@ This statistic is implemented in `landvR` in the `area.diff` function that simpl
distribution_1 <- rnorm(10)
distribution_2 <- rnorm(10)
## Their area difference
## Their displacement difference
area.diff(distribution_1, distribution_2)
```

Expand All @@ -235,7 +235,7 @@ bhatt.coeff(distribution_1, distribution_2)
### Random permutation test

Now that we have two statistics (note that one could be sufficient), we can finally test our hypothesis using a random permutation test.
This test measures for on statistic between two populations (e.g. the area difference between the landmarks variation in the front or the back of the skull) come from the same global statistical population (H0) or different ones (H1).
This test measures for on statistic between two populations (e.g. the displacement difference between the landmarks variation in the front or the back of the skull) come from the same global statistical population (H0) or different ones (H1).

First we measured the statistic between the landmark partition of interest and all the other landmarks (including the ones from the partition).
Second, we generated 1000 statistics by randomly sampling the same number of landmarks as in the partition in the whole distributions and compared them again to the full distribution.
Expand Down Expand Up @@ -340,21 +340,21 @@ This function allows to pass the statistic as a function to the `test` argument
We can use the argument `test.parameter` to calculate the _p_ value as outlined above (note that by default, these tests are two sided).

```{r}
## The random permutation test for the area difference between species
## The random permutation test for the displacement difference between species
sp_mean_test_area <- rand.test(species_means_difference[[1]][, "radius"], subset = land_front,
test = area.diff, test.parameter = TRUE)
## The random permutation test for the probability of overlap between species
sp_mean_test_bc <- rand.test(species_means_difference[[1]][, "radius"], subset = land_front,
test = bhatt.coeff, test.parameter = TRUE)
## The random permutation test for the area difference within both species
## The random permutation test for the displacement difference within both species
all_sp_test_area <- rand.test(all_spec_difference$range[, "radius"], subset = land_front,
test = area.diff, test.parameter = TRUE)
## The random permutation test for the probability of overlap within both species
all_sp_test_bc <- rand.test(all_spec_difference$range[, "radius"], subset = land_front,
test = bhatt.coeff, test.parameter = TRUE)
## The random permutation test for the area difference within both species
## The random permutation test for the displacement difference within both species
ci95_sp_test_area <- rand.test(ci95_spec_difference$range[, "radius"], subset = land_front,
test = area.diff, test.parameter = TRUE)
## The random permutation test for the probability of overlap within both species
Expand All @@ -370,7 +370,7 @@ sp_mean_test_area
```

The `Observation` value is the observed statistic in the subset.
For example, this can be the area difference or the probability of overlap in landmark displacement between the two tested specimens in the tested subset (here the front of the skull).
For example, this can be the displacement difference or the probability of overlap in landmark displacement between the two tested specimens in the tested subset (here the front of the skull).
This value is then compared to 100 replicated random values that are equivalent of measuring this statistic over any randomly picked landmark displacements.
The _p_ value will indicate the type I error when rejecting the null hypothesis (that is: the landmarks in the subset are not different than the other).

Expand All @@ -381,20 +381,20 @@ To facilitate interpreting these results, it is possible to plot them:
par(mfrow = c(3,2))
## Plotting one result
plot(sp_mean_test_area, main = "Species mean area difference")
plot(sp_mean_test_area, main = "Species mean displacement difference")
## Adding the p value
legend("topright", legend = paste("p =", round(sp_mean_test_area$pvalue, 3)), bty = "n")
## Plotting the other results
plot(sp_mean_test_bc, main = "Species mean Bhattacharyya Coefficient")
legend("topright", legend = paste("p =", round(sp_mean_test_bc$pvalue, 3)), bty = "n")
plot(all_sp_test_area, main = "Overall range area difference")
plot(all_sp_test_area, main = "Overall range displacement difference")
legend("topright", legend = paste("p =", round(all_sp_test_area$pvalue, 3)), bty = "n")
plot(all_sp_test_bc, main = "Overall range Bhattacharyya Coefficient")
legend("topright", legend = paste("p =", round(all_sp_test_bc$pvalue, 3)), bty = "n")
plot(ci95_sp_test_area, main = "Overall range area difference")
plot(ci95_sp_test_area, main = "Overall range displacement difference")
legend("topright", legend = paste("p =", round(ci95_sp_test_area$pvalue, 3)), bty = "n")
plot(ci95_sp_test_bc, main = "Overall range Bhattacharyya Coefficient")
legend("topright", legend = paste("p =", round(ci95_sp_test_bc$pvalue, 3)), bty = "n")
Expand Down
32 changes: 16 additions & 16 deletions inst/vignettes/Landmark_partition_test.html

Large diffs are not rendered by default.

0 comments on commit ae7bfb2

Please sign in to comment.