Last data update: 2014.03.03

R: Evaluating Class Membership of Binary Data
ZscoreR Documentation

Evaluating Class Membership of Binary Data

Description

For a fitted model of class blca, and binary data X, the probability of class membership for each data point is provided.

Usage

Zscore(X, fit = NULL, itemprob = NULL, classprob = NULL)

Arguments

X

A binary data matrix. X must have the same number of columns as the data that fit was applied to.

fit

An object of class blca.

itemprob

A matrix of item probabilities, conditional on class membership.

classprob

A vector denoting class membership probability.

Details

Calculation of the probability of class membership for a data point relies on two parameters, class membership and item probability. These may be supplied directly to Zscore, or alternatively, a blca object containing both parameters can be used instead.

Value

A matrix of equal rows to X and with G, the number of classes, columns, where each row is a score denoting the probability of class membership. Each row should therefore sum to 1.

Note

Zscore.internal has the same functionality as Zscore, but is only intended for internal use.

Author(s)

Arthur White

Examples

set.seed(1)
type1 <- c(0.8, 0.8, 0.05, 0.2)
type2 <- c(0.2, 0.2, 0.05, 0.8)
x<- rlca(250, rbind(type1,type2), c(0.5,0.5))

fit <- blca.em(x, 2)
fit$Z ## Unique data types
Zscore(x, fit=fit) ## Whole data set
Zscore(c(0, 1, 1, 0), fit=fit) ## Not in data set
Zscore(x, itemprob=rbind(type1,type2), classprob=c(0.5,0.5))

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/Zscore.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Zscore
> ### Title: Evaluating Class Membership of Binary Data
> ### Aliases: Zscore Zscore.internal
> ### Keywords: blca
> 
> ### ** Examples
> 
> set.seed(1)
> type1 <- c(0.8, 0.8, 0.05, 0.2)
> type2 <- c(0.2, 0.2, 0.05, 0.8)
> x<- rlca(250, rbind(type1,type2), c(0.5,0.5))
> 
> fit <- blca.em(x, 2)
Restart number 1, logpost = -522.09... 
New maximum found... Restart number 2, logpost = -522.09... 
New maximum found... Restart number 3, logpost = -522.09... 
Restart number 4, logpost = -522.09... 
Restart number 5, logpost = -522.09... 
> fit$Z ## Unique data types
        Group 1     Group 2
0000 0.12556835 0.874431650
0001 0.01179732 0.988202684
0010 0.18678721 0.813212792
0011 0.01873747 0.981262527
0100 0.52246275 0.477537255
0101 0.08337268 0.916627322
0111 0.12700768 0.872992320
1000 0.89496750 0.105032502
1001 0.41465021 0.585349785
1010 0.93164383 0.068356174
1011 0.53119116 0.468808843
1100 0.98483006 0.015169945
1101 0.84367908 0.156320919
1110 0.99046168 0.009538317
1111 0.89618741 0.103812594
> Zscore(x, fit=fit) ## Whole data set
           [,1]        [,2]
1100 0.98483006 0.015169945
1000 0.89496750 0.105032502
1100 0.98483006 0.015169945
0101 0.08337268 0.916627322
1100 0.98483006 0.015169945
0101 0.08337268 0.916627322
0100 0.52246275 0.477537255
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1000 0.89496750 0.105032502
1100 0.98483006 0.015169945
1101 0.84367908 0.156320919
1110 0.99046168 0.009538317
1100 0.98483006 0.015169945
1101 0.84367908 0.156320919
1101 0.84367908 0.156320919
1100 0.98483006 0.015169945
0100 0.52246275 0.477537255
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
0100 0.52246275 0.477537255
1100 0.98483006 0.015169945
1101 0.84367908 0.156320919
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1101 0.84367908 0.156320919
1100 0.98483006 0.015169945
0100 0.52246275 0.477537255
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1110 0.99046168 0.009538317
1000 0.89496750 0.105032502
1100 0.98483006 0.015169945
0100 0.52246275 0.477537255
1111 0.89618741 0.103812594
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1101 0.84367908 0.156320919
0101 0.08337268 0.916627322
1101 0.84367908 0.156320919
1000 0.89496750 0.105032502
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1000 0.89496750 0.105032502
1100 0.98483006 0.015169945
0101 0.08337268 0.916627322
1110 0.99046168 0.009538317
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1000 0.89496750 0.105032502
1100 0.98483006 0.015169945
1010 0.93164383 0.068356174
1100 0.98483006 0.015169945
1101 0.84367908 0.156320919
0100 0.52246275 0.477537255
1100 0.98483006 0.015169945
1000 0.89496750 0.105032502
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1000 0.89496750 0.105032502
0100 0.52246275 0.477537255
1100 0.98483006 0.015169945
0100 0.52246275 0.477537255
1100 0.98483006 0.015169945
1000 0.89496750 0.105032502
1000 0.89496750 0.105032502
0001 0.01179732 0.988202684
0000 0.12556835 0.874431650
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
0100 0.52246275 0.477537255
1000 0.89496750 0.105032502
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1010 0.93164383 0.068356174
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1101 0.84367908 0.156320919
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1000 0.89496750 0.105032502
1000 0.89496750 0.105032502
1101 0.84367908 0.156320919
1100 0.98483006 0.015169945
0100 0.52246275 0.477537255
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1101 0.84367908 0.156320919
1100 0.98483006 0.015169945
0100 0.52246275 0.477537255
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1101 0.84367908 0.156320919
0100 0.52246275 0.477537255
1000 0.89496750 0.105032502
1101 0.84367908 0.156320919
1000 0.89496750 0.105032502
1100 0.98483006 0.015169945
0000 0.12556835 0.874431650
1100 0.98483006 0.015169945
0101 0.08337268 0.916627322
1100 0.98483006 0.015169945
1000 0.89496750 0.105032502
1101 0.84367908 0.156320919
1101 0.84367908 0.156320919
1000 0.89496750 0.105032502
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1101 0.84367908 0.156320919
0100 0.52246275 0.477537255
1100 0.98483006 0.015169945
1000 0.89496750 0.105032502
1100 0.98483006 0.015169945
1100 0.98483006 0.015169945
1101 0.84367908 0.156320919
1100 0.98483006 0.015169945
1000 0.89496750 0.105032502
0101 0.08337268 0.916627322
0000 0.12556835 0.874431650
0001 0.01179732 0.988202684
1000 0.89496750 0.105032502
1000 0.89496750 0.105032502
0000 0.12556835 0.874431650
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0000 0.12556835 0.874431650
0001 0.01179732 0.988202684
0101 0.08337268 0.916627322
0001 0.01179732 0.988202684
0101 0.08337268 0.916627322
0101 0.08337268 0.916627322
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0101 0.08337268 0.916627322
0001 0.01179732 0.988202684
1011 0.53119116 0.468808843
0001 0.01179732 0.988202684
1001 0.41465021 0.585349785
0101 0.08337268 0.916627322
0000 0.12556835 0.874431650
0101 0.08337268 0.916627322
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
1001 0.41465021 0.585349785
0001 0.01179732 0.988202684
1001 0.41465021 0.585349785
0101 0.08337268 0.916627322
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
1001 0.41465021 0.585349785
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0000 0.12556835 0.874431650
0001 0.01179732 0.988202684
0000 0.12556835 0.874431650
0000 0.12556835 0.874431650
0101 0.08337268 0.916627322
0000 0.12556835 0.874431650
0000 0.12556835 0.874431650
0101 0.08337268 0.916627322
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
1100 0.98483006 0.015169945
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0101 0.08337268 0.916627322
1001 0.41465021 0.585349785
0000 0.12556835 0.874431650
0101 0.08337268 0.916627322
0010 0.18678721 0.813212792
0001 0.01179732 0.988202684
0101 0.08337268 0.916627322
0000 0.12556835 0.874431650
1001 0.41465021 0.585349785
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
1001 0.41465021 0.585349785
0001 0.01179732 0.988202684
0100 0.52246275 0.477537255
0100 0.52246275 0.477537255
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0100 0.52246275 0.477537255
1101 0.84367908 0.156320919
0001 0.01179732 0.988202684
0000 0.12556835 0.874431650
1001 0.41465021 0.585349785
0001 0.01179732 0.988202684
0101 0.08337268 0.916627322
0101 0.08337268 0.916627322
1001 0.41465021 0.585349785
0101 0.08337268 0.916627322
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0011 0.01873747 0.981262527
0100 0.52246275 0.477537255
0000 0.12556835 0.874431650
0001 0.01179732 0.988202684
0010 0.18678721 0.813212792
1001 0.41465021 0.585349785
0001 0.01179732 0.988202684
0000 0.12556835 0.874431650
0101 0.08337268 0.916627322
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
1001 0.41465021 0.585349785
0001 0.01179732 0.988202684
0000 0.12556835 0.874431650
0001 0.01179732 0.988202684
1101 0.84367908 0.156320919
0000 0.12556835 0.874431650
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0101 0.08337268 0.916627322
0101 0.08337268 0.916627322
0000 0.12556835 0.874431650
0111 0.12700768 0.872992320
0101 0.08337268 0.916627322
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
1101 0.84367908 0.156320919
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
0001 0.01179732 0.988202684
1001 0.41465021 0.585349785
0001 0.01179732 0.988202684
0101 0.08337268 0.916627322
> Zscore(c(0, 1, 1, 0), fit=fit) ## Not in data set
          [,1]      [,2]
0110 0.6363629 0.3636371
> Zscore(x, itemprob=rbind(type1,type2), classprob=c(0.5,0.5))
           [,1]       [,2]
1100 0.98461538 0.01538462
1000 0.80000000 0.20000000
1100 0.98461538 0.01538462
0101 0.20000000 0.80000000
1100 0.98461538 0.01538462
0101 0.20000000 0.80000000
0100 0.80000000 0.20000000
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1000 0.80000000 0.20000000
1100 0.98461538 0.01538462
1101 0.80000000 0.20000000
1110 0.98461538 0.01538462
1100 0.98461538 0.01538462
1101 0.80000000 0.20000000
1101 0.80000000 0.20000000
1100 0.98461538 0.01538462
0100 0.80000000 0.20000000
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
0100 0.80000000 0.20000000
1100 0.98461538 0.01538462
1101 0.80000000 0.20000000
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1101 0.80000000 0.20000000
1100 0.98461538 0.01538462
0100 0.80000000 0.20000000
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1110 0.98461538 0.01538462
1000 0.80000000 0.20000000
1100 0.98461538 0.01538462
0100 0.80000000 0.20000000
1111 0.80000000 0.20000000
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1101 0.80000000 0.20000000
0101 0.20000000 0.80000000
1101 0.80000000 0.20000000
1000 0.80000000 0.20000000
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1000 0.80000000 0.20000000
1100 0.98461538 0.01538462
0101 0.20000000 0.80000000
1110 0.98461538 0.01538462
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1000 0.80000000 0.20000000
1100 0.98461538 0.01538462
1010 0.80000000 0.20000000
1100 0.98461538 0.01538462
1101 0.80000000 0.20000000
0100 0.80000000 0.20000000
1100 0.98461538 0.01538462
1000 0.80000000 0.20000000
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1000 0.80000000 0.20000000
0100 0.80000000 0.20000000
1100 0.98461538 0.01538462
0100 0.80000000 0.20000000
1100 0.98461538 0.01538462
1000 0.80000000 0.20000000
1000 0.80000000 0.20000000
0001 0.01538462 0.98461538
0000 0.20000000 0.80000000
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
0100 0.80000000 0.20000000
1000 0.80000000 0.20000000
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1010 0.80000000 0.20000000
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1101 0.80000000 0.20000000
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1000 0.80000000 0.20000000
1000 0.80000000 0.20000000
1101 0.80000000 0.20000000
1100 0.98461538 0.01538462
0100 0.80000000 0.20000000
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1101 0.80000000 0.20000000
1100 0.98461538 0.01538462
0100 0.80000000 0.20000000
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1101 0.80000000 0.20000000
0100 0.80000000 0.20000000
1000 0.80000000 0.20000000
1101 0.80000000 0.20000000
1000 0.80000000 0.20000000
1100 0.98461538 0.01538462
0000 0.20000000 0.80000000
1100 0.98461538 0.01538462
0101 0.20000000 0.80000000
1100 0.98461538 0.01538462
1000 0.80000000 0.20000000
1101 0.80000000 0.20000000
1101 0.80000000 0.20000000
1000 0.80000000 0.20000000
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1101 0.80000000 0.20000000
0100 0.80000000 0.20000000
1100 0.98461538 0.01538462
1000 0.80000000 0.20000000
1100 0.98461538 0.01538462
1100 0.98461538 0.01538462
1101 0.80000000 0.20000000
1100 0.98461538 0.01538462
1000 0.80000000 0.20000000
0101 0.20000000 0.80000000
0000 0.20000000 0.80000000
0001 0.01538462 0.98461538
1000 0.80000000 0.20000000
1000 0.80000000 0.20000000
0000 0.20000000 0.80000000
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0000 0.20000000 0.80000000
0001 0.01538462 0.98461538
0101 0.20000000 0.80000000
0001 0.01538462 0.98461538
0101 0.20000000 0.80000000
0101 0.20000000 0.80000000
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0101 0.20000000 0.80000000
0001 0.01538462 0.98461538
1011 0.20000000 0.80000000
0001 0.01538462 0.98461538
1001 0.20000000 0.80000000
0101 0.20000000 0.80000000
0000 0.20000000 0.80000000
0101 0.20000000 0.80000000
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
1001 0.20000000 0.80000000
0001 0.01538462 0.98461538
1001 0.20000000 0.80000000
0101 0.20000000 0.80000000
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
1001 0.20000000 0.80000000
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0000 0.20000000 0.80000000
0001 0.01538462 0.98461538
0000 0.20000000 0.80000000
0000 0.20000000 0.80000000
0101 0.20000000 0.80000000
0000 0.20000000 0.80000000
0000 0.20000000 0.80000000
0101 0.20000000 0.80000000
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
1100 0.98461538 0.01538462
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0101 0.20000000 0.80000000
1001 0.20000000 0.80000000
0000 0.20000000 0.80000000
0101 0.20000000 0.80000000
0010 0.20000000 0.80000000
0001 0.01538462 0.98461538
0101 0.20000000 0.80000000
0000 0.20000000 0.80000000
1001 0.20000000 0.80000000
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
1001 0.20000000 0.80000000
0001 0.01538462 0.98461538
0100 0.80000000 0.20000000
0100 0.80000000 0.20000000
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0100 0.80000000 0.20000000
1101 0.80000000 0.20000000
0001 0.01538462 0.98461538
0000 0.20000000 0.80000000
1001 0.20000000 0.80000000
0001 0.01538462 0.98461538
0101 0.20000000 0.80000000
0101 0.20000000 0.80000000
1001 0.20000000 0.80000000
0101 0.20000000 0.80000000
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0011 0.01538462 0.98461538
0100 0.80000000 0.20000000
0000 0.20000000 0.80000000
0001 0.01538462 0.98461538
0010 0.20000000 0.80000000
1001 0.20000000 0.80000000
0001 0.01538462 0.98461538
0000 0.20000000 0.80000000
0101 0.20000000 0.80000000
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
1001 0.20000000 0.80000000
0001 0.01538462 0.98461538
0000 0.20000000 0.80000000
0001 0.01538462 0.98461538
1101 0.80000000 0.20000000
0000 0.20000000 0.80000000
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0101 0.20000000 0.80000000
0101 0.20000000 0.80000000
0000 0.20000000 0.80000000
0111 0.20000000 0.80000000
0101 0.20000000 0.80000000
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
1101 0.80000000 0.20000000
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
0001 0.01538462 0.98461538
1001 0.20000000 0.80000000
0001 0.01538462 0.98461538
0101 0.20000000 0.80000000
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>