error in biv model with definition variable

2 replies [Last post]
Nienke's picture
Offline
Joined: 01/22/2013

Hi,
I am trying to fit a biv model (2 continuous phenotypes) with sex as definition variable to test for mean differences, however I get the same error over and over again:

Error: A definition variable has been declared in model 'Chol' that does not contain a data set

I cannot find where it goes wrong, I suspect it's somewhere in the matrices declared to store linear coefficients for covariate:

grandMean <- mxMatrix(type="Full", nrow=1, ncol=nphen, free = TRUE, values=c(2700, 19), label=c("mean1","mean2"), name="Mean")
B_Sex <- mxMatrix(type="Full", nrow=ndef, ncol=nvar, free=TRUE, values=c(900,2.7), label=(rep(c("bphen1","bphen2"), 2)), name="bSex" )
defSex <- mxMatrix(type="Full", nrow=ndef, ncol=nvar, free=FALSE, labels=(rep(c("data.Sex1","data.Sex2"),each=2)), name="Sex")
SexR <- mxAlgebra(bSex * Sex, name="SexR")
expMean <- mxAlgebra(name="expMean", expression= cbind(Mean, Mean) + SexR)

Any help would be very much appreciated!

Regards,
Nienke

tbates's picture
Offline
Joined: 07/31/2009
definition variable declared in model that does not contain data

The error appears to be saying that it wants you to add a dataset to the model, so that it can find the variable?
Try adding something like this to your model:

	mxData(myData, type="raw")

PS, the tiny fragment of script you posted doesn't help, as it can't be generating the error

randMean <- mxMatrix(type="Full", nrow=1, ncol=nphen, free = TRUE, values=c(2700, 19), label=c("mean1","mean2"), name="Mean")
B_Sex <- mxMatrix(type="Full", nrow=ndef, ncol=nvar, free=TRUE, values=c(900,2.7), label=(rep(c("bphen1","bphen2"), 2)), name="bSex" )
defSex <- mxMatrix(type="Full", nrow=ndef, ncol=nvar, free=FALSE, labels=(rep(c("data.Sex1","data.Sex2"),each=2)), name="Sex")
SexR <- mxAlgebra(bSex * Sex, name="SexR")
expMean <- mxAlgebra(name="expMean", expression= cbind(Mean, Mean) + SexR)

Nienke's picture
Offline
Joined: 01/22/2013
Sorry, you're right, think

Sorry, you're right, think I've found the solution, however next time I'll post more of the script :)