generator | R Documentation |
This function generates univariate and multivariate normal data. It allows simulating correlated and independent samples. Moreover, normality tests and numeric informations are provided.
generator(n , mean = 0, sigma = 1, coefvar = NULL, sigmaSup = NULL, dec = 2)
n |
vector size of samples. |
mean |
vector of means. |
sigma |
vector of standard deviations or covariance/correlation matrix. |
coefvar |
an optional vector of coefficients of variation. |
sigmaSup |
an optional vector of standard deviations if sigma is a correlation matrix. |
dec |
number of decimals for observations. |
If mean
or sigma
are not specified it's assumed the default values of 0
and 1
.
If coefvar
(= sigma
/mean
) is specified, function omits sigma
and sigmaSup
. It's assumed that independent samples are desired.
Number of samples are choosen by taken the longest parameter (n
, mean
, sigma
, coefvar
). Therefore, function rep
is used. Pay attention if vectors don't have same length!
If sigma
is a vector, samples are independent. In other case (sigma
is a matrix), samples are dependent (following information meanst be taken into account: if sigma
is a correlation matrix, sigmaSup
is required).
List containing the following components for independent (with the same length) and dependent samples:
Samples
: a data frame containing the samples created.
Test normality test for the data (shapiro.test()
for n <= 50 and lillie.test()
in other case).
List containing the following components for independent samples with different lengths:
X_i
sample number i.
generator(4,0,2) sigma <- matrix(c(1,0.8,0.8,1),nrow = 2, byrow = 2) d <- generator(4,mean = c(1,2),sigma, sigmaSup = 1) generator(10,1,coefvar = c(0.3,0.5)) generator(c(10,11,10),c(1,2),coefvar = c(0.3,0.5))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.