Skip to content

Instantly share code, notes, and snippets.

@tbates
Created October 29, 2012 16:21
Show Gist options
  • Save tbates/3974601 to your computer and use it in GitHub Desktop.
Save tbates/3974601 to your computer and use it in GitHub Desktop.
setMethod("imxVerifyModel", "MxRAMModel",
function(model) {
if ((length(model$A) == 0) ||
(length(model$S) == 0) ||
(length(model$F) == 0)) {
msg <- paste("The RAM model", omxQuotes(model@name),
"does not contain any paths.",
" Are you just starting out? you need to add paths like",
" mxPath(from = 'x1', to = 'y1') to your RAM model.")
stop(msg, call. = FALSE)
}
objective <- model$objective
if (!is.null(objective) && is(objective, "MxRAMObjective")) {
if (!is.null(model@data) && model@data@type == "raw" &&
is.null(model$M)) {
msg <- paste("The RAM model", omxQuotes(model@name),
"contains raw data but has not specified any means paths.",
" Add something like mxPath(from = 'one', to = manifests) to your model."
)
stop(msg, call. = FALSE)
}
if (!is.null(model@data) && !single.na(model@data@means) &&
is.null(model$M)) {
msg <- paste("The RAM model", omxQuotes(model@name),
"contains an observed means vector",
"but has not specified any means paths.")
stop(msg, call. = FALSE)
}
}
if (length(model@submodels) > 0) {
return(all(sapply(model@submodels, imxVerifyModel)))
}
return(TRUE)
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment