-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extra error handling for when lavaan models fail evaluation of likeli…
…hood
- Loading branch information
1 parent
d9bce42
commit 78cf150
Showing
3 changed files
with
44 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,42 @@ | ||
#' SEM Forest Control Object | ||
#' | ||
#' | ||
#' A SEM Forest control object to tune parameters of the forest learning | ||
#' algorithm. | ||
#' | ||
#' | ||
#' | ||
#' | ||
#' @aliases semforest.control print.semforest.control | ||
#' @param num.trees Number of trees. | ||
#' @param sampling Sampling procedure. Can be subsample or bootstrap. | ||
#' @param control A SEM Tree control object. Will be generated by default. | ||
#' @param mtry Number of subsampled covariates at each node. | ||
#' @param remove_dead_trees Remove trees from forest that had runtime errors | ||
#' @author Andreas M. Brandmaier, John J. Prindle | ||
#' @references Brandmaier, A.M., Oertzen, T. v., McArdle, J.J., & Lindenberger, | ||
#' U. (2013). Structural equation model trees. \emph{Psychological Methods}, | ||
#' 18(1), 71-86. | ||
#' | ||
#' | ||
#' @export | ||
semforest.control <- function(num.trees=5, sampling="subsample", control=NA, mtry=2) | ||
{ | ||
options <- list() | ||
options$num.trees <- num.trees | ||
options$sampling <- sampling | ||
options$premtry <- 0 | ||
options$mtry <- mtry | ||
if (all(is.na(control))) { | ||
options$semtree.control <- semtree.control() | ||
options$semtree.control$method <- "fair" | ||
options$semtree.control$alpha <- 1 | ||
options$semtree.control$exclude.heywood <- FALSE | ||
} else { | ||
options$semtree.control <- control | ||
} | ||
class(options) <- "semforest.control" | ||
semforest.control <- | ||
function(num.trees = 5, | ||
sampling = "subsample", | ||
control = NA, | ||
mtry = 2, | ||
remove_dead_trees = TRUE) | ||
{ | ||
options <- list() | ||
options$num.trees <- num.trees | ||
options$sampling <- sampling | ||
options$premtry <- 0 | ||
options$mtry <- mtry | ||
if (all(is.na(control))) { | ||
options$semtree.control <- semtree.control() | ||
options$semtree.control$method <- "fair" | ||
options$semtree.control$alpha <- 1 | ||
options$semtree.control$exclude.heywood <- FALSE | ||
} else { | ||
options$semtree.control <- control | ||
} | ||
options$remove_dead_trees <- remove_dead_trees | ||
class(options) <- "semforest.control" | ||
return(options) | ||
} | ||
} |