Skip to content

Commit

Permalink
Allow decomposition model response check to tolerate missing values
Browse files Browse the repository at this point in the history
Resolves #388
  • Loading branch information
mitchelloharawild committed Nov 11, 2023
1 parent dfc4011 commit 261b695
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/model_decomposition.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ Please specify an appropriate model for these components",

model <- reduce(c(mdls, mdls_default), `+`)

if(!isTRUE(all.equal(response(model)[[".response"]], .data[[measured_vars(.data)]]))){
all_match <- function(x, y) {
non_missing <- complete.cases(x, y)
isTRUE(all.equal(x[non_missing], y[non_missing]))
}
if(!all_match(response(model)[[".response"]], .data[[measured_vars(.data)]])) {
abort(
"The models specified do not combine to give the correct response.
Please check that you have specified the decomposition models appropriately.")
Expand Down

0 comments on commit 261b695

Please sign in to comment.