Running ‘invariance.R’ [0m/180m]
  Running ‘lavaan.R’
Running the tests in ‘tests/invariance.R’ failed.
Complete output:
  > #
  > # testing invariance 
  > #
  > 
  > # simulation:
  > # factor structure holds over SES but not over age
  > # both SES and age predict a mean difference in cognitive outcome
  > 
  > set.seed(123)
  > 
  > require("semtree")
  Loading required package: semtree
  Loading required package: OpenMx
  To take full advantage of multiple cores, use:
    mxOption(NULL, 'Number of Threads', parallel::detectCores()) #now
    Sys.setenv(OMP_NUM_THREADS=parallel::detectCores()) #before library(OpenMx)
  > require("lavaan")
  Loading required package: lavaan
  This is lavaan 0.5-23.1097
  lavaan is BETA software! Please report any bugs.
  
  Attaching package: 'lavaan'
  
  The following object is masked from 'package:OpenMx':
  
      vech
  
  > #
  > lambda <- list()
  > age <- c(0,0,1,1) # 0=young, 1 =old
  > ses <- c(0,1,0,1) # 0=low, 1=high
  > lambda[[1]] <- c(1,0.9,0.8,0.8)
  > lambda[[2]] <- c(1,0.9,0.8,0.8)
  > lambda[[3]] <- c(1,0.4,0.2,0.9)
  > lambda[[4]] <- c(1,0.4,0.2,0.9)
  > cogmean <- 80-age*30 + ses*20
  > cogsd <- 1
  > errsd <- 1
  > 
  > Nsub <- 200 # persons per agexSES group
  > 
  > cbind(age,ses,cogmean)
       age ses cogmean
  [1,]   0   0      80
  [2,]   0   1     100
  [3,]   1   0      50
  [4,]   1   1      70
  > 
  > # simulate data from 4 groups
  > data <- c()
  > for (i in 1:4) {
  +   cogsim <- rnorm(n = Nsub,mean = cogmean[i],cogsd)
  +   scores <- as.matrix(t(outer(lambda[[i]],cogsim))) + rnorm(Nsub*4,0,errsd)
  +   data <- rbind(data,scores)
  + }
  > data <- data.frame(data)
  > names(data) <- paste0("x",1:4)
  > 
  > fulldata <- cbind(data, age=rep(age,each=Nsub),ses=rep(ses,each=Nsub))
  > #
  > model<-"
  + ! regressions 
  + F=~1.0*x1
  + F=~l2*x2
  + F=~l3*x3
  + F=~l4*x4
  + ! residuals, variances and covariances
  + x1 ~~ VAR_x1*x1
  + x2 ~~ VAR_x2*x2
  + x3 ~~ VAR_x3*x3
  + x4 ~~ VAR_x4*x4
  + F ~~ 1.0*F
  + ! means
  + F~1
  + x1~0*1;
  + x2~0*1;
  + x3~0*1;
  + x4~0*1;
  + ";
  > result<-lavaan(model, data=data, fixed.x=FALSE, missing="FIML");
  > 
  > manifests<-c("x1","x2","x3","x4")
  > latents<-c("F")
  > model <- mxModel("Unnamed_Model", 
  +                  type="RAM",
  +                  manifestVars = manifests,
  +                  latentVars = latents,
  +                  mxPath(from="F",to=c("x1","x2","x3","x4"), free=c(FALSE,TRUE,TRUE,TRUE),
  +                         value=c(1.0,1.0,1.0,1.0) , arrows=1, label=c("F__x1","l2","l3","l4") ),
  +                  mxPath(from="one",to=c("F"), free=c(TRUE), value=c(1.0) , arrows=1, label=c("const__F") ),
  +                  mxPath(from="one",to=c("x2","x3","x4"), free=c(TRUE,TRUE,TRUE), value=c(1.0,1.0,1.0) , arrows=1, label=c("const__x2","const__x3","const__x4") ),
  +                  mxPath(from="x1",to=c("x1"), free=c(TRUE), value=c(1.0) , arrows=2, label=c("VAR_x1") ),
  +                  mxPath(from="x2",to=c("x2"), free=c(TRUE), value=c(1.0) , arrows=2, label=c("VAR_x2") ),
  +                  mxPath(from="x3",to=c("x3"), free=c(TRUE), value=c(1.0) , arrows=2, label=c("VAR_x3") ),
  +                  mxPath(from="x4",to=c("x4"), free=c(TRUE), value=c(1.0) , arrows=2, label=c("VAR_x4") ),
  +                  mxPath(from="F",to=c("F"), free=c(FALSE), value=c(1.0) , arrows=2, label=c("VAR_F") ),
  +                  mxPath(from="one",to=c("x1"), free=F, value=0, arrows=1),
  +                  mxData(data[1:50,], type = "raw")
  + );
  > 
  > result <- mxTryHard(model)
  
  Begin fit attempt 1 of at maximum 11 tries
  
   Lowest minimum so far:  625.429968267965
  
   OpenMx status code 6 not in list of acceptable status codes, 0
   OpenMx status code 6 not in list of acceptable status codes, 0
  
   Not all eigenvalues of Hessian are greater than 0: 319349520875.753, 451797.655294426, 258017.704254041, 84.8324174096648, 80.3118297540561, 33.7010745689736, 29.935388071682, 24.1710636832687, 0.0128893372935328, 0.00860442915486071, -778968229358.277
  
  Begin fit attempt 2 of at maximum 11 tries
  
   Fit attempt worse than current best:  625.488211569839 vs 625.429968267965
  
  Begin fit attempt 3 of at maximum 11 tries
  
   Lowest minimum so far:  -72813.7817136682
  Error in eigen(fit$output$calculatedHessian, symmetric = T, only.values = T) : 
    infinite or missing values in 'x'
  
   Eigenvalues of Hessian could not be calculated
  
  Begin fit attempt 4 of at maximum 11 tries
  
   Lowest minimum so far:  -2758643436524249
  Error in eigen(fit$output$calculatedHessian, symmetric = T, only.values = T) : 
    infinite or missing values in 'x'
  
   Eigenvalues of Hessian could not be calculated
  
  Begin fit attempt 5 of at maximum 11 tries
  
   Fit attempt worse than current best:  -2758643436524249 vs -2758643436524249
  Error in eigen(fit$output$calculatedHessian, symmetric = T, only.values = T) : 
    infinite or missing values in 'x'
  
   Eigenvalues of Hessian could not be calculated
  
  Begin fit attempt 6 of at maximum 11 tries
  
   Fit attempt worse than current best:  23330931257110864 vs -2758643436524249
  
  Begin fit attempt 7 of at maximum 11 tries
  
   Fit attempt worse than current best:  -961853400235293 vs -2758643436524249
  
  Begin fit attempt 8 of at maximum 11 tries
  
   Fit attempt generated errors
  
  Begin fit attempt 9 of at maximum 11 tries
  
   Fit attempt worse than current best:  -105055416203.449 vs -2758643436524249
  
  Begin fit attempt 10 of at maximum 11 tries
  
   Fit attempt worse than current best:  4950630354311978 vs -2758643436524249
  
  Begin fit attempt 11 of at maximum 11 tries
  
   Fit attempt generated errors
  
  Retry limit reached
  
  Start values from best fit:
  -6053045918.77947,-6053040433.06568,433.212491947628,400.041912077991,39.6462535061804,47.2606997680849,5.1025227013682,53.9244024947842,55.0811542870979,60.2000569315827,-14750818.1935198
  > summary(result)
  Summary of Unnamed_Model 
   
  free parameters:
          name matrix row col      Estimate    Std.Error A
  1         l2      A  x2   F -6.053046e+09           NA !
  2         l3      A  x3   F -6.053040e+09           NA !
  3         l4      A  x4   F  4.332125e+02 1.028193e-06  
  4     VAR_x1      S  x1  x1  4.000419e+02 6.637995e-08 !
  5     VAR_x2      S  x2  x2  3.964625e+01           NA !
  6     VAR_x3      S  x3  x3  4.726070e+01 3.186857e+02 !
  7     VAR_x4      S  x4  x4  5.102523e+00           NA !
  8  const__x2      M   1  x2  5.392440e+01           NA !
  9  const__x3      M   1  x3  5.508115e+01 1.939950e+12 !
  10 const__x4      M   1  x4  6.020006e+01 6.093615e+10 !
  11  const__F      M   1   F -1.475082e+07 1.649506e+06  
  
  Model Statistics: 
                 |  Parameters  |  Degrees of Freedom  |  Fit (-2lnL units)
         Model:             11                    189         -2.758643e+15
     Saturated:             14                    186                    NA
  Independence:              8                    192                    NA
  Number of observations/statistics: 50/200
  
  Information Criteria: 
        |  df Penalty  |  Parameters Penalty  |  Sample-Size Adjusted
  AIC:  -2.758643e+15          -2.758643e+15            -2.758643e+15
  BIC:  -2.758643e+15          -2.758643e+15            -2.758643e+15
  To get additional fit indices, see help(mxRefModels)
  timestamp: 2018-04-04 17:45:09 
  Wall clock time: 0.0902884 secs 
  optimizer:  CSOLNP 
  OpenMx version number: 2.9.6 
  Need help?  See help(mxSummary) 
  
  > 
  > subset <- data[1:50, ]
  > 
  > 
  > ctr <- semtree.control(verbose=TRUE)
  > ctr$exclude.heywood <- FALSE
  > # naive tree should find both effects, age & ses, with age having the stronger effect 
  > tree <- semtree(model = result, data=fulldata, control=ctr )
  Detected OpenMx model.
  MODEL IDS 1234
  COV IDS 56
  OpenMx model estimation selected!
  Growing level 0
  Testing Covariate: 5/6 (age)
  Within Covariates LLs: 279022809207279104
  Testing Covariate: 6/6 (ses)
  Within Covariates LLs: 278887028892897280
  Best LR 279022809207279104 : age at covariate column 5
  
  Growing level 1
  
   *** caught segfault ***
  address 20747261, cause 'memory not mapped'