Learn R Programming

ForImp (version 1.0.3)

rancatmat: Generating a random matrix of ordinal variables

Description

The function generates a random matrix of integer (ordinal) variables, with independent and uniform marginal distributions

Usage

rancatmat(n, m, cat = 3)

Arguments

n
number of rows/units
m
number of columns, variables
cat
number of categories for each variable

Value

a matrix of ordinal values

Details

The function generates a random matrix of integer (ordinal) variables (coded with 1, 2, 3...), with independent and uniform marginal distributions

See Also

transfmatcat

Examples

Run this code
n<-500
m<-3
mat<-rancatmat(n,m,c(3,4,5))
# let's check the marginal distributions...
apply(mat,2,tabulate)
#... should be "quite" uniform

Run the code above in your browser using DataLab