tbates / umx

Making Structural Equation Modeling (SEM) in R quick & powerful
https://tbates.github.io/
44 stars 17 forks source link

umxDOC with ordinal variables #175

Closed lf-araujo closed 2 years ago

lf-araujo commented 2 years ago

Hi Tim,

I was experimenting with the umxDoC function and noticed it seems not to work with ordinal variables, my testing data set looks like:

image

My code:

doc <- umxDoC(
  sep = "_t",
  mzData = mzData,
  dzData = dzData,
  var1Indicators = c("anx", "dr", "eat", "dep", "adhd"),
  var2Indicators = c("dm", "hd", "hch", "hbp", "art", "cbp", "all", "res", "mig", "epi")
)

Which errors with:

image


Also, I see that umxDoC is less flexible on its calls, compared to umxCP. It loses the ability to pass the data set directly, like:

m2 <- umxCP(
  name = "2fac",
  data = dt,
  sep = "_t",
  selDVs = selDVs,
  mzData = "1: monozygotic",
  dzData = "2: dizygotic",
  nFac = 2
)

Is this by design? I think the above is quicker to write (and to pipe to and from) than splitting the data beforehand.

lf-araujo commented 2 years ago

Hi Tim,

Found that the DoCp works as intended regarding ordinal variables.


Now, I took this opportunity to try a pull request that adds the data, zyg arguments to umxDoC. First ever PR, so please recheck. It works locally.

Best, luis

lf-araujo commented 2 years ago

Thanks so much for the merge. This is very cool. Sorry for the assignments (<-) and the lack of @param, now I get it. I will get the hang of it over time.

Now, in umxDoCp, the part:

        # 5. ✓ Load specifics onto var1 and var2 indicators
        umxPath(as, to = c(var1Indicators, var2Indicators), values = .6),
        umxPath(cs, to = c(var1Indicators, var2Indicators), values = .6),
        umxPath(es, to = c(var1Indicators, var2Indicators), values = .6, lbound=1e-5),

Is it really correct, considering the model you are trying to specify?

DoC

tbates commented 2 years ago

great! It's a fun if somewhat arduous learning curve.

The model should be drawn as below (I tried to keep the models clean and easy to see, but didn't always draw, for instance, all twin groups, or all residuals (your question), or fixed @1 variances. net net, I think that was a mistake.

So sprint goal: Upload a figure that's closer to "what we show is every path in the diagram" tonight.

DoC