gendatLCplfm: Data generation

View source: R/plfm.R

gendatLCplfmR Documentation

Data generation

Description

Data generation for disjunctive, conjunctive and additive latent class probabilistic latent feature models.

Usage

gendatLCplfm(N,objpar,attpar,sizepar,maprule="disj",model=1)

Arguments

N

Number of replications (e.g. persons) for which binary object-attribute associations are generated.

objpar

True objectparameters. If model=1, model=3, model=4, or model=6 objpar is a J X F X T array, if model=2 or model=5 objpar is a J X F matrix. As object parameters are probabilities they should be between 0 and 1.

attpar

True attributeparameters. If model=2, model=3, model=5, or model=6 attpar is a K X F X T array, if model=1 or model=4 attpar is a K X F matrix. As attribute parameters are probabilities they should be between 0 and 1.

sizepar

A T-vector of true class size parameters.

maprule

Disjunctive (maprule="disj"), conjunctive (maprule="conj") or additive (maprule="add") mapping rule of the latent class probabilistic latent feature model.

model

The type of dependency and heterogeneity assumption included in the model. model=1, model=2, model=3 represent models with a constant object-feature classification per person and with, respectively, class-specific object parameters, class-specific attribute parameters, and class-specific object- and attribute parameters. model=4, model=5, model=6 represent models with a constant attribute-feature classification per person and with, respectively, class-specific object parameters, class-specific attribute parameters, and class-specific object- and attribute parameters.

Details

The function gendatLCplfm generates binary object-attribute associations for N replications according to a disjunctive, conjunctive or additive latent class probabilistic latent feature model of a specific model type. In addition, the function computes the J X K matrix of marginal object-attribute association probabilities and a J X K X T array of class-specific object-attribute association probabilities. To compute association probabilities the function gendatLCplfm uses a vector of class size parameters (sizepar) a matrix or array of object parameters (objpar) and a matrix or array of true attribute parameters (attpar) as input.

According to the disjunctive probabilistic latent feature model, object j is associated to attribute k if the object and the attribute have at least one feature in common. More specifically, for model=1 the class-specific object-attribute association probability in cell (j,k) for the disjunctive model can be computed as:

p(j,k|t)=1-∏_f(1-objpar[j,f,t]*attpar[k,f]).

According to the conjunctive probabilistic latent feature model, object j and attribute k are associated if object j has all the features that are linked to attribute k.

In particular, for model=1,the class-specific object-attribute association probability in cell (j,k) for the conjunctive model can be computed as:

p(j,k|t)=∏_f(1-(1-objpar[j,f,t])*attpar[k,f]).

According to the additive probabilistic latent feature model, an object and an attribute are more likely to be associated if they have more features in common.

In particular, for model=1,the class-specific object-attribute association probability in cell (j,k) for the additive model can be computed as:

p(j,k|t)= (1/F) * ∑_f(objpar[j,f,t])*attpar[k,f]).

The marginal object-attribute association probability can be computed as follows:

p(j,k)=∑_t sizepar[t]*p(j,k|t).

Value

call

Parameters used to call the function.

data

I X J X K matrix of association probabilities.

class

I-vector that contains latent class membership of each replication.

condprob.JKT

J X K X T array of class-specific conditional object-attribute association probabilities.

margprob.JK

J X K matrix of marginal object-attribute association probabilities.

Author(s)

Michel Meulders

References

Meulders, M., Tuerlinckx, F., and Vanpaemel, W. (2013). Constrained multilevel latent class models for the analysis of three-way three-mode binary data. Journal of Classification, 30 (3), 306-337.

See Also

LCplfm

Examples

## Not run: 
# define constants
I<-500
J<-10
K<-8
F<-2
T<-2

# model 1

# generate true parameters
objpar<-array(runif(J*F*T),c(J,F,T))
attpar<-matrix(runif(K*F),c(K,F))
sizepar<-rep(1/T,T)
# generate data
d<-gendatLCplfm(N=I,objpar=objpar,attpar=attpar,sizepar=sizepar,maprule="conj",model=1)
# estimate parameters of true model
res<-LCplfm(data=d$data,F=2,T=2,model=1,maprule="conj")


# model 2

# generate true parameters
objpar<-matrix(runif(J*F),nrow=J)
attpar<-array(runif(K*F*T),c(K,F,T))
sizepar<-rep(1/T,T)
# generate data
d<-gendatLCplfm(N=I,objpar=objpar,attpar=attpar,sizepar=sizepar,maprule="conj",model=2)
# estimate parameters of true model
res<-LCplfm(data=d$data,F=2,T=2,model=2,maprule="conj")

# model 3

# generate true parameters
objpar<-array(runif(J*F*T),c(J,F,T))
attpar<-array(runif(K*F*T),c(K,F,T))
sizepar<-rep(1/T,T)
# generate data
d<-gendatLCplfm(N=I,objpar=objpar,attpar=attpar,sizepar=sizepar,maprule="conj",model=3)
# estimate parameters of true model
res<-LCplfm(data=d$data,F=2,T=2,model=3,maprule="conj")

# model 4

# generate true parameters
objpar<-array(runif(J*F*T),c(J,F,T))
attpar<-matrix(runif(K*F),c(K,F))
sizepar<-rep(1/T,T)
# generate data
d<-gendatLCplfm(N=I,objpar=objpar,attpar=attpar,sizepar=sizepar,maprule="conj",model=4)
# estimate parameters of true model
res<-LCplfm(data=d$data,F=2,T=2,model=4,maprule="conj")

# model 5

# generate true parameters
objpar<-matrix(runif(J*F),nrow=J)
attpar<-array(runif(K*F*T),c(K,F,T))
sizepar<-rep(1/T,T)
# generate data
d<-gendatLCplfm(N=I,objpar=objpar,attpar=attpar,sizepar=sizepar,maprule="conj",model=5)
# estimate parameters of true model
res<-LCplfm(data=d$data,F=2,T=2,model=5,maprule="conj")


# model 6
# generate true parameters
objpar<-array(runif(J*F*T),c(J,F,T))
attpar<-array(runif(K*F*T),c(K,F,T))
sizepar<-rep(1/T,T)
# generate data
d<-gendatLCplfm(N=I,objpar=objpar,attpar=attpar,sizepar=sizepar,maprule="conj",model=6)
# estimate parameters of true model
res<-LCplfm(data=d$data,F=2,T=2,model=6,maprule="conj")

## End(Not run)

plfm documentation built on March 30, 2022, 5:08 p.m.