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

Better warning for missing dimnames on a mxExpectationRAM model #339

Open
lf-araujo opened this issue Apr 15, 2022 · 0 comments
Open

Better warning for missing dimnames on a mxExpectationRAM model #339

lf-araujo opened this issue Apr 15, 2022 · 0 comments

Comments

@lf-araujo
Copy link
Contributor

Hi all,

If you don't add dimnames to the main model, but adds dimnames to the F matrix and call mxExpectationRAM( dimnames=c(manifests, latents)), the warning is not too helpful. It took me a while to note it was complaining about dimnames in for the entire model. Here is the example where this happens:

options(mxByrow = T)

manifests<-c("X1", "X2", "Y1", "Y2", "PGSx", "PGSy")
latents<-c("xir", "yir", "innoX1", "innoX2",  "innoY1", "innoY2")
allVariables <- c(manifests, latents)
Al = c(
NA, NA ,NA ,NA,  "PGSx_to_X1", NA, NA, NA,  NA,  NA,  NA,  NA,
NA, NA , "Y1_to_X2" ,NA,  "PGSx_to_X2", NA, NA, NA,   "innoX1_to_X2",  NA,  NA,  NA,
NA, NA ,NA ,NA, NA,  "PGSy_to_Y1", NA, NA,  NA,  NA,  NA,  NA,
 "X1_to_Y2", NA ,NA ,NA, NA,  "PGSy_to_Y2", NA, NA,  NA,  NA,   "innoY1_to_Y2",  NA,
NA, NA ,NA ,NA, NA, NA, NA, NA,  NA,  NA,  NA,  NA,
NA, NA ,NA ,NA, NA, NA, NA, NA,  NA,  NA,  NA,  NA,
NA, NA ,NA ,NA, NA, NA, NA, NA,  NA,  NA,  NA,  NA,
NA, NA ,NA ,NA, NA, NA, NA, NA,  NA,  NA,  NA,  NA,
NA, NA ,NA ,NA, NA, NA, NA, NA,  NA,  NA,  NA,  NA,
NA, NA ,NA ,NA, NA, NA, NA, NA,  NA,  NA,  NA,  NA,
NA, NA ,NA ,NA, NA, NA, NA, NA,  NA,  NA,  NA,  NA,
NA, NA ,NA ,NA, NA, NA, NA, NA,  NA,  NA,  NA,  NA
)

Sl  <- c(
NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,
NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,
NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,
NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,
NA,NA,NA,NA,NA,"PGSx_with_PGSy",NA,NA,NA,NA,NA,NA,
NA,NA,NA,NA,"PGSx_with_PGSy",NA,NA,NA,NA,NA,NA,NA,
NA,NA,NA,NA,NA,NA,NA,"xir_with_yir",NA,NA,NA,NA,
NA,NA,NA,NA,NA,NA,"xir_with_yir",NA,NA,NA,NA,NA,
NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,
NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,
NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,
NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA
)

Fv <- matrix(ncol = 12, byrow = T, c(
           1,  0,  0,  0,    0,    0,   0,   0,      0,      0,      0,      0,
          0,  1,  0,  0,    0,    0,   0,   0,      0,      0,      0,      0,
          0,  0,  1,  0,    0,    0,   0,   0,      0,      0,      0,      0,
          0,  0,  0,  1,    0,    0,   0,   0,      0,      0,      0,      0,
          0,  0,  0,  0,    1,    0,   0,   0,      0,      0,      0,      0,
          0,  0,  0,  0,    0,    1,   0,   0,      0,      0,      0,      0
          ))

ld <- mxModel("long2", type = "RAM",
      mxMatrix(name = "A",type = "Full", nrow = 12, ncol = 12, values = c(
         #X1 X2 Y1 Y2 PGSx  PGSy   xir yir     innoX1 innoX2 innoY1 innoY2
          0,  0, 0, 0,   0,   0,  1,  0,     1,     0,     0,     0,
          0,  0, 0, 0,   0,   0,  1,  0,     0,     1,     0,     0,
          0,  0, 0, 0,   0,   0,  0,  1,     0,     0,     1,     0,
          0,  0, 0, 0,   0,   0,  0,  1,     0,     0,     0,     1,
          0,  0, 0, 0,   0,   0,  0,  0,     0,     0,     0,     0,
          0,  0, 0, 0,   0,   0,  0,  0,     0,     0,     0,     0,
          0,  0, 0, 0,   0,   0,  0,  0,     0,     0,     0,     0,
          0,  0, 0, 0,   0,   0,  0,  0,     0,     0,     0,     0,
          0,  0, 0, 0,   0,   0,  0,  0,     0,     0,     0,     0,
          0,  0, 0, 0,   0,   0,  0,  0,     0,     0,     0,     0,
          0,  0, 0, 0,   0,   0,  0,  0,     0,     0,     0,     0,
          0,  0, 0, 0,   0,   0,  0,  0,     0,     0,     0,     0
        ), labels = Al, free = (!is.na(Al))),
      mxMatrix(name = "S", type = "Full", nrow=12,ncol=12,values=c(
        0,  0,  0,  0,    0,    0,   0,   0,      0,      0,      0,      0,
        0,  0,  0,  0,    0,    0,   0,   0,      0,      0,      0,      0,
        0,  0,  0,  0,    0,    0,   0,   0,      0,      0,      0,      0,
        0,  0,  0,  0,    0,    0,   0,   0,      0,      0,      0,      0,
        0,  0,  0,  0,    0,    0,   0,   0,      0,      0,      0,      0,
        0,  0,  0,  0,    0,    0,   0,   0,      0,      0,      0,      0,
        0,  0,  0,  0,    0,    0,   0,   0,      0,      0,      0,      0,
        0,  0,  0,  0,    0,    0,   0,   0,      0,      0,      0,      0,
        0,  0,  0,  0,    0,    0,   0,   0,      1,      0,      0,      0,
        0,  0,  0,  0,    0,    0,   0,   0,      0,      1,      0,      0,
        0,  0,  0,  0,    0,    0,   0,   0,      0,      0,      1,      0,
        0,  0,  0,  0,    0,    0,   0,   0,      0,      0,      0,      1
        ),  labels = Sl,  free = (!is.na(Sl))),
         mxMatrix(name = "F",type =  "Full", nrow=6, ncol=12, values=Fv,
                  free = F, labels = NA),
        mxExpectationRAM("A", "S", "F", dimnames = c(manifests, latents)),
        mxFitFunctionML()
        )

ld <- mxGenerateData(ld, empirical = T, nrows = 1000, returnModel = T)
mxRun(ld)

Error: The F matrix associated with the RAM expectation function in model 'long2 ' contains dimnames and the expectation function has specified dimnames

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

1 participant