Last data update: 2014.03.03

R: Conveniently Format Data for Bayesian Latent Class
data.blcaR Documentation

Conveniently Format Data for Bayesian Latent Class

Description

Conveniently format data for use with blca.

Usage

data.blca(X)

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

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)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(BayesLCA)
Loading required package: e1071
Loading required package: coda
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/BayesLCA/data.blca.Rd_%03d_medium.png", width=480, height=480)
> ### Name: data.blca
> ### Title: Conveniently Format Data for Bayesian Latent Class
> ### Aliases: data.blca
> ### Keywords: blca data.blca
> 
> ### ** Examples
> 
> 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)
$counts.n
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 
  25   49   51  148   68   35   31   45   64   24   24   46  226   70   63   31 

$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"
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>