matrix2df: For multiple membership models, translates matrix into a...

View source: R/matrix2df.R

matrix2dfR Documentation

For multiple membership models, translates matrix into a data.frame formatted for MLwiN Translates a matrix into a form usable by MLwiN for multiple membership models, namely a data.frame with (a) columns containing membership IDs (if first row matrix is 0 1 1 0 1 1, then first row of generated ID vectors would be, say, 2, 3, 5, 6) and (b) columns containing weights (in this example, if standardise = TRUE, then first row of generated weight vectors would be, say, 0.25, 0.25, 0.25, 0.25, otherwise first row of generated weight vectors would be, say, 1, 1, 1, 1).

Description

For multiple membership models, translates matrix into a data.frame formatted for MLwiN

Translates a matrix into a form usable by MLwiN for multiple membership models, namely a data.frame with (a) columns containing membership IDs (if first row matrix is 0 1 1 0 1 1, then first row of generated ID vectors would be, say, 2, 3, 5, 6) and (b) columns containing weights (in this example, if standardise = TRUE, then first row of generated weight vectors would be, say, 0.25, 0.25, 0.25, 0.25, otherwise first row of generated weight vectors would be, say, 1, 1, 1, 1).

Usage

matrix2df(mat, standardise = FALSE, idstub = "id", weightstub = "weight")

Arguments

mat

A matrix.

standardise

If TRUE, ensures the row sums to one; defaults to FALSE.

idstub

Prefix for columns containing IDs; defaults to id.

weightstub

Prefix for columns containing weights; defaults to weight.

Author(s)

Zhang, Z., Charlton, C.M.J., Parker, R.M.A., Leckie, G., and Browne, W.J. (2016) Centre for Multilevel Modelling, University of Bristol, U.K.

See Also

df2matrix


R2MLwiN documentation built on May 29, 2024, 2:10 a.m.