space.maker | R Documentation |
Creates a multidimensional space with a given number of elements and dimensions
space.maker(
elements,
dimensions,
distribution,
arguments = NULL,
cor.matrix = NULL,
scree = NULL,
elements.names = NULL,
replicates = NULL
)
elements |
An |
dimensions |
An |
distribution |
One or more |
arguments |
Optional |
cor.matrix |
An optional correlation |
scree |
An optional proportional |
elements.names |
Optional, a |
replicates |
Optional, an |
When passing additional arguments to different distributions, these must be given as a list
to each function in the order they appear.
For example if distribution = c(runif, rnorm, rgamma)
and one wants the distributions to be runif(elements, min = 1, max = 10)
, rnorm(elements, mean = 8)
and rgamma(elements, shape = 1, log = TRUE)
, the additional arguments should be passed as
c(list(min = 1, max = 10), list(mean = 8), list(shape = 1, log = TRUE)
. If no arguments have to be passed to a certain function, it can be left as NULL
(e.g. c(list(min = 1, max = 10), list(NULL), list(shape = 1, log = TRUE)
).
The cor.matrix
argument should be a correlation matrix between the dimensions.
If not NULL
, the multidimensional space is multiplied by the the Choleski decomposition (chol
) of the correlation matrix.
The scree
argument is simply a value multiplier for each dimension to adjust their variance to approximate the scree
one.
Thomas Guillerme
null.test
, test.dispRity
.
## A square space
plot(space.maker(5000, 2, runif), pch = 20)
## A circular space
plot(space.maker(5000, 2, rnorm), pch = 20)
## A 2-dimensional cylindrical space
plot(space.maker(5000, 2, c(rnorm, runif)), pch = 20)
## A 4-dimensional space with different distributions
space.maker(5, 4, c(runif, runif, rnorm, rgamma),
arguments = list(list(min = 1, max = 10), list(min = 1, max = 2),
list(mean = 8), list(shape = 1)))
## A 3-dimensional correlated space
cor_matrix <- matrix(cbind(1, 0.8 ,0.2, 0.8, 1, 0.7, 0.2, 0.7, 1), nrow = 3)
space <- space.maker(10000, 3, rnorm, cor.matrix = cor_matrix)
round(cor(space), 1) ; cor_matrix ## Both should be really similar matrices
## A 3-dimensional space with a priori approximated variance for each dimension
space <- space.maker(10000, 3, rnorm, scree = c(0.6, 0.3, 0.1))
## The resulting screeplot
barplot(apply(space, 2, var))
## Generate 3 2D normal spaces with rownames
space.maker(10, 2, rnorm, elements.names = letters[1:10], replicates = 3)
## Not run:
require(scatterplot3d)
## A cube space
scatterplot3d(space.maker(5000, 3, runif), pch = 20)
## A plane space
scatterplot3d(space.maker(5000, 3, c(runif, runif, runif),
arguments = list(list(min = 0, max = 0), NULL, NULL)), pch = 20)
## A sphere space
scatterplot3d(space.maker(5000, 3, rnorm), pch = 20)
## A 3D cylindrical space
scatterplot3d(space.maker(5000, 3, c(rnorm, rnorm, runif)), pch = 20)
## Generating a doughnut space
doughnut <- space.maker(5000, 3, c(rnorm, random.circle),
arguments = list(list(mean = 0), list(runif, inner = 0.5, outer = 1)))
## Reodering the axis for projecting the dougnut in 2D
scatterplot3d(doughnut[,c(2,1,3)], pch = 20)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.