Running examples in ‘umx-Ex.R’ failed
The error most likely occurred in:

> ### Name: umxACE
> ### Title: umxACE: Build and run a Cholesky (uni- or multi-variate)
> ### Aliases: umxACE
> 
> ### ** Examples
> 
> 
> # ===========================
> # = Univariate model of BMI =
> # ===========================
> require(umx)
> data(twinData) # ?twinData set from Australian twins.
> # Pick the variables
> selDVs = c("bmi1", "bmi2")
> mzData <- twinData[twinData$zyg == 1,]
> dzData <- twinData[twinData$zyg == 3,]
> m1 = umxACE(selDVs = selDVs, dzData = dzData, mzData = mzData)
All variables continuous
treating data as raw
Running ACE with 4 parameters
-2 × log(Likelihood)
'log Lik.' 4067.663 (df=4)
Standardized solution


|     |   a1|c1 |   e1|
|:----|----:|:--|----:|
|bmi1 | 0.88|.  | 0.47|
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
> umxSummary(m1, std = FALSE)
-2 × log(Likelihood)
'log Lik.' 4067.663 (df=4)
Raw solution


|     |   a1|c1 |   e1|
|:----|----:|:--|----:|
|bmi1 | 0.79|.  | 0.42|
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
> plot(m1)
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
> 
> # =========================================
> # = ADE model (DZ correlation set to .25) =
> # =========================================
> m2 = umxACE("ADE", selDVs = selDVs, dzData = dzData, mzData = mzData, dzCr = .25)
All variables continuous
treating data as raw
Running ADE with 4 parameters
-2 × log(Likelihood)
'log Lik.' 4063.45 (df=4)
Standardized solution


|     |   a1|   c1|   e1|
|:----|----:|----:|----:|
|bmi1 | 0.64| 0.61| 0.47|
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
> umxCompare(m2, m1) # ADE is better
Warning in collectStatistics(nextBaseSummary, nextCompareSummary) :
  Model 'ADE' has more degrees of freedom than ACE which means that either the models need to be compared in the oppposite order or the models are not nested and should not be compared with the likelihood ratio test


|Model | EP|∆ -2LL    |∆ df |p  |      AIC|Compare with Model |
|:-----|--:|:---------|:----|:--|--------:|:------------------|
|ADE   |  4|          |     |   | 517.4496|                   |
|ACE   |  4|4.2132753 |0    |   | 521.6629|ADE                |
> umxSummary(m2, compare = m1) # nb: though this is ADE, columns are labeled ACE
-2 × log(Likelihood)
'log Lik.' 4063.45 (df=4)
Standardized solution


|     |   a1|   c1|   e1|
|:----|----:|----:|----:|
|bmi1 | 0.64| 0.61| 0.47|
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
> 
> 
> # =====================================
> # = Bivariate height and weight model =
> # =====================================
> data(twinData)
> selDVs = c("ht", "wt") # umx will add suffix (in this case "") + "1" or '2'
> mzData <- twinData[twinData$zygosity %in% c("MZFF", "MZMM"),]
> dzData <- twinData[twinData$zygosity %in% c("DZFF", "DZMM", "DZOS"), ]
> mzData <- mzData[1:80,] # quicker run to keep CRAN happy
> dzData <- dzData[1:80,]
> m1 = umxACE(selDVs = selDVs, dzData = dzData, mzData = mzData, suffix = '')
All variables continuous
treating data as raw
Running ACE with 11 parameters
Warning: In model 'ACE' Optimizer returned a non-zero status code 6. The model does not satisfy the first-order optimality conditions to the required accuracy, and no improved point for the merit function could be found during the final linesearch (Mx status RED)
-2 × log(Likelihood)
'log Lik.' 1136.411 (df=11)
Standardized solution


|    |   a1|a2   |    c1|c2 |   e1|e2  |
|:---|----:|:----|-----:|:--|----:|:---|
|ht1 | 0.76|     | -0.43|   | 0.49|    |
|wt1 | 0.60|0.68 |  0.10|.  | 0.02|0.4 |
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
> umxSummary(m1)
-2 × log(Likelihood)
'log Lik.' 1136.411 (df=11)
Standardized solution


|    |   a1|a2   |    c1|c2 |   e1|e2  |
|:---|----:|:----|-----:|:--|----:|:---|
|ht1 | 0.76|     | -0.43|   | 0.49|    |
|wt1 | 0.60|0.68 |  0.10|.  | 0.02|0.4 |
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
> 
> # ================================================================
> # = Well done! Now you can make and compare twin models in R :-) =
> # ================================================================
> 
> 
> # ===================
> # = Ordinal example =
> # ===================
> require(umx)
> data(twinData)
> # Cut bmi colum to form ordinal obesity variables
> ordDVs = c("obese1", "obese2")
> selDVs = c("obese")
> obesityLevels = c('normal', 'overweight', 'obese')
> cutPoints <- quantile(twinData[, "bmi1"], probs = c(.5, .2), na.rm = TRUE)
> twinData$obese1 <- cut(twinData$bmi1, breaks = c(-Inf, cutPoints, Inf), labels = obesityLevels) 
> twinData$obese2 <- cut(twinData$bmi2, breaks = c(-Inf, cutPoints, Inf), labels = obesityLevels) 
> # Make the ordinal variables into mxFactors (ensure ordered is TRUE, and require levels)
> twinData[, ordDVs] <- mxFactor(twinData[, ordDVs], levels = obesityLevels)
> mzData <- twinData[twinData$zyg == 1, umx_paste_names(selDVs, "", 1:2)]
> dzData <- twinData[twinData$zyg == 3, umx_paste_names(selDVs, "", 1:2)]
> mzData <- mzData[1:80,] # just top 80 pairs to run fast
> dzData <- dzData[1:80,]
> str(mzData) # make sure mz, dz, and t1 and t2 have the same levels!
'data.frame':	80 obs. of  2 variables:
 $ obese1: Ord.factor w/ 3 levels "normal"<"overweight"<..: 2 2 2 3 1 3 2 1 1 3 ...
 $ obese2: Ord.factor w/ 3 levels "normal"<"overweight"<..: 1 1 1 3 1 3 2 1 1 2 ...
> m1 = umxACE(selDVs = selDVs, dzData = dzData, mzData = mzData, suffix = '')
umxACE found 1 pairs of ordinal variables:'obese1' and 'obese2'
No binary variables were found
No continuous variables found.
treating data as raw
Running ACE with 4 parameters
-2 × log(Likelihood)
'log Lik.' 644.9818 (df=4)
Standardized solution


|       |   a1|   c1|   e1|
|:------|----:|----:|----:|
|obese1 | 0.72| 0.42| 0.56|
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
> umxSummary(m1)
-2 × log(Likelihood)
'log Lik.' 644.9818 (df=4)
Standardized solution


|       |   a1|   c1|   e1|
|:------|----:|----:|----:|
|obese1 | 0.72| 0.42| 0.56|
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
> 
> # ============================================
> # = Bivariate continuous and ordinal example =
> # ============================================
> data(twinData)
> selDVs = c("wt", "obese")
> # Cut bmi column to form ordinal obesity variables
> ordDVs = c("obese1", "obese2")
> obesityLevels = c('normal', 'overweight', 'obese')
> cutPoints <- quantile(twinData[, "bmi1"], probs = c(.5, .2), na.rm = TRUE)
> twinData$obese1 <- cut(twinData$bmi1, breaks = c(-Inf, cutPoints, Inf), labels = obesityLevels) 
> twinData$obese2 <- cut(twinData$bmi2, breaks = c(-Inf, cutPoints, Inf), labels = obesityLevels) 
> # Make the ordinal variables into mxFactors (ensure ordered is TRUE, and require levels)
> twinData[, ordDVs] <- mxFactor(twinData[, ordDVs], levels = obesityLevels)
> mzData <- twinData[twinData$zyg == 1,] # umxACE can trim out unused variables on its own
> dzData <- twinData[twinData$zyg == 3,]
> mzData <- mzData[1:80,] # just top 80 so example runs in a couple of secs
> dzData <- dzData[1:80,]
> m1 = umxACE(selDVs = selDVs, dzData = dzData, mzData = mzData, suffix = '')
umxACE found 1 pairs of ordinal variables:'obese1' and 'obese2'
No binary variables were found
There were also 1 pairs of continuous variables:'wt1' and 'wt2'
treating data as raw
Running ACE with 11 parameters
-2 × log(Likelihood)
'log Lik.' 2514.258 (df=11)
Standardized solution


|       |   a1|a2   |   c1|c2 |   e1|e2  |
|:------|----:|:----|----:|:--|----:|:---|
|wt1    | 0.90|     | 0.15|   | 0.40|    |
|obese1 | 0.58|0.34 | 0.47|.  | 0.54|0.2 |
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
> plot(m1)
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
> 
> # =======================================
> # = Mixed continuous and binary example =
> # =======================================
> require(umx)
> data(twinData)
> # Cut to form category of 20% obese subjects
> cutPoints <- quantile(twinData[, "bmi1"], probs = .2, na.rm = TRUE)
> obesityLevels = c('normal', 'obese')
> twinData$obese1 <- cut(twinData$bmi1, breaks = c(-Inf, cutPoints, Inf), labels = obesityLevels) 
> twinData$obese2 <- cut(twinData$bmi2, breaks = c(-Inf, cutPoints, Inf), labels = obesityLevels) 
> # Make the ordinal variables into mxFactors (ensure ordered is TRUE, and require levels)
> ordDVs = c("obese1", "obese2")
> twinData[, ordDVs] <- mxFactor(twinData[, ordDVs], levels = obesityLevels)
> selDVs = c("wt", "obese")
> mzData <- twinData[twinData$zyg == 1, umx_paste_names(selDVs, "", 1:2)]
> dzData <- twinData[twinData$zyg == 3, umx_paste_names(selDVs, "", 1:2)]
> mzData <- mzData[1:80,] # just top 80 so example runs in a couple of secs
> dzData <- dzData[1:80,]
> m1 = umxACE(selDVs = selDVs, dzData = dzData, mzData = mzData, suffix = '')
umxACE found 1 pairs of binary variables:'obese1' and 'obese2'

I am fixing the latent means and variances of these variables to 0 and 1

and 1 pairs of continuous variables:'wt1' and 'wt2'
object 'threshMat' created to handle 
1 pair(s) of binary variables:'obese1' and 'obese2'

2 trait(s) are binary (only 2-levels).
'obese2' and NA
For these, you you MUST fix the mean and variance of the latent traits driving each variable (usually 0  & 1 respectively) .
See ?mxThresholdMatrix
Using deviation-based model: Thresholds will be in'threshMat' based on deviations in 'deviations_for_thresh'
treating data as raw
Running ACE with 11 parameters
Warning: In model 'ACE' Optimizer returned a non-zero status code 6. The model does not satisfy the first-order optimality conditions to the required accuracy, and no improved point for the merit function could be found during the final linesearch (Mx status RED)
-2 × log(Likelihood)
'log Lik.' 12689.16 (df=11)
Standardized solution


|       |   a1|a2   |    c1|c2    |   e1|e2   |
|:------|----:|:----|-----:|:-----|----:|:----|
|wt1    | 0.15|     | -0.99|      | 0.03|     |
|obese1 | 0.39|0.42 |  0.01|-0.71 | 0.39|0.13 |
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
> umxSummary(m1)
-2 × log(Likelihood)
'log Lik.' 12689.16 (df=11)
Standardized solution


|       |   a1|a2   |    c1|c2    |   e1|e2   |
|:------|----:|:----|-----:|:-----|----:|:----|
|wt1    | 0.15|     | -0.99|      | 0.03|     |
|obese1 | 0.39|0.42 |  0.01|-0.71 | 0.39|0.13 |
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
> 
> # ===================================
> # Example with covariance data only =
> # ===================================
> 
> require(umx)
> data(twinData)
> selDVs = c("wt1", "wt2")
> mz = cov(twinData[twinData$zyg == 1, selDVs], use = "complete")
> dz = cov(twinData[twinData$zyg == 3, selDVs], use = "complete")
> m1 = umxACE(selDVs=selDVs, dzData=dz, mzData=mz, numObsDZ=nrow(dzData), numObsMZ=nrow(mzData))
treating data as cov
Running ACE with 3 parameters
-2 × log(Likelihood)
'log Lik.' 1601.057 (df=3)
Standardized solution


|    |   a1|c1 |   e1|
|:---|----:|:--|----:|
|wt1 | 0.92|.  | 0.39|
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
> umxSummary(m1)
-2 × log(Likelihood)
'log Lik.' 1601.057 (df=3)
Standardized solution


|    |   a1|c1 |   e1|
|:---|----:|:--|----:|
|wt1 | 0.92|.  | 0.39|
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
> plot(m1)
Current format is'DiagrammeR'. Valid options are 'graphviz' or 'DiagrammeR'
> # =========================================================
> # Example with Tobin data (this is not profuction quality =
> # Definately a work in progress!!!                        =
> # =========================================================
> 
> # Analyse a dataset in which only people with a BMI over 22 had their BMI recorded
> 
> require(umx)
> data(twinData)
> baseNames = c("bmi")
> selDVs = umx_paste_names(baseNames, "", 1:2)
> tmp = twinData[, c(selDVs, "zyg")]
> tmp$bmi1[tmp$bmi1 <= 22] = 22
> tmp$bmi2[tmp$bmi2 <= 22] = 22
> tmp = umxFactor(tmp) # BAD! letting it know that there are wide data!
> tmp = umxFactor(tmp, sep = "") # GOOD same factor for each twin!
Warning in levels(x) == levels :
  longer object length is not a multiple of shorter object length
Warning in if (!levels(x) == levels) { :
  the condition has length > 1 and only the first element will be used
Warning in levels(x) == levels :
  longer object length is not a multiple of shorter object length
Warning in if (!levels(x) == levels) { :
  the condition has length > 1 and only the first element will be used
> mz = tmp[tmp$zyg == 1, selDVs]
> dz = tmp[tmp$zyg == 3, selDVs]
> x  = umxThresholdMatrix(dz, sep = "", thresholds = "left_censored", verbose = TRUE)
object 'threshMat' created to handle 
1 pair(s) of ordinal variables:'bmi1' and 'bmi2'


Using left_censored for a fixed-threshold Tobit-style analysis
> m1 = umxACE(selDVs = baseNames, dzData = dz, mzData = mz, suffix = "", thresholds = "left_censored")
umxACE found 1 pairs of ordinal variables:'bmi1' and 'bmi2'
No binary variables were found
No continuous variables found.

Using left_censored for a fixed-threshold Tobit-style analysis
treating data as raw
Running ACE with 4 parameters
Warning: In model 'ACE' Optimizer returned a non-zero status code 10. Starting values are not feasible. Consider mxTryHard()
Error: The job for model 'ACE' exited abnormally with the error message: fit is not finite (1: Multivariate normal integration failure:
cor =  matrix(c(    # 2x2
   1, 0.5
, 0.5,   1), byrow=TRUE, nrow=2, ncol=2)
lower = t( matrix(c(    # 2x1
 -inf, 37.9478), byrow=TRUE, nrow=1, ncol=2))
upper = t( matrix(c(    # 2x1
 37.9319, 37.9608), byrow=TRUE, nrow=1, ncol=2))

)
Execution halted