gendatLCplfm {plfm} | R 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 |
attpar |
True attributeparameters. If |
sizepar |
A T-vector of true class size parameters. |
maprule |
Disjunctive ( |
model |
The type of dependency and heterogeneity assumption included in the model. |
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-\prod_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)=\prod_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)= \frac{1}{F} * \sum_f(objpar[j,f,t])*attpar[k,f]).
The marginal object-attribute association probability can be computed as follows:
p(j,k)=\sum_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
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)