You are here

can mxPath error include the path?

got this error

Error: mxPath() call will generate 2 paths but you have specified 3 values

Would be very helpful if the error could include the mxPath as coded to help find the bad path, for instance in a list of possible bad paths like this:

Error: mxPath() call will generate 2 paths but you have specified 3 values:
    mxPath(from= c("x","y"),  arrows=2, free=TRUE, values=c(1, 1), labels=c("Varx","Vary"))

<

pre>
defModel<-mxModel("Def model", type="RAM",
mxData(myData, type="raw"),
manifestVars=c("x","y"),
latentVars="DefDummy",
mxPath(from=c("x","y"), arrows=2, free=TRUE, values=c(1,.1,1), labels=c("Varx","Vary")), # variances
mxPath(from="x", to="y", arrows=2, free=TRUE, values=c(.1), labels=c("Covxy")), # covariances
mxPath(from="one", to=c("x","y","DefDummy"), arrows=1, free=c(TRUE,TRUE,FALSE), values=c(1,1,1), labels =c("meanx","meany","data.def")), # means
mxPath(from="DefDummy", to=c("x","y"), arrows=1, free=c(TRUE,TRUE), values=c(1,1), labels =c("beta_1","beta_2")) # moderator paths
)

Reporter: 
Created: 
Sun, 09/27/2009 - 11:34
Updated: 
Mon, 10/12/2009 - 15:06

Comments

Use traceback(). The problem is that if we always include the stack trace, then we'll get the complaint "OMG what is all this error output, it's so confusing." And the stacktrace is all or nothing, there's no such thing as a partial stacktrace.

> traceback()
6: stop(paste("mxPath() call will generate", numPaths, "paths but you have specified", 
       len, lenName), call. = FALSE)
5: pathCheckSingleLength(numPaths, length(values), "values")
4: pathCheckLengths(from, to, arrows, values, free, labels, lbound, 
       ubound)
3: generatePath(from, to, all, arrows, values, free, labels, lbound, 
       ubound)
2: mxPath(from = c("x", "y"), arrows = 2, free = TRUE, values = c(1, 
       0.1, 1), labels = c("Varx", "Vary"))
1: mxModel("Def model", type = "RAM", mxData(myData, type = "raw"), 
       manifestVars = c("x", "y"), latentVars = "DefDummy", mxPath(from = c("x", 
           "y"), arrows = 2, free = TRUE, values = c(1, 0.1, 1), 
           labels = c("Varx", "Vary")), mxPath(from = "x", to = "y", 
           arrows = 2, free = TRUE, values = c(0.1), labels = c("Covxy")), 
       mxPath(from = "one", to = c("x", "y", "DefDummy"), arrows = 1, 
           free = c(TRUE, TRUE, FALSE), values = c(1, 1, 1), labels = c("meanx", 
               "meany", "data.def")), mxPath(from = "DefDummy", 
           to = c("x", "y"), arrows = 1, free = c(TRUE, TRUE), values = c(1, 
               1), labels = c("beta_1", "beta_2")))

As a compromise the error message has been modified to print:

Error: mxPath() call will generate 2 paths but you have specified 3 values with 'from' argument assigned to 'x' and 'y' and 'to' argument assigned to 'NA'

thanks michael! very helpful: anyone who reads that will be able to locate the problematic statement.

Automatically closed -- issue fixed for 2 weeks with no activity.