Move all fitfunction args to expectation
[openmx:openmx.git] / R / MxFitFunctionBA81.R
1 #
2 #   Copyright 2012 The OpenMx Project
3 #
4 #   Licensed under the Apache License, Version 2.0 (the "License");
5 #   you may not use this file except in compliance with the License.
6 #   You may obtain a copy of the License at
7
8 #        http://www.apache.org/licenses/LICENSE-2.0
9
10 #   Unless required by applicable law or agreed to in writing, software
11 #   distributed under the License is distributed on an "AS IS" BASIS,
12 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #   See the License for the specific language governing permissions and
14 #   limitations under the License.
15
16
17 setClass(Class = "MxFitFunctionBA81",
18         representation = representation(
19           data = "MxCharOrNumber"),
20         contains = "MxBaseFitFunction")
21
22 setMethod("initialize", "MxFitFunctionBA81",
23         function(.Object) {
24                 .Object@name <- 'fitfunction'
25                 .Object@data <- as.integer(NA)
26                 return(.Object)
27         }
28 )
29
30 setMethod("genericFitFunConvert", signature("MxFitFunctionBA81"),
31         function(.Object, flatModel, model, labelsData, defVars, dependencies) {
32                 name <- .Object@name
33                 modelname <- imxReverseIdentifier(model, name)[[1]]
34                 expectName <- paste(modelname, "expectation", sep=".")
35                 if (expectName %in% names(flatModel@expectations)) {
36                         expectIndex <- imxLocateIndex(flatModel, expectName, name)
37                 } else {
38                         expectIndex <- as.integer(NA)
39                 }
40                 .Object@expectation <- expectIndex
41
42                 for (s in c("data")) {
43                         if (is.null(slot(.Object, s))) next
44                         slot(.Object, s) <-
45                           imxLocateIndex(flatModel, slot(.Object, s), name)
46                 }
47                 return(.Object)
48 })
49
50 setMethod("qualifyNames", signature("MxFitFunctionBA81"), 
51         function(.Object, modelname, namespace) {
52                 .Object@name <- imxIdentifier(modelname, .Object@name)
53                 return(.Object)
54 })
55
56 setMethod("genericFitRename", signature("MxFitFunctionBA81"),
57         function(.Object, oldname, newname) {
58           # not sure what goes here yet
59                 return(.Object)
60 })
61
62 mxFitFunctionBA81 <- function() {
63         return(new("MxFitFunctionBA81"))
64 }