Learn R Programming

BayesLCA (version 1.9)

Zscore: 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.

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.

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.

Examples

Run this code
# NOT RUN {
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))
# }

Run the code above in your browser using DataLab