null.test: Testing a null hypothesis on multidimensional data.

View source: R/null.test.R

null.testR Documentation

Testing a null hypothesis on multidimensional data.

Description

Testing the difference between the observed disparity and disparity under a null model.

Usage

null.test(
  data,
  replicates = 100,
  null.distrib,
  null.args = NULL,
  null.cor = NULL,
  null.scree = NULL,
  alter = "two-sided",
  scale = FALSE,
  ...
)

Arguments

data

a dispRity object.

replicates

the number of replicates for the test (default = 100).

null.distrib

one or more distribution functions to generate the null model to be passed to space.maker.

null.args

any additional distribution arguments to be passed to space.maker (see arguments within; default = NULL).

null.cor

an additional correlation matrix to be passed to space.maker (see cor.matrix within; default = NULL).

null.scree

an additional vector of variance per axis (equivalent to screeplot output); default = NULL).

alter

the type of alternative hypothesis (H1) as used in randtest (default = "two-sided").

scale

whether to scale the simulated and the observed data.

...

optional arguments to be passed to as.randtest.

Author(s)

Thomas Guillerme

References

Diaz, S., Kattge, J., Cornelissen, J.H., Wright, I.J., Lavorel, S., Dray, S., Reu, B., Kleyer, M., Wirth, C., Prentice, I.C. and Garnier, E., 2016. The global spectrum of plant form and function. Nature, 529(7585), pp.167-171.

See Also

space.maker, test.dispRity

Examples

## Load the Beck & Lee 2014 data
data(BeckLee_mat50)
## Calculating the disparity as the ellipsoid volume
obs_disparity <- dispRity(BeckLee_mat50, metric = ellipse.volume)
## Testing against normal distribution
results <- null.test(obs_disparity, replicates = 100, null.distrib = rnorm)
results ; plot(results)

## Running the test on multiple subsets (may take some time!)
## Generating the subsets
groups <- as.data.frame(matrix(data = c(rep(1, 12), rep(2, 13), rep(3, 12),
     rep(4, 13)), dimnames = list(rownames(BeckLee_mat50))), ncol = 1)
customised_subsets <- custom.subsets(BeckLee_mat50, groups)
## Bootstrapping the data
bootstrapped_data <- boot.matrix(customised_subsets, bootstraps = 100)
## Calculating variances of each dimension
sum_variances <- dispRity(bootstrapped_data, metric = c(sum, variances))
## Testing against normal distribution
results <- null.test(sum_variances, replicates = 100, null.distrib = rnorm)
summary(results) ; plot(results)


dispRity documentation built on Aug. 9, 2022, 5:11 p.m.