OpenMx icon indicating copy to clipboard operation
OpenMx copied to clipboard

Users cannot label expected means matrix

Open mcneale opened this issue 4 years ago • 5 comments

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.

mcneale avatar Nov 30 '21 11:11 mcneale

I think the problem is that you labelled the row. I suggest we only compare the colnames?

jpritikin avatar Nov 30 '21 16:11 jpritikin

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

tbates avatar Nov 30 '21 16:11 tbates

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.

mcneale avatar Nov 30 '21 17:11 mcneale

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?

jpritikin avatar Nov 30 '21 17:11 jpritikin

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

tbates avatar Feb 17 '22 21:02 tbates