Mixture distribution, zygosity example
Posted on

Attachment | Size |
---|---|
sim1.mz_.txt | 29.08 KB |
acemix.R | 2.66 KB |
sim1.dz_.txt | 29.09 KB |
I seem to have this almost working but for a pesky error:
Error: The job for model 'twinACE' exited abnormally with the error message: Objective returned invalid value.
Execution halted
Script and data files attached (albeit with an extra _ in the name of the latter, ffs).
I checked in a patch so that
I checked in a patch so that the error message will now tell you if the objective function is returning NaN or it is returning an infinite value.
Log in or register to post comments
In reply to I checked in a patch so that by mspiegel
A great patch that. For some
A great patch that. For some reason, the script now works when all I was expecting was better debugging information!
Log in or register to post comments
In reply to A great patch that. For some by neale
:-) "Your error was
:-)
"Your error was interesting: code 2 with little bit of 4 and 7 - Anyhow, I patched myself to cope with this in future, ran the script and emailed you the results in Molecular Psychiatry format.. hope that's OK,
Yours,
O. Supermodeler"
Log in or register to post comments
I now have another problem.
I now have another problem. Suppose I want to use a definition variable in the mxAlgebra that is operating on the vector of likelihoods coming back from an mxModel's mxFIMLObjective. For example, with code snippet:
mxModel("MZlike",
mxData(DataMZ, type="raw"),
mxFIMLObjective("twinACE.expCovMZ", "twinACE.expMean",selVars, vector=T)),
mxModel("DZlike",
mxData(DataMZ, type="raw"),
mxFIMLObjective("twinACE.expCovDZ", "twinACE.expMean",selVars, vector=T)),
mxAlgebra(-2*sum(log(MZlike@DataMZ.pMZ%x%MZlike.objective + (1-MZlike@DataMZ.pMZ)%x%DZlike.objective)), name="twin"),
mxAlgebraObjective("twin"))
The mxAlgebra complains that it can't find DataMZ.pMZ. Is there some way I can get a hold of it? I've tried going down the path of
twinACEFit@submodels$MZcorrect@data
but I don't seem to be able to reference the dataframe or matrix's third column.
MZlike@DataMZ[,3] doesn't work, nor does
twinACEFit@submodels$MZcorrect@data$pMZ)
nor
twinACEFit@submodels$MZcorrect@data@pMZ)
and I'm running out of ideas.
Log in or register to post comments
In reply to I now have another problem. by neale
As far as I know, mxAlgebras
As far as I know, mxAlgebras do not have access to mxData columns. I am not exactly sure why that is. Perhaps Michael Spiegel can let us know about that.
In the mean time, you can always create an mxMatrix for use in your algebra:
Log in or register to post comments
Umm, don't we assume that
Umm, don't we assume that algebras are calculated once per optimization iteration? This restriction would prohibit us from using definition variables, as we don't know which value of the definition value should be selected. A follow up question: should we allow the use of data sets in matrix algebra computations? Something like:
Log in or register to post comments
In reply to Umm, don't we assume that by mspiegel
Ok I think I got it going.
Ok I think I got it going. However, it was quite a bit of a fiddle. I've put it into trunk/models/passing/Acemix2.R
There's a slight disconnect in that a definition variable routinely appears as a 1x1 matrix as far as mxAlgebras are concerned, so to get a vector, as in the vector of likelihoods, we have to work with a separate dataframe, not a definition variable extracted from the mxData() command.
It almost seems to me that we should be able to refer to definition variables as either the whole vector of them (as needed for this weighted likelihood example) or to the individual level elements, which change with each evaluation.
Some distinction between def as a vector and def(i) as a scalar for the ith record in the sample would be required.
Log in or register to post comments
Right. One strategy for
Right. One strategy for allowing the whole vector of definition variables is to allow the data to appear in the matrix algebras. Well, and we need a mechanism for pulling a column out of a matrix. Plus we need something sane for the case where the data is a data.frame.
Log in or register to post comments