R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid" Copyright (C) 2022 The R Foundation for Statistical Computing Platform: aarch64-apple-darwin20 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > set.seed(789) > require("semtree") Loading required package: semtree Loading required package: OpenMx OpenMx may run faster if it is compiled to take advantage of multiple cores. > data(lgcm) > > lgcm$agegroup <- ordered(lgcm$agegroup) > lgcm$training <- 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") + ) > > > fr <- semforest(lgcModel, lgcm,control = semforest.control(num.trees = 3)) ❯ Model was not run. Estimating parameters now before running the forest. Running Linear Growth Curve Model Path Specification with 10 parameters Beginning initial fit attempt Running Linear Growth Curve Model Path Specification with 10 parameters Lowest minimum so far: 3946.79931515404 Solution found Solution found! Final fit=3946.7993 (started at 12364.579) (1 attempt(s): 1 valid, 0 errors) Start values from best fit: 0.0517425500974165,0.057996464842973,0.0467583755756157,0.0520836958577161,0.0361130739855864,2.41004053260765,0.477157340565657,0.973042383133384,3.49639424449095,-0.465977315382569 ✖ Variable noise is numeric but has only few unique values. Consider recoding as ordered factor. ✔ Tree construction finished [took 2s]. ✖ Variable noise is numeric but has only few unique values. Consider recoding as ordered factor. ✔ Tree construction finished [took 1s]. ✖ Variable noise is numeric but has only few unique values. Consider recoding as ordered factor. ✔ Tree construction finished [took 2s]. ✔ Forest completed [took 5s] > > > vimp <- varimp(fr) > > print(vimp) Variable Importance agegroup training noise 6750.526689 34.849484 -4.840505 > print(vimp, na.omit=TRUE) Variable Importance agegroup training noise 6750.526689 34.849484 -4.840505 > > > proc.time() user system elapsed 7.403 0.104 7.515