| umx_make_double_entry_data | R Documentation |
Helper to split one or more variables in a twin dataset into a paired
continuous column (holding non-censored values) and an ordered factor column
(indicating censoring status), ready for umxACE_DE.
The function has flexible rules for censoring. You give a list() of columns, with the censoring rule for each, and the function creates new matching var_cens and var_cont columns. A rule can be a simple numeric value to cut at, e.g., list(wt=0)) for cut column wt at zero. More complex expressions should be in quotes list(wt="<= cut").
Mutual-NA invariant enforced: Each row contributes exactly one non-missing element per DE trait - continuous density f(x) or threshold CDF P(Y \le \tau) - preventing double-counting.
On non-censored rows, the function sets the var_cont to the observed value and the var_cens value to NA. On censored rows, the continuous column is set to NA, and the correct value of an ordered factor c("censored","observed") is set in var_cens (integer 1). Right-censor >=cut flips levels to c("observed","censored") so censored = integer 2 (upper tail). NA in raw propagates to NA in both.
umx_make_double_entry_data(
data,
cols = NULL,
doubleEntrySuffix = c("_cont", "_cens"),
sep = "_T",
nSib = 2,
levels = NULL
)
data |
The dataframe to process. |
cols |
A named list of variables and their censoring rules. A numeric scalar is left-censoring at that floor;
length-2 numeric is interval; character comparison (e.g. |
doubleEntrySuffix |
Suffixes for the continuous and censored columns (default = c("_cont", "_cens")). |
sep |
Suffix/separator for twin indices (default = "_T"). |
nSib |
Number of siblings/twins (default = 2). |
levels |
Ordered factor levels for the censored column. |
Double-entry data preparation creates paired continuous (_cont) and ordinal factor (_cens) columns for censored traits.
To prevent likelihood double-counting during FIML estimation:
Non-censored observations (x > cut) retain their numeric continuous score in _cont, while _cens is set to NA.
Censored observations (x \le cut) have _cont set to NA, while _cens records the ordinal censored status level.
This ensures each case contributes exactly one mutually exclusive likelihood component (either continuous PDF or ordinal CDF threshold probability).
The modified dataframe with expanded double-entry pairs and attribute umxDoubleEntry
listing per-trait cut, side, and whether the cut is fixable in a model.
umxACE_DE(), umxRAM_DE(), plot(), umxSummary(), umxModify(), umxCompare()
Other Twin Modeling Functions:
power.ACE.test(),
umx,
umxACE(),
umxACE_DE(),
umxACE_GLM(),
umxACEcov(),
umxACEv(),
umxCP(),
umxCloud(),
umxDiffMZ(),
umxDiscTwin(),
umxDoC(),
umxDoCp(),
umxGxE(),
umxGxE_window(),
umxGxEbiv(),
umxIP(),
umxMRDoC(),
umxReduce(),
umxReduceACE(),
umxReduceGxE(),
umxRotate.MxModelCP(),
umxSexLim(),
umxSimplex(),
umxSummarizeTwinData(),
umxSummaryACE(),
umxSummaryACE_GLM(),
umxSummaryACEv(),
umxSummaryDoC(),
umxSummaryGxEbiv(),
umxSummarySexLim(),
umxSummarySimplex(),
umxTwinMaker()
## Not run:
data(twinData)
prep = umx_make_double_entry_data(twinData, cols = list(wt = 0), sep = "")
# attr(prep, "umxDoubleEntry")$pairs[[1]]$cut # 0
# Then
selDVs = c("ht", "wt_cont", "wt_cens")
# Known LOD
umxACE_DE(data = prep, selDVs = selDVs, sep = "")
# Un-known LOD
umxACE_DE(data = prep, selDVs = selDVs, sep = "", fixCensorThresholds = "no")
# Mix with continuous traits:
umxACE_DE(data = prep, selDVs = c("ht", "wt_cont", "wt_cens"))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.