data.blca: Conveniently Format Data for Bayesian Latent Class

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/data.blca.R

Description

Conveniently format data for use with blca.

Usage

1

Arguments

X

A data matrix intended for latent class analysis. See details.

Details

The data may take of one of two forms, either as a binary matrix, or as a matrix consisting of unique binary rows, with a column of counts. In either case data.blca will convert X into a list, with binary matrix and count vector explicitly identified.

Value

A list of class data.blca, containing

counts.n

A vector of counts of each unique data entry.

data

A matrix consisting of each unique data entry.

Note

This function is used internally by blca, so its use is not necessary, though it will speed up computation time to supply the model with data of this form if repeated use of a function is required.

Author(s)

Arthur White

See Also

blca

Examples

1
2
3
4
5
type1 <- c(0.8, 0.8, 0.2, 0.2)
type2 <- c(0.2, 0.2, 0.8, 0.8)
x<- rlca(1000, rbind(type1,type2), c(0.6,0.4)) ##Only 16 unique observations possible

data.blca(x)

Example output

Loading required package: e1071
Loading required package: coda
$counts.n
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 
  31   49   59  150   66   23   28   50   70   22   21   49  232   63   49   38 

$data
      [,1] [,2] [,3] [,4]
 [1,]    0    0    0    0
 [2,]    0    0    0    1
 [3,]    0    0    1    0
 [4,]    0    0    1    1
 [5,]    0    1    0    0
 [6,]    0    1    0    1
 [7,]    0    1    1    0
 [8,]    0    1    1    1
 [9,]    1    0    0    0
[10,]    1    0    0    1
[11,]    1    0    1    0
[12,]    1    0    1    1
[13,]    1    1    0    0
[14,]    1    1    0    1
[15,]    1    1    1    0
[16,]    1    1    1    1

attr(,"class")
[1] "data.blca"

BayesLCA documentation built on July 2, 2020, 12:11 a.m.