Skip to content

Commit

Permalink
validate that M is between M_m and M_d
Browse files Browse the repository at this point in the history
  • Loading branch information
bl-young committed Sep 11, 2024
1 parent b80c38b commit c9762f4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions R/ExternalImportFactors.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,14 @@ deriveMMatrix <- function(model) {
M <- model$M_d %*% diag(as.vector(dr)) + model$M_m %*% diag(as.vector(mr))
colnames(M) <- colnames(model$M_d)

# Validate that M is between M_m and M_d
a <- signif(model$M_m, 6)
b <- signif(M, 6)
c <- signif(model$M_d, 6)
z <- ((b > a) & (b > c)) | ((b < a) & (b < c))
if(sum(z) > 0) {
stop("Error in deriving M matrix")
}

return(M)
}

0 comments on commit c9762f4

Please sign in to comment.