expand.mat: Utility function to expand aggregated data

Description Usage Arguments Value Note Examples

Description

The function expands aggregated data into casewise data. For instance, for a contingency table given in the form of a design matrix and corresponding counts the function sets up a matrix where each design row is repeated according to the frequencies for that row.

Usage

1
expand.mat(mat, freq)

Arguments

mat

a matrix (or column vector) or data frame to be expanded

freq

a vector of counts

Value

the expanded matrix.

Note

This utility allows to generate input data for the design generating and model fitting functions of the prefmod package from aggregated data.

Examples

1
2
tdat <- expand.mat(tennis[, -1], tennis[, 1])
head(tdat)

Example output

Loading required package: gnm
Loading required package: colorspace
     C1 C2 C3 SEX
[1,]  1  1 -1   1
[2,]  1  1 -1   1
[3,]  1  1 -1   1
[4,]  1  1 -1   1
[5,]  1  1 -1   1
[6,]  1  1 -1   1

prefmod documentation built on May 2, 2019, 4:59 p.m.