#Create sample data frame
set.seed(123)
yvar<-rlnorm(200)
these<-sample(1:100,20)
yvar[these]<-NA
logyvar<-log(yvar)
y2var<-rlnorm(200)
those<-sample(1:200,25)
y2var[those]<-NA
logy2var<-log(y2var)
pred1<-sample(0:1,200,replace=TRUE)
pred2<-sample(1:10,200,replace=TRUE)
pred3<-sample(0:1,200,replace=TRUE)
pred3miss<-sample(1:200,50)
pred3[pred3miss]<-NA
testdata<-data.frame(cbind(yvar,y2var,logyvar,logy2var,pred1,pred2,pred3))
#Get the names of the response variables
ynames<-names(testdata)[3:4]
#Run a mixture model on each response variable
mod<-~pred1+pred2+pred3|pred1+pred2+pred3
mxtrmod(ynames=ynames,mxtrModel=mod,data=testdata)
#Create example expression set
#Specify the response variables
exprsobs<-t(testdata[,3:4])
#Specify the phenotype data
exprspheno<-testdata[,5:7]
#make phenotype data an annotated data frame
phenoData <- new("AnnotatedDataFrame",data=exprspheno)
#combine into example expression set
testexpr<-ExpressionSet(assayData=exprsobs,phenoData=phenoData)
#Get the names of the response variables
ynames<-rownames(exprs(testexpr))
#Run the mixture model on each response variable
mxtrmod(ynames=ynames,mxtrModel=mod,data=testexpr)
#Load the data set from the package
data(metabdata)
#Select the response variables
ynames<-names(metabdata)[11:17]
#Run the mixture models
mod2<-~PHENO|PHENO+age_ogtt_mc+parity12+ga_ogtt_wks_mc
mxtrmod(ynames,mxtrModel=mod2,data=metabdata)
Run the code above in your browser using DataLab