Skip to content

Commit

Permalink
added error wrapper around vcov computation, which could fail, thus s…
Browse files Browse the repository at this point in the history
…alvaging the tree
  • Loading branch information
brandmaier committed Mar 6, 2024
1 parent 7cc97e2 commit 90d60bd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions R/scoreSplit.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,18 @@ ScoreSplit <- function(model = NULL, mydata = NULL, control = NULL,
n_obs <- nobs(model)

# get covariance matrix of the model parameters
vcov. <- solve(vcov_semtree(model) * n_obs)
vcov. <- strucchange::root.matrix(vcov.)
vcov. <- tryCatch({
solve(vcov_semtree(model) * n_obs)
}, error=function(e){
ui_fail("An error occured inverting the vcov model matrix when computing scores! Nobs=",n_obs," Aborting.")
NULL
})

if (is.null(vcov.)) {
return(NULL)
}

vcov. <- strucchange::root.matrix(vcov.)

############################################
# main loop with calls to sctest_semtree() #
Expand Down

0 comments on commit 90d60bd

Please sign in to comment.