You are here

Error in FUN(X[[2L]], ...) : Could not find function with name + and 1 arguments

8 posts / 0 new
Last post
MNivard's picture
Offline
Joined: 12/09/2010 - 11:18
Error in FUN(X[[2L]], ...) : Could not find function with name + and 1 arguments

Running NucTwFam
Error in FUN(X[[2L]], ...) :
Could not find function with name + and 1 arguments

So it would appear from this error I am summing a matrixobject and empty space (hence the could not find a function for one sided summing???) in one of my mxAlgebra functions.

However I have extensively checked my code for a "+" in an maAlgebra function lead by or trailed by a non matrix object or just whitespace. I could not find such a occurence.

I am running OpenMX 1.0.6 in R 2.11

Any sugestions?

Michel

mspiegel's picture
Offline
Joined: 07/31/2009 - 15:24
One suggestion is to download

One suggestion is to download the OpenMx pre-release and run your script. We have improved the error messages for algebras for OpenMx 1.1. I would recommend not relying on the pre-release to publish results (yet). We are in the process of testing the pre-releases, and the pre-release r1527 is out-of-date with respect to the source code repository.

mspiegel's picture
Offline
Joined: 07/31/2009 - 15:24
Oops. Nevermind, we have not

Oops. Nevermind, we have not added context information to that error situation yet. Probably better to just attach your script to a forum post.

MNivard's picture
Offline
Joined: 12/09/2010 - 11:18
so i just added the script, i

so i just added the script, i dont think however this will quickly solve the problem. Am i right to suspect the algebra styatements are involved in this error?

Michel

mspiegel's picture
Offline
Joined: 07/31/2009 - 15:24
I improved the error message

I improved the error message in our source code repository, so now it prints out the name of the algebra in which the error occurs. The error is the expression "CpathM %*% + CpathM" in the algebra CvDOS. Same error occurs in CvSibOS.

MNivard's picture
Offline
Joined: 12/09/2010 - 11:18
thaks a lot! i have been

thaks a lot! i have been staring at %, *, + and x for so long i just didnt notice anymore.

tbates's picture
Offline
Joined: 07/31/2009 - 14:25
very helpful mike!

very helpful mike!

MNivard's picture
Offline
Joined: 12/09/2010 - 11:18
My script is enormous

It's an enormous script with a lot of algebra but here goes:

   ntf <- mxModel(model="NTF",

   ####################
   ####  Matrices  ####
   ####################

   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=50, label="ass mating path",           name="AMP"),              #D
   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=.005, label="within person path",        name="WPP"),              #P

   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=1, label="addative gen cov M",        name="AcovM"),            #G
   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=0, label="common env path M",         name="CpathM"),           #C
   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=6, label="addative gen path M",       name="ApathM"),           #A
   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=.3, label="AC cov M",                 name="ACcovM"),           #S

   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=1, label="addative gen cov F",        name="AcovF"),            #I
   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=0, label="common env  path F",        name="CpathF"),           #Y
   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=6, label="addative gen path F",       name="ApathF"),           #X
   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=.3, label="AC cov F",                 name="ACcovF"),           #T

   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=0, label="fath som cult trans",       name="FSc"),              #F(4)
   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=0, label="mothson cult trans",        name="MSc"),              #M(4)
   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=0, label="fath dau cult trans",       name="FDc"),              #E(6)
   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=0, label="moth dau cult trans",       name="MDc"),              #L(6)
   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=1, label="common env M",              name="Cm"),               #R
   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=1, label="common env F",              name="Cf"),               #Q
   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=1, label="common env D",              name="Cd"),               #O
   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=.1, label="Unique env M",              name="Em"),               #J
   mxMatrix(type="Full", nrow=1, ncol=1, free=TRUE, values=.1, label="Unique env F",              name="Ef"),               #K
   mxMatrix(type="Full", nrow=1, ncol=1, free=FALSE, values=0, label="Dominance M",               name="Dm"),               #N
   mxMatrix(type="Full", nrow=1, ncol=1, free=FALSE, values=0, label="Dominance F",               name="Df"),               #B

   mxMatrix(type="Full", nrow=1, ncol=1, free=FALSE, values=.5, label="Halve",                    name="H"),                #H
   mxMatrix(type="Iden", nrow=1, ncol=1, free=FALSE,                                              name="Iden"),                #I as in identity!


   ####################
   ####  Algebras  ####
   ####################


   mxAlgebra(  expression= WPP %*% AMP %*% WPP, name="E1"),                                                                              #W
   mxAlgebra(  expression=  AcovM %*%t(ApathM) + ACcovM %*% t(CpathM), name="E2"),                                                        #U
   mxAlgebra(  expression= AcovF %*%t(ApathF) + ACcovF %*% t(CpathF), name="E3"),                                                        #V


   mxAlgebra(  expression= (WPP %*% t(FSc) +  t(E1) %*%t(MSc) ) %*% t(CpathM) + Iden %*% t(E2) %*% (H %x% t(ApathM)) + (WPP%*%t(AMP)) %*% t(E3)%*% (H %x% t(ApathM)), name="CvFS"), # father Son cov
   mxAlgebra(  expression= (WPP %*% t(MSc) +  t(E1) %*%t(FSc) ) %*% t(CpathM) + Iden %*% t(E3) %*% (H %x% t(ApathM)) + (WPP%*%t(AMP)) %*% t(E2)%*% (H %x% t(ApathM)), name="CvMS"), # Mother Son cov

   mxAlgebra(  expression= (WPP %*% t(FDc) +  t(E1) %*%t(MDc) ) %*% t(CpathF) + Iden %*% t(E2) %*% (H %x% t(ApathF)) + (WPP%*%t(AMP)) %*% t(E3)%*% (H %x% t(ApathF)), name="CvFD"), # Father daughter cov
   mxAlgebra(  expression= (WPP %*% t(MDc) +  t(E1) %*%t(FDc) ) %*% t(CpathF) + Iden %*% t(E3) %*% (H %x% t(ApathF)) + (WPP%*%t(AMP)) %*% t(E2)%*% (H %x% t(ApathF)), name="CvMD"), # Mother daughter cov

   mxAlgebra(  expression= ApathM %*% AcovM %*% t(ApathM) + CpathM %*% Cm %*% t(CpathM) + ApathM %*% ACcovM %*% t(CpathM) + CpathM %*% t(ACcovM) %*% t(ApathM) + Dm %*% t(Dm), name="CvMZM"), # MZM cov
   mxAlgebra(  expression= H %x% ApathM %*% (AcovM + H %x%( E2 %*% (t(AMP) + AMP) %*% t(E3))) %*% t(ApathM) + CpathM %*% Cm %*% t(CpathM) + ApathM %*% ACcovM %*% t(CpathM) + CpathM %*% t(ACcovM) %*% t(ApathM) + H %x% H %x% Dm %*% t(Dm), name="CvDZM"), # DZM cov
   mxAlgebra(  expression= H %x% ApathM %*% (AcovM + H %x%( E2 %*% (t(AMP) + AMP) %*% t(E3))) %*% t(ApathM) + CpathM %*% Cm %*% t(CpathM) + ApathM %*% ACcovM %*% t(CpathM) + CpathM %*% t(ACcovM) %*% t(ApathM) + H %x% H %x% Dm %*% t(Dm), name="CvSibMM"), # |MAle sib Male sib cov

   mxAlgebra(  expression= ApathF %*% AcovF %*% t(ApathF) + CpathF %*% Cf %*% t(CpathF) + ApathF %*% ACcovF %*% t(CpathF) + CpathF %*% t(ACcovF) %*% t(ApathF) + Df %*% t(Df), name="CvMZF"), # MZF cov
   mxAlgebra(  expression= H %x% ApathF %*% (AcovF + H %x%( E3 %*% (t(AMP) + AMP) %*% t(E2))) %*% t(ApathF) + CpathF %*% Cm %*% t(CpathF) + ApathF %*% ACcovF %*% t(CpathF) + CpathF %*% t(ACcovF) %*% t(ApathF) + H %x% H %x% Df %*% t(Df), name="CvDZF"), # DZF cov
   mxAlgebra(  expression= H %x% ApathF %*% (AcovF + H %x%( E3 %*% (t(AMP) + AMP) %*% t(E2))) %*% t(ApathF) + CpathF %*% Cm %*% t(CpathF) + ApathF %*% ACcovF %*% t(CpathF) + CpathF %*% t(ACcovF) %*% t(ApathF) + H %x% H %x% Df %*% t(Df), name="CvSibFF"), # Female sib female sib cov

   mxAlgebra(  expression= H %x% ApathM %*% (AcovM + H %x%( E2 %*% (t(AMP) + AMP) %*% t(E3))) %*%  t(ApathF) + CpathM %*%   + CpathM %*% (Cm^H) %*% Cd %*% (t(Cf)^H   %*% t(CpathF)   + ApathM %*% (H %x% ( E2 %*% FDc + E2 %*% AMP %*% WPP %*% MDc + E3 %*% MDc  + AMP %*% E3  %*% WPP %*% FDc )))   %*% t(CpathF)    + CpathM  %*% t( H %x% (  FSc %*% E2 + FSc %*% WPP %*% AMP %*% E3 + MSc %*%  E3   +  MSc %*% WPP %*% AMP %*%  E2)) %*%  t(ApathF)   + H %x% H %x% Dm %*% t(Df), name="CvDOS"), # Covariance DOS twin pair
   mxAlgebra(  expression= H %x% ApathM %*% (AcovM + H %x%( E2 %*% (t(AMP) + AMP) %*% t(E3))) %*%  t(ApathF) + CpathM %*%   + CpathM %*% (Cm^H) %*% Cd %*% (t(Cf)^H   %*% t(CpathF)   + ApathM %*% (H %x% ( E2 %*% FDc + E2 %*% AMP %*% WPP %*% MDc + E3 %*% MDc  + AMP %*% E3  %*% WPP %*% FDc )))   %*% t(CpathF)    + CpathM  %*% t( H %x% (  FSc %*% E2 + FSc %*% WPP %*% AMP %*% E3 + MSc %*%  E3   +  MSc %*% WPP %*% AMP %*%  E2)) %*%  t(ApathF)   + H %x% H %x% Dm %*% t(Df), name="CvSibOS"), # Covariance DOS twin pair

   #######################
   ####  Constraints  ####
   #######################

   mxAlgebra(  expression= H %x% (H %x% AcovM + H %x% AcovF + H %x% ( E2 %*% (t(AMP) + AMP) %*% t(E3))) + Iden, name="AcovM2"),
   mxConstraint(AcovM == AcovM2, name="AcovMcon"),

   mxAlgebra(  expression= H %x% (H %x% AcovF + H %x% AcovM + H %x% ( E3 %*% (t(AMP) + AMP) %*% t(E2))) + Iden, name="AcovF2"),
   mxConstraint(AcovF == AcovF2, name="AcovFcon"),

   mxAlgebra(  expression= H %x% E2 %*% (t(FSc) + (AMP %*% WPP %*% t(MSc))) + H %x% E3 %*% (t(MSc) + (AMP %*% WPP %*% t(FSc))), name="ACcovM2"),
   mxConstraint(ACcovM == ACcovM2, name="ACcovMcon"),

   mxAlgebra(  expression= H %x% E2 %*% (t(FDc) + (AMP %*% WPP %*% t(MDc))) + H %x% E3 %*% (t(MDc) + (AMP %*% WPP %*% t(FDc)) ), name="ACcovF2"),
   mxConstraint(ACcovF == ACcovF2, name="ACcovFcon"),

   mxAlgebra(expression= ApathM %*% AcovM %*% t(ApathM) + CpathM %*% Cm %*% t(CpathM) +  Em %*% t(Em) + ApathM %*% ACcovM %*% t(CpathM) + CpathM %*% t(ACcovM) %*% t(ApathM) + Dm %*% t(Dm), name="WPP2"),
   mxConstraint(WPP == WPP2, name="phenocon"),

   mxAlgebra(expression= ApathF %*% AcovF %*% t(ApathF) + CpathF %*% Cf %*% t(CpathF) +  Ef %*% t(Ef) + ApathF %*% ACcovF %*% t(CpathF) + CpathF %*% t(ACcovF) %*% t(ApathF) + Df %*% t(Df), name="WPP3"),
   mxConstraint(WPP == WPP3, name="phenocon2"),

   mxAlgebra(expression= MSc %*% WPP %*% t(MSc) + FSc %*% WPP %*% t(FSc) + MSc %*% E1 %*% t(FSc) + FSc %*% t(E1) %*% t(MSc)   + Iden, name="Cm2"),
   mxConstraint(Cm == Cm2, name="Cmcon"),

   mxAlgebra(expression= MDc %*% WPP %*% t(MDc) + FDc %*% WPP %*%  t(FDc) + MDc %*% E1 %*% t(FDc) + FDc %*% t(E1) %*% t(MDc)   + Iden, name="Cm3"),
   mxConstraint(Cm == Cm3, name="Cmcon2")

   )

   mzmModel <-  mxModel(name = "MZMNTF",

   mxMatrix(type="Full", nrow=1, ncol=8, free=TRUE, values=170, label="mean", dimnames=list(NULL, c("t1","t2","f","m","sbm", "sbm", "sbf", "sbf")), name="Meanmzm"),
# Algebra for expected variance/covariance matrix in MZM
mxAlgebra(expression=rbind(
    cbind(NTF.WPP,     NTF.CvMZM,  NTF.CvFS, NTF.CvMS, NTF.CvSibMM, NTF.CvSibMM, NTF.CvSibOS, NTF.CvSibOS ),
    cbind(NTF.CvMZM,   NTF.WPP,    NTF.CvFS, NTF.CvMS, NTF.CvSibMM, NTF.CvSibMM, NTF.CvSibOS, NTF.CvSibOS ),
    cbind(NTF.CvFS,    NTF.CvFS,   NTF.WPP,  NTF.E1,   NTF.CvFS,    NTF.CvFS,    NTF.CvFD,    NTF.CvFD    ),
    cbind(NTF.CvMS,    NTF.CvMS,   NTF.E1,   NTF.WPP,  NTF.CvMS,    NTF.CvMS,    NTF.CvMD,    NTF.CvMD    ),
    cbind(NTF.CvSibMM, NTF.CvSibMM,NTF.CvFS, NTF.CvMS, NTF.WPP,     NTF.CvSibMM, NTF.CvSibOS, NTF.CvSibOS ),
    cbind(NTF.CvSibMM, NTF.CvSibMM,NTF.CvFS, NTF.CvMS, NTF.CvSibMM, NTF.WPP,     NTF.CvSibOS, NTF.CvSibOS ),
    cbind(NTF.CvSibOS, NTF.CvSibOS,NTF.CvFD, NTF.CvMD, NTF.CvSibOS, NTF.CvSibOS, NTF.WPP,     NTF.CvSibFF ),
    cbind(NTF.CvSibOS, NTF.CvSibOS,NTF.CvFD, NTF.CvMD, NTF.CvSibOS, NTF.CvSibOS, NTF.CvSibFF, NTF.WPP     )),
dimnames=list(c("t1","t2","f","m","sbm", "sbm", "sbf", "sbf"),c("t1","t2","f","m","sbm", "sbm", "sbf", "sbf")),name="expCovMzm"),

mxData(observed=mzm, type="raw"),
  mxFIMLObjective(covariance="expCovMzm",means="Meanmzm")

)

dzmModel <- mxModel(name = "DZMNTF",

   mxMatrix(type="Full", nrow=1, ncol=8, free=TRUE, values=170, label="mean", dimnames=list(NULL, c("t1","t2","f","m","sbm", "sbm", "sbf", "sbf")), name="Meandzm"),
# Algebra for expected variance/covariance matrix in DZM
mxAlgebra(expression=rbind(
    cbind(NTF.WPP,     NTF.CvDZM,  NTF.CvFS, NTF.CvMS, NTF.CvSibMM, NTF.CvSibMM, NTF.CvSibOS, NTF.CvSibOS ),
    cbind(NTF.CvDZM,   NTF.WPP,    NTF.CvFS, NTF.CvMS, NTF.CvSibMM, NTF.CvSibMM, NTF.CvSibOS, NTF.CvSibOS ),
    cbind(NTF.CvFS,    NTF.CvFS,   NTF.WPP,  NTF.E1,   NTF.CvFS,    NTF.CvFS,    NTF.CvFD,    NTF.CvFD    ),
    cbind(NTF.CvMS,    NTF.CvMS,   NTF.E1,   NTF.WPP,  NTF.CvMS,    NTF.CvMS,    NTF.CvMD,    NTF.CvMD    ),
    cbind(NTF.CvSibMM, NTF.CvSibMM,NTF.CvFS, NTF.CvMS, NTF.WPP,     NTF.CvSibMM, NTF.CvSibOS, NTF.CvSibOS ),
    cbind(NTF.CvSibMM, NTF.CvSibMM,NTF.CvFS, NTF.CvMS, NTF.CvSibMM, NTF.WPP,     NTF.CvSibOS, NTF.CvSibOS ),
    cbind(NTF.CvSibOS, NTF.CvSibOS,NTF.CvFD, NTF.CvMD, NTF.CvSibOS, NTF.CvSibOS,NTF.WPP,     NTF.CvSibFF ),
    cbind(NTF.CvSibOS, NTF.CvSibOS,NTF.CvFD, NTF.CvMD, NTF.CvSibOS, NTF.CvSibOS, NTF.CvSibFF, NTF.WPP     )),
dimnames=list(c("t1","t2","f","m","sbm", "sbm", "sbf", "sbf"),c("t1","t2","f","m","sbm", "sbm", "sbf", "sbf")),name="expCovDzm"),

mxData(observed=dzm, type="raw"),
  mxFIMLObjective(covariance="expCovDzm",means="Meandzm")

)

mzfModel <- mxModel(name = "MZFNTF",

   mxMatrix(type="Full", nrow=1, ncol=8, free=TRUE, values=170, label="mean", dimnames=list(NULL, c("t1","t2","f","m","sbm", "sbm", "sbf", "sbf")), name="Meanmzf"),
# Algebra for expected variance/covariance matrix in MZF
mxAlgebra(expression=rbind(
    cbind(NTF.WPP,     NTF.CvMZF,  NTF.CvFD, NTF.CvMD, NTF.CvSibOS, NTF.CvSibOS, NTF.CvSibFF, NTF.CvSibFF ),
    cbind(NTF.CvMZF,   NTF.WPP,    NTF.CvFD, NTF.CvMD, NTF.CvSibOS, NTF.CvSibOS, NTF.CvSibFF, NTF.CvSibFF ),
    cbind(NTF.CvFD,    NTF.CvFD,   NTF.WPP,  NTF.E1,   NTF.CvFS,    NTF.CvFS,    NTF.CvFD,    NTF.CvFD    ),
    cbind(NTF.CvMD,    NTF.CvMD,   NTF.E1,   NTF.WPP,  NTF.CvMS,    NTF.CvMS,    NTF.CvMD,    NTF.CvMD    ),
    cbind(NTF.CvSibOS, NTF.CvSibOS,NTF.CvFS, NTF.CvMS, NTF.WPP,     NTF.CvSibMM, NTF.CvSibOS, NTF.CvSibOS ),
    cbind(NTF.CvSibOS, NTF.CvSibOS,NTF.CvFS, NTF.CvMS, NTF.CvSibMM, NTF.WPP,     NTF.CvSibOS, NTF.CvSibOS ),
    cbind(NTF.CvSibFF, NTF.CvSibFF,NTF.CvFD, NTF.CvMD, NTF.CvSibOS, NTF.CvSibOS, NTF.WPP,     NTF.CvSibFF ),
    cbind(NTF.CvSibFF, NTF.CvSibFF,NTF.CvFD, NTF.CvMD, NTF.CvSibOS, NTF.CvSibOS, NTF.CvSibFF, NTF.WPP     )),
dimnames=list(c("t1","t2","f","m","sbm", "sbm", "sbf", "sbf"),c("t1","t2","f","m","sbm", "sbm", "sbf", "sbf")),name="expCovMzf"),

mxData(observed=mzf, type="raw"),
  mxFIMLObjective(covariance="expCovMzf",means="Meanmzf")

)

dzfModel <- mxModel(name = "DZFNTF",

   mxMatrix(type="Full", nrow=1, ncol=8, free=TRUE, values=170, label="mean", dimnames=list(NULL, c("t1","t2","f","m","sbm", "sbm", "sbf", "sbf")), name="Meandzf"),
# Algebra for expected variance/covariance matrix in MZF
mxAlgebra(expression=rbind(
    cbind(NTF.WPP,     NTF.CvDZF,  NTF.CvFD, NTF.CvMD, NTF.CvSibOS, NTF.CvSibOS, NTF.CvSibFF, NTF.CvSibFF ),
    cbind(NTF.CvDZF,   NTF.WPP,    NTF.CvFD, NTF.CvMD, NTF.CvSibOS, NTF.CvSibOS, NTF.CvSibFF, NTF.CvSibFF ),
    cbind(NTF.CvFD,    NTF.CvFD,   NTF.WPP,  NTF.E1,   NTF.CvFS,    NTF.CvFS,    NTF.CvFD,    NTF.CvFD    ),
    cbind(NTF.CvMD,    NTF.CvMD,   NTF.E1,   NTF.WPP,  NTF.CvMS,    NTF.CvMS,    NTF.CvMD,    NTF.CvMD    ),
    cbind(NTF.CvSibOS, NTF.CvSibOS,NTF.CvFS, NTF.CvMS, NTF.WPP,     NTF.CvSibMM, NTF.CvSibOS, NTF.CvSibOS ),
    cbind(NTF.CvSibOS, NTF.CvSibOS,NTF.CvFS, NTF.CvMS, NTF.CvSibMM, NTF.WPP,     NTF.CvSibOS, NTF.CvSibOS ),
    cbind(NTF.CvSibFF, NTF.CvSibFF,NTF.CvFD, NTF.CvMD, NTF.CvSibOS, NTF.CvSibOS, NTF.WPP,     NTF.CvSibFF ),
    cbind(NTF.CvSibFF, NTF.CvSibFF,NTF.CvFD, NTF.CvMD, NTF.CvSibOS, NTF.CvSibOS, NTF.CvSibFF, NTF.WPP     )),
dimnames=list(c("t1","t2","f","m","sbm", "sbm", "sbf", "sbf"),c("t1","t2","f","m","sbm", "sbm", "sbf", "sbf")),name="expCovDzf"),

mxData(observed=dzf, type="raw"),
  mxFIMLObjective(covariance="expCovDzf",means="Meandzf")

)

dosModel <- mxModel(name = "DOSNTF",

   mxMatrix(type="Full", nrow=1, ncol=8, free=TRUE, values=170, label="mean", dimnames=list(NULL, c("t1","t2","f","m","sbm", "sbm", "sbf", "sbf")), name="Meandos"),
# Algebra for expected variance/covariance matrix in DOS
mxAlgebra(expression=rbind(
    cbind(NTF.WPP,     NTF.CvDOS,  NTF.CvFS, NTF.CvMS, NTF.CvSibMM, NTF.CvSibMM, NTF.CvSibOS, NTF.CvSibOS ),
    cbind(NTF.CvDOS,   NTF.WPP,    NTF.CvFD, NTF.CvMD, NTF.CvSibOS, NTF.CvSibOS, NTF.CvSibFF, NTF.CvSibFF ),
    cbind(NTF.CvFS,    NTF.CvFD,   NTF.WPP,  NTF.E1,   NTF.CvFS,    NTF.CvFS,    NTF.CvFD,    NTF.CvFD    ),
    cbind(NTF.CvMS,    NTF.CvMD,   NTF.E1,   NTF.WPP,  NTF.CvMS,    NTF.CvMS,    NTF.CvMD,    NTF.CvMD    ),
    cbind(NTF.CvSibMM, NTF.CvSibOS,NTF.CvFS, NTF.CvMS, NTF.WPP,     NTF.CvSibMM, NTF.CvSibOS, NTF.CvSibOS ),
    cbind(NTF.CvSibMM, NTF.CvSibOS,NTF.CvFS, NTF.CvMS, NTF.CvSibMM, NTF.WPP,     NTF.CvSibOS, NTF.CvSibOS ),
    cbind(NTF.CvSibOS, NTF.CvSibFF,NTF.CvFD, NTF.CvMD, NTF.CvSibOS, NTF.CvSibOS, NTF.WPP,     NTF.CvSibFF ),
    cbind(NTF.CvSibOS, NTF.CvSibFF,NTF.CvFD, NTF.CvMD, NTF.CvSibOS, NTF.CvSibOS, NTF.CvSibFF, NTF.WPP     )),
dimnames=list(c("t1","t2","f","m","sbm", "sbm", "sbf", "sbf"),c("t1","t2","f","m","sbm", "sbm", "sbf", "sbf")),name="expCovDos"),

mxData(observed=dos, type="raw"),
  mxFIMLObjective(covariance="expCovDos",means="Meandos")

)

   FinalModel &lt;- mxModel(model="NucTwFam", mzmModel, dzmModel, mzfModel, dzfModel, dosModel, ntf,
       mxAlgebra(expression=MZMNTF.objective + DZMNTF.objective + MZFNTF.objective + DZFNTF.objective + DOSNTF.objective , name="ntffit"), #MZ.objective is the automatic name for the -2LL of mzModel
       mxAlgebraObjective("ntffit")
    )                                                                                    

Fit <- mxRun(FinalModel)
summary(Fit)