Running ‘tree.R’ [14s/14s]
Running the tests in ‘tests/tree.R’ failed.
Complete output:
  > set.seed(789)
  > require("semtree")
  Loading required package: semtree
  Loading required package: OpenMx
  Loading required package: digest
  Loading required package: MASS
  Loading required package: Matrix
  Loading required package: Rcpp
  Loading required package: parallel
  To take full advantage of multiple cores, use:
    mxOption(NULL, 'Number of Threads', parallel::detectCores())
  
  Attaching package: 'OpenMx'
  
  The following objects are masked from 'package:Matrix':
  
      %&%, expm
  
  
  Attaching package: 'semtree'
  
  The following object is masked from 'package:utils':
  
      toLatex
  
  > data(lgcm)
  > 
  > lgcm$agegroup <- as.ordered(lgcm$agegroup)
  > lgcm$training <- as.factor(lgcm$training)
  > lgcm$noise <- as.numeric(lgcm$noise)
  > 
  > # LOAD IN OPENMX MODEL.
  > # A SIMPLE LINEAR GROWTH MODEL WITH 5 TIME POINTS FROM SIMULATED DATA
  > 
  > manifests <- names(lgcm)[1:5]
  > lgcModel <- mxModel("Linear Growth Curve Model Path Specification",
  +                             type="RAM",
  +                             manifestVars=manifests,
  +                             latentVars=c("intercept","slope"),
  +                             # residual variances
  +                             mxPath(
  +                               from=manifests,
  +                               arrows=2,
  +                               free=TRUE,
  +                               values = c(1, 1, 1, 1, 1),
  +                               labels=c("residual1","residual2","residual3","residual4","residual5")
  +                             ),
  +                             # latent variances and covariance
  +                             mxPath(
  +                               from=c("intercept","slope"),
  +                               connect="unique.pairs",
  +                               arrows=2,
  +                               free=TRUE,
  +                               values=c(1, 1, 1),
  +                               labels=c("vari", "cov", "vars")
  +                             ),
  +                             # intercept loadings
  +                             mxPath(
  +                               from="intercept",
  +                               to=manifests,
  +                               arrows=1,
  +                               free=FALSE,
  +                               values=c(1, 1, 1, 1, 1)
  +                             ),
  +                             # slope loadings
  +                             mxPath(
  +                               from="slope",
  +                               to=manifests,
  +                               arrows=1,
  +                               free=FALSE,
  +                               values=c(0, 1, 2, 3, 4)
  +                             ),
  +                             # manifest means
  +                             mxPath(
  +                               from="one",
  +                               to=manifests,
  +                               arrows=1,
  +                               free=FALSE,
  +                               values=c(0, 0, 0, 0, 0)
  +                             ),
  +                             # latent means
  +                             mxPath(
  +                               from="one",
  +                               to=c("intercept", "slope"),
  +                               arrows=1,
  +                               free=TRUE,
  +                               values=c(1, 1),
  +                               labels=c("meani", "means")
  +                             ),
  +                     mxData(lgcm,type="raw")
  +                     )
  > 
  > 
  > # TREE CONTROL OPTIONS.
  > # TO OBTAIN BASIC/DEFAULT SMETREE OPTIONS, SIMPLY TPYE THE FOLLOWING:
  > 
  > controlOptions <- semtree.control(method = "naive")
  > controlOptions$alpha <- 0.05
  > 
  > # RUN TREE.
  > 
  > tree <- semtree(model=lgcModel, data=lgcm, control = controlOptions)
  [x] Tree construction finished!
  > 
  > # RERUN TREE WITH MODEL CONSTRAINTS.
  > # MODEL CONSTRAINTS CAN BE ADDED BY IDENTIFYING THE PARAMETERS TO BE
  > # CONSTRAINED IN EVERY NODE. ONLY UNCONSTRAINED PARAMETERS ARE THEN
  > # TESTED AT EACH NODE FOR GROUP DIFFERENCES. IN THIS EXAMPLE THE MODEL 
  > # RESIDUALS ARE CONSTRAINED OVER THE NODES.
  > 
  > constraints <- semtree.constraints(global.invariance = names(omxGetParameters(lgcModel))[1:5])
  > 
  > treeConstrained <- semtree(model=lgcModel, data=lgcm, control = controlOptions,
  +                            constraints=constraints)
  Global Constraints:
  residual1 residual2 residual3 residual4 residual5
  Freely Estimated Parameters:
  vari cov vars meani means
  [x] Tree construction finished!
  > 
  > # SEE PLOT.
  > # THE PLOT FUNCTION WILL SHOW ALL FREE PARAMETERS AT EACH TERMINAL NODE.
  > # THIS CAN CREATE UNREADABLE FIGURES FOR MODELS WITH MANY FREE PARAMETERS.
  > 
  > plot(tree)
  > 
  > summary(tree)
  SEMtree Summary
  Template model:  
  Total Sample Size:  400 
  Number of nodes:  9 
  Number of leaf nodes:  5 
  Free Parameters:  10  ( residual1 residual2 residual3 residual4 residual5 vari cov vars meani means )
  > 
  > summary(treeConstrained)
  SEMtree Summary
  Template model:  
  Total Sample Size:  400 
  Number of nodes:  5 
  Number of leaf nodes:  3 
  Free Parameters:  5  ( vari cov vars meani means )
  > 
  > print(tree)
  SEMtree with numbered nodes
   |-[1] agegroup >= 0.5 [N=400 LR=1304.48, df=10]
   |   |-[2] noise >= 0.5 [N=200 LR=861.88, df=10]
   |   |   |-[3] TERMINAL [N=103]
   |   |   |-[4] training  in [ 0 ] [N=97 LR=19.06, df=10]
   |   |   |   |-[5] TERMINAL [N=50]
   |   |   |   |-[6] TERMINAL [N=47]
   |   |-[7] training  in [ 0 ] [N=200 LR=40.85, df=10]
   |   |   |-[8] TERMINAL [N=100]
   |   |   |-[9] TERMINAL [N=100]
  > 
  > parameters(tree)
                  3       5      6      8      9
  residual1   0.052   0.093  0.091  0.048  0.042
  residual2   0.061   0.036  0.032  0.069  0.049
  residual3   0.048   0.030  0.040  0.053  0.053
  residual4   0.038   0.071  0.073  0.039  0.063
  residual5   0.061   0.013  0.009  0.048  0.011
  vari        1.225   0.442  0.399  0.104  0.085
  cov        10.663   5.750  5.703  0.028 -0.044
  vars      100.488 100.360 95.487  0.674  1.629
  meani       5.051   5.073  5.099  1.941  2.005
  means       0.278   0.452  0.383 -0.494 -1.084
  > 
  > parameters(tree, leafs.only=FALSE)
                 1      2       3      4       5      6      7      8      9
  residual1  0.050  0.068   0.052  0.091   0.093  0.091  0.045  0.048  0.042
  residual2  0.059  0.049   0.061  0.035   0.036  0.032  0.059  0.069  0.049
  residual3  0.047  0.043   0.048  0.035   0.030  0.040  0.053  0.053  0.053
  residual4  0.052  0.055   0.038  0.072   0.071  0.073  0.051  0.039  0.063
  residual5  0.037  0.038   0.061  0.011   0.013  0.009  0.030  0.048  0.011
  vari      54.636  0.831   1.225  0.415   0.442  0.399  0.095  0.104  0.085
  cov       23.194  8.572  10.663  5.674   5.750  5.703 -0.017  0.028 -0.044
  vars      10.861 98.824 100.488 97.981 100.360 95.487  1.239  0.674  1.629
  meani      3.919  5.060   5.051  5.085   5.073  5.099  1.973  1.941  2.005
  means     -0.281  0.351   0.278  0.419   0.452  0.383 -0.789 -0.494 -1.084
  > 
  > treeSub <- subtree(tree, startNode=3)
  > 
  > plot(treeSub)
  Error in plot.window(...) : need finite 'xlim' values
  Calls: plot -> plot.default -> localWindow -> plot.window
  In addition: Warning messages:
  1: In min(x) : no non-missing arguments to min; returning Inf
  2: In max(x) : no non-missing arguments to max; returning -Inf
  3: In min(x) : no non-missing arguments to min; returning Inf
  4: In max(x) : no non-missing arguments to max; returning -Inf
  Execution halted