Generating a random matrix of ordinal variables

Share:

Description

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

Usage

1
rancatmat(n, m, cat = 3)

Arguments

n

number of rows/units

m

number of columns, variables

cat

number of categories for each variable

Details

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

Value

a matrix of ordinal values

Author(s)

Alessandro Barbiero, Giancarlo Manzi, Pieralda Ferrari

See Also

transfmatcat

Examples

1
2
3
4
5
6
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