tbates / umx

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

Definition variables on umxTwinMaker() #224

Closed lf-araujo closed 9 months ago

lf-araujo commented 9 months ago

As soon as one adds a defn, the model fails to identify information for each twin in the data:

     data(twinData)
     tmp = umx_make_twin_data_nice(data=twinData, sep="", zygosity="zygosity", numbering=1:2)
     tmp = umx_scale_wide_twin_data(varsToScale= c("wt", "ht"), sep= "_T", data= tmp) %>%
  drop_na(bmi_T1, bmi_T2)

     mzData = subset(tmp, zygosity %in%  c("MZFF", "MZMM"))
     dzData = subset(tmp, zygosity %in%  c("DZFF", "DZMM"))

     # ==========================
     # = Make an ACE twin model =
     # ==========================
     # 1. Define paths for *one* person:
     paths = c(
        umxPath(v1m0 = c("a1", 'c1', "e1")),
        umxPath(means = c("wt")),
        umxPath(c("a1", 'c1', "e1"), to = "wt", values=.2),
  umxPath(defn = "bmi")
     )

     # 2. Make a twin model from the paths for one person
     m1 = umxTwinMaker("test", paths, mzData = mzData, dzData= dzData)

umxSummary(m1)

Errs:

Error in umx_check_names(defnNames, data = data, message = "note: used as definition variable, but not present in data") : 
  Not all required names were found in the data. Missing were:
bmi
note: used as definition variable, but not present in data
tbates commented 9 months ago

this is a good feature and one that has been requested.