diff --git a/R/MxModel.R b/R/MxModel.R index ed6b5b84..d9c30afc 100644 --- a/R/MxModel.R +++ b/R/MxModel.R @@ -332,7 +332,10 @@ typeArgument <- function(model, type) { omxQuotes(names(imxModelTypes))), call. = FALSE) } typename <- imxModelTypes[[type]] - class(model) <- typename + #class(model) <- typename + if(typename=="MxRAMModel"){ + model <- as.MxRAMModel(model) + } model <- imxInitModel(model) } return(model) diff --git a/R/MxRAMModel.R b/R/MxRAMModel.R index 894ece57..2cb586eb 100755 --- a/R/MxRAMModel.R +++ b/R/MxRAMModel.R @@ -35,6 +35,58 @@ imxVariableTypes <- c("exogenous", "endogenous") # Define generic functions +setMethod( + "initialize", "MxRAMModel", + function(.Object, name = character()) { + .Object@name <- name + .Object@latentVars <- character() + .Object@manifestVars <- character() + .Object@matrices <- list() + .Object@algebras <- list() + .Object@constraints <- list() + .Object@data <- NULL + .Object@submodels <- list() + .Object@expectation <- NULL + .Object@fitfunction <- NULL + .Object@compute <- NULL + .Object@independent <- FALSE + .Object@options <- list() + .Object@output <- list() + .Object@runstate <- list() + .Object@.newobjects <- FALSE + .Object@.resetdata <- FALSE + .Object@.wasRun <- FALSE + .Object@.modifiedSinceRun <- FALSE + if (.hasSlot(.Object, '.version')) { + .Object@.version <- as.character(pkg_globals$myVersion) + } + .Object <- imxInitModel(.Object) + return(.Object) + } +) + +as.MxRAMModel <- function(x){ + retval <- new("MxRAMModel",x@name) + retval@latentVars <- x@latentVars + retval@manifestVars <- x@manifestVars + retval@matrices <- x@matrices + retval@algebras <- x@algebras + retval@constraints <- x@constraints + retval@data <- x@data + retval@submodels <- x@submodels + retval@expectation <- x@expectation + retval@fitfunction <- x@fitfunction + retval@compute <- x@compute + retval@independent <- x@independent + retval@options <- x@options + retval@runstate <- x@runstate + retval@.newobjects <- x@.newobjects + #retval@.resetData <- x@.resetData + retval@.wasRun <- x@.wasRun + retval@.modifiedSinceRun <- x@.modifiedSinceRun + return(retval) +} + setMethod("imxTypeName", "MxRAMModel", function(model) { "RAM" } )