Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users cannot label expected means matrix #333

Open
mcneale opened this issue Nov 30, 2021 · 5 comments
Open

Users cannot label expected means matrix #333

mcneale opened this issue Nov 30, 2021 · 5 comments

Comments

@mcneale
Copy link
Contributor

mcneale commented Nov 30, 2021

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.

@jpritikin
Copy link
Member

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

@tbates
Copy link
Member

tbates commented Nov 30, 2021

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

@mcneale
Copy link
Contributor Author

mcneale commented Nov 30, 2021

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.

@jpritikin
Copy link
Member

jpritikin commented Nov 30, 2021

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?

@tbates
Copy link
Member

tbates commented Feb 17, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants