grtrnorm: Sample from multiple multivariate normal distributions

Description Usage Arguments Details Value Author(s) References Examples

Description

Generate one or more samples from the two or more specified multivariate normal distributions.

Usage

1
2
3
4
5
6
7
8
9
grtrnorm(n,
        np = 2,
        means = list(rep(0,np), rep(0,np)), 
        covs = diag(rep(1,np)), 
        clip.sd = Inf,
        tol = 1e-6,
        empirical = TRUE, 
        seed = NULL,
        response.acc = NULL)

Arguments

n

the number of samples per population required

np

the number of populations to be sampled from

means

a list of vectors specifying the means of the variable for each populations

covs

a matrix or a list of matrices specifying the covariance matrices of the variables. Each matrix should be positive-definite and symmetric.

clip.sd

an integer specifying the cutoff value of standard score. The standard score of a generated sample exceeding this value should be truncated. Default to Inf (no truncation).

tol

tolerance (relative to largest variance) for numerical lack of positive-definiteness in covs.

empirical

logical. If true, means and covs specify the empirical rather than population means and covariance matrices.

seed

an integer internally supplied as seed argument to the function set.seed. If NULL, .Random.seed is used.

response.acc

an optional numeric value between 0 and 1, specifying the classification accuracy of a hypothetical observer. See ‘Details’. Default to NULL.

Details

This function is essentially a wrapper to the mvrnorm function in MASS package.

If the optional response.acc argument is supplied, hypothetical random classification responses with specified accuracy will be generated.

Value

a data frame containing a column of numeric category labels and column(s) of sampled values for each variable, and optionally, a column of hypothetical responses.

Author(s)

Author of the original Matlab routines: Leola Alfonso-Reese

Author of R adaptation: Kazunaga Matsuki

References

Alfonso-Reese, L. A. (2006) General recognition theory of categorization: A MATLAB toolbox. Behavior Research Methods, 38, 579-583.

Examples

1
2
3
4
5
6
7
8
9
m <- list(c(268,157), c(332, 93))
covs <- matrix(c(4538, 4351, 4351, 4538), ncol=2)
II <- grtrnorm(n=80, np=2, means=m, covs=covs)


m <- list(c(283,98),c(317,98),c(283,152),c(317,152))
covs <- diag(75, ncol=2, nrow=2)
CJ <- grtrnorm(n=c(8,16,16,40), np=4, means=m, covs=covs)
CJ$category <- c(1,1,1,2)[CJ$category]

Example output

Loading required package: MASS

Attaching package: 'grt'

The following object is masked from 'package:base':

    scale

grt documentation built on May 2, 2019, 7:10 a.m.