Errors in UnivariateTwinSaturated_MatrixRawCon.R

3 replies [Last post]
Karin's picture
Offline
Joined: 02/11/2011

I am just starting out in OpenMx and am trying to run the demonstration script UnivariateTwinSaturated_MatrixRawCon.R I get the error messages below.

Can anybody help?

Thankyou

Karin

> # Fit Model with Equal Means & Variances across Twin Order and Zygosity
> # -----------------------------------------------------------------------
> # Constrain expected means and variances to be equal across twin order
> equateMeansVarsTwinModel <- mxModel(univTwinSatFit, name="equateMeansVarsTwin",
+ mxConstraint( alg1="MZ.expVarMZt1", "=", alg2="MZ.expVarMZt2", name="VarMZt1ist2"),
+ mxConstraint( alg1="DZ.expVarDZt1", "=", alg2="DZ.expVarDZt2", name="VarDZt1ist2"),
+ mxConstraint( alg1="MZ.expMeanMZt1", "=", alg2="MZ.expMeanMZt2", name="MeanMZt1ist2"),
+ mxConstraint( alg1="DZ.expMeanDZt1", "=", alg2="DZ.expMeanDZt2", name="MeanDZt1ist2")
+ )
Error in mxConstraint(alg1 = "MZ.expVarMZt1", "=", alg2 = "MZ.expVarMZt2", :
unused argument(s) (alg1 = "MZ.expVarMZt1", alg2 = "MZ.expVarMZt2")
> equateMeansVarsTwinFit <- mxRun(equateMeansVarsTwinModel)
Error in cat("Running", model@name, "\n") :
object 'equateMeansVarsTwinModel' not found
> equateMeansVarsTwinSumm <- summary(equateMeansVarsTwinFit)
Error in summary(equateMeansVarsTwinFit) :
error in evaluating the argument 'object' in selecting a method for function 'summary': Error: object 'equateMeansVarsTwinFit' not found
> equateMeansVarsTwinSumm
Error: object 'equateMeansVarsTwinSumm' not found
> parameterSpecifications(equateMeansVarsTwinFit)
Error in .collectParameterSpecifications(model) :
object 'equateMeansVarsTwinFit' not found
> expectedMeansCovariances(equateMeansVarsTwinFit)
Error in .collectExpectedMeansCovariances(model, model) :
object 'equateMeansVarsTwinFit' not found
> tableFitStatistics(univTwinSatFit, equateMeansVarsTwinFit)
Error in .showFitStatistics(reference, compare) :
object 'equateMeansVarsTwinFit' not found
>
> # Constrain expected means and variances to be equal across twin order and zygosity
> equateMeansVarsTwinZygModel <- mxModel(equateMeansVarsTwinFit, name="equateMeansVarsTwinZyg",
+ mxConstraint( alg1="MZ.expVarMZt1", "=", alg2="DZ.expVarDZt1", name="VarMZisDZ"),
+ mxConstraint( alg1="MZ.expMeanMZt1", "=", alg2="DZ.expMeanDZt1", name="MeanMZisDZ")
+ )
Error in is(model, "MxModel") : object 'equateMeansVarsTwinFit' not found
> equateMeansVarsTwinZygFit <- mxRun(equateMeansVarsTwinZygModel)
Error in cat("Running", model@name, "\n") :
object 'equateMeansVarsTwinZygModel' not found
> equateMeansVarsTwinZygSumm <- summary(equateMeansVarsTwinZygFit)
Error in summary(equateMeansVarsTwinZygFit) :
error in evaluating the argument 'object' in selecting a method for function 'summary': Error: object 'equateMeansVarsTwinZygFit' not found
> equateMeansVarsTwinZygSumm
Error: object 'equateMeansVarsTwinZygSumm' not found
> parameterSpecifications(equateMeansVarsTwinZygFit)
Error in .collectParameterSpecifications(model) :
object 'equateMeansVarsTwinZygFit' not found
> expectedMeansCovariances(equateMeansVarsTwinZygFit)
Error in .collectExpectedMeansCovariances(model, model) :
object 'equateMeansVarsTwinZygFit' not found
> tableFitStatistics(univTwinSatFit, list(equateMeansVarsTwinFit, equateMeansVarsTwinZygFit))
Error in .showFitStatistics(reference, compare) :
object 'equateMeansVarsTwinFit' not found

Karin's picture
Offline
Joined: 02/11/2011
Thanks

Many thanks for your helpful comments. Much appreciated! Karin

tbates's picture
Offline
Joined: 07/31/2009
easy fix: constraint is out of date

First, look for the first error

Error in mxConstraint(alg1 = "MZ.expVarMZt1", "=", alg2 = "MZ.expVarMZt2", :
unused argument(s) (alg1 = "MZ.expVarMZt1", alg2 = "MZ.expVarMZt2")

?mxConstraint tells us that the expression should have the form x = y

So where you have

mxConstraint( alg1="MZ.expVarMZt1", "=", alg2="MZ.expVarMZt2", name="VarMZt1ist2"),

replace this with

mxConstraint(MZ.expVarMZt1 == MZ.expVarMZt2, name="VarMZt1ist2"),

It is unfortunate that this script exists... It is out of date and hasn't run since the earliest alpha days of OpenMx.

Ryne's picture
Offline
Joined: 07/31/2009
That's our fault. The

That's our fault. The signature for mxConstraint during the beta version of OpenMx, and this script was never changed before the 1.0 release. The mxConstraint objects should be changed from this format:

mxConstraint( alg1="MZ.expVarMZt1", "=", alg2="MZ.expVarMZt2", name="VarMZt1ist2")

to this one:
mxConstraint(MZ.expVarMZt1==MZ.expVarMZt2, name="VarMZt1ist2")

Once those changes are made, then the equateMeansVarsTwinModel will exist and the errors should go away.