Users cannot label expected means matrix
If the user correctly labels the means matrix, it generates an error. Ideally, the names and their order should be compared; if different then error, otherwise proceed.
twinModel1out <- mxRun(twinModel1) Error: The expected means matrix associated with the expectation function in model 'DZ' contains dimnames: mean, c("BMI1", "SBP1", "FTO1", "BMI2", "SBP2", "FTO2"). The expectation function has specified dimnames: BMI1, SBP1, FTO1, BMI2, SBP2, FTO2.
I think the problem is that you labelled the row. I suggest we only compare the colnames?
I guess it's been conventional for the row element of the dim names list to be NULL, so they don't get checked.
mxMatrix("Full",1, 3, free = TRUE, dimnames = list(NULL, selVars))
Not sure if there would be side effects of ignoring non-Null row names. Might be best to say:
The row names of the expected means matrix associated with the expectation function in model 'DZ' contains dimnames: mean. The expectation function expected row dimnames to be NULL
Actually, I labelled both. With either "mean" for a row name (as above) or NULL, it is not happy at all about column labels on the mean algebra.
it is not happy at all about column labels on the mean algebra
Oh, you're using an mxAlgebra for the mean? Hm, do we have a test for that? Can you provide an example?
Here's an example. It appears to work: The means fix fixed the algebra double naming also...
But exposes an issue where other functions (at least mxStandardizeRAMpaths don't work (see below).
data(HS.ability.data) # load the data
Spatial = c("visual", "cubes", "paper")
m1 = umxRAM(model= "Holzinger_and_Swineford_1939", data = HS.ability.data,
umxPath(from = "vis", to = Spatial),
umxPath(v1m0 = "vis"),
umxPath(v.m. = Spatial),
mxAlgebra(name = "myMcols", M, dimnames = list(NULL, c(Spatial, "vis"))),
mxAlgebra(name = "myMboth", M, dimnames = list("means", c(Spatial, "vis")))
)
m1$expectation$M = "myMcols"
m1 = mxRun(m1)
m1$expectation$M = "myMboth"
m1 = mxRun(m1)
so far so good but other functions are not happy with the M matrix being an algebra, I think?
mxStandardizeRAMpaths(m1)
Error in out$label[j] <- model_M$labels[1, M_need_pos[i]] : replacement has length zero