Last data update: 2014.03.03

R: Randomly Generate Binary Data with Underlying Latent Classes
rlcaR Documentation

Randomly Generate Binary Data with Underlying Latent Classes

Description

A function which randomly generates data with respect to some underlying latent class. Data may be generated either by specifying item and class probabilities or by utilising an object previously fitted to data.

Usage

rlca(n, itemprob = 0.5, classprob = 1, fit = NULL)

Arguments

n

Number of data points to be generated.

itemprob

The item probabilities, conditional on class membership. Defaults to 0.5.

classprob

The class probabilities. Defaults to 1, i.e., a one class model.

fit

An object of class blca. If fit is supplied, data is generated using the class and item probabilities obtained. Defaults to NULL.

Author(s)

Arthur White

See Also

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))

fit <- blca.em(x, 2)

x2<- rlca(1000, fit=fit)
fit2<- blca.em(x2,2)

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/rlca.Rd_%03d_medium.png", width=480, height=480)
> ### Name: rlca
> ### Title: Randomly Generate Binary Data with Underlying Latent Classes
> ### Aliases: rlca
> ### Keywords: blca random
> 
> ### ** 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))
> 
> fit <- blca.em(x, 2)
Restart number 1, logpost = -2503.72... 
Restart number 2, logpost = -2503.72... 
Restart number 3, logpost = -2503.72... 
Restart number 4, logpost = -2503.72... 
Restart number 5, logpost = -2503.72... 
> 
> x2<- rlca(1000, fit=fit)
> fit2<- blca.em(x2,2)
Restart number 1, logpost = -2483.45... 
New maximum found... Restart number 2, logpost = -2483.45... 
New maximum found... Restart number 3, logpost = -2483.45... 
Restart number 4, logpost = -2483.45... 
New maximum found... Restart number 5, logpost = -2483.44... 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>