[Robkalman-commits] r45 - in branches/robKalman_2012/pkg/robKalman: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Sep 18 12:04:04 CEST 2012


Author: ruckdeschel
Date: 2012-09-18 12:04:03 +0200 (Tue, 18 Sep 2012)
New Revision: 45

Modified:
   branches/robKalman_2012/pkg/robKalman/NAMESPACE
   branches/robKalman_2012/pkg/robKalman/R/AllGenerics.R
   branches/robKalman_2012/pkg/robKalman/R/Fmethods.R
   branches/robKalman_2012/pkg/robKalman/R/SSM-classes.R
   branches/robKalman_2012/pkg/robKalman/R/allClass.R
Log:
?\195?\132nderungen von Ende Juni committed (aber noch nicht gecheckt)

Modified: branches/robKalman_2012/pkg/robKalman/NAMESPACE
===================================================================
--- branches/robKalman_2012/pkg/robKalman/NAMESPACE	2012-06-25 18:05:20 UTC (rev 44)
+++ branches/robKalman_2012/pkg/robKalman/NAMESPACE	2012-09-18 10:04:03 UTC (rev 45)
@@ -19,8 +19,7 @@
 
 	   
 exportClasses("OptionalList","OptionalFunctionWithControl",
-              "FunctionWithControl","SSTransform", "SSVar", "SSTransform",
-              "SSExo", "SSstateEq", "SSinitEq", "SSobsEq", "SSM",
+              "FunctionWithControl", "SSstateEq", "SSinitEq", "SSobsEq", "SSM",
 			  "SStimes", "SSObs", "SSFilter", "SSrobFilter", "SSSmoother",
 			  "SSrobSmoother", "SSClassOrRobFilter", "SSClassOrRobSmoother",
 			  "SSClassOrRobSmootherOrFilter","SSDiagnostic","SSDiagnosticFilter",

Modified: branches/robKalman_2012/pkg/robKalman/R/AllGenerics.R
===================================================================
--- branches/robKalman_2012/pkg/robKalman/R/AllGenerics.R	2012-06-25 18:05:20 UTC (rev 44)
+++ branches/robKalman_2012/pkg/robKalman/R/AllGenerics.R	2012-09-18 10:04:03 UTC (rev 45)
@@ -8,11 +8,11 @@
 if(!isGeneric("name")) 
     setGeneric("name", function(object) standardGeneric("name"))
 
-if(!isGeneric("fct"))
-    setGeneric("fct", function(object) standardGeneric("fct"))
+#if(!isGeneric("fct"))
+#    setGeneric("fct", function(object) standardGeneric("fct"))
 
-if(!isGeneric("dots"))
-    setGeneric("dots", function(object) standardGeneric("dots"))
+if(!isGeneric("dots.propagated"))
+    setGeneric("dots.propagated", function(object) standardGeneric("dots.propagated"))
 
 if(!isGeneric("control"))
     setGeneric("control", function(object) standardGeneric("control"))

Modified: branches/robKalman_2012/pkg/robKalman/R/Fmethods.R
===================================================================
--- branches/robKalman_2012/pkg/robKalman/R/Fmethods.R	2012-06-25 18:05:20 UTC (rev 44)
+++ branches/robKalman_2012/pkg/robKalman/R/Fmethods.R	2012-09-18 10:04:03 UTC (rev 45)
@@ -67,24 +67,27 @@
 ##  R ... selection matrix array (cf. Durbin & Koopman, 2001, p.38)
     F <- object
 
-    ### some F checking possible and needed
-
-    funcF <- function (t, x0, v, u, control, dots)
-    {
-    ##  t ... time index
-    ##  x0 ... filter estimate x_{t-1|t-1}, vector
-    ##  v ... innovations v_t, vector!
-    ##  u ... exogenous variable u_{t-1}, vector!
-    ##  control ... control parameters, list
-    ##  dots ... additional parameters, list
-        call <- match.call()
-
-        ret0 <- F(t, x0, v, u, control, dots)
-
-        retF <- new("SSretValueF", x1 = ret0$x1, F = ret0$F,
-                    R = NULL, t=t, x0=x0, control=control,
-                    dots = dots, call = call, diagnostics = list())
-        return(retF)
-    }
-    return(new("FunctionWithControl",funcF))
+#    ### some F checking possible and needed
+#
+#
+#    funcF <- function (t, x0, v, u, control, dots)
+#    {
+#   ##  t ... time index
+#   ##  x0 ... filter estimate x_{t-1|t-1}, vector
+#   ##  v ... innovations v_t, vector!
+#   ##  u ... exogenous variable u_{t-1}, vector!
+#   ##  control ... control parameters, list
+#   ##  dots ... additional parameters, list
+#       call <- match.call()
+#
+#       ret0 <- F(t, x0, v, u, control, dots)
+#       if(is(ret0,"SSretValueF")) return(ret0)
+#
+#       retF <- new("SSretValueF", x1 = ret0$x1, F = ret0$F,
+#                   R = NULL, t=t, x0=x0, control=control,
+#                   dots = dots, call = call, diagnostics = list())
+#       return(retF)
+#   }
+    return(new("FunctionWithControl",F))
+#    return(new("FunctionWithControl",funcF))
 }

Modified: branches/robKalman_2012/pkg/robKalman/R/SSM-classes.R
===================================================================
--- branches/robKalman_2012/pkg/robKalman/R/SSM-classes.R	2012-06-25 18:05:20 UTC (rev 44)
+++ branches/robKalman_2012/pkg/robKalman/R/SSM-classes.R	2012-09-18 10:04:03 UTC (rev 45)
@@ -11,9 +11,9 @@
   Qret <- createQ(Q)
   Vret <- createV(V)
   
-  stateEq <- new("SSstateEq", F=Fret, Q=Qret, Exo = Exo.state.ret, distr = distr.state)
-  obsEq <- new("SSobsEq", Z=Zret, V=Vret, Exo = Exo.obs.ret, distr = distr.obs)
-  initEq <- new("SSinitEq", a0=a0, Sigma0=Sigma0, Exo = Exo.ini.ret, distr = distr.ini)
+  stateEq <- new("SSstateEq", Ffct=Fret, Qfct=Qret, Exofct = Exo.state.ret, distrfct = distr.state)
+  obsEq <- new("SSobsEq", Zfct=Zret, Vfct=Vret, Exofct = Exo.obs.ret, distrfct = distr.obs)
+  initEq <- new("SSinitEq", a0=a0, Sigma0=Sigma0, Exofct = Exo.ini.ret, distrfct = distr.ini)
 
   return(new("SSM",initEq  = initEq, statesEq = stateEq, obsEq = obsEq, p = p, q = q)
 }
@@ -34,3 +34,7 @@
 setMethod("a0", "SSM", function(object) initEq(object)@a0)
 setMethod("Sigma0", "SSinitEq", function(object) object at Sigma0)
 setMethod("Sigma0", "SSM", function(object) initEq(object)@Sigma0)
+
+setMethod("createF", "matrix", function(object, R, Exo){
+
+})
\ No newline at end of file

Modified: branches/robKalman_2012/pkg/robKalman/R/allClass.R
===================================================================
--- branches/robKalman_2012/pkg/robKalman/R/allClass.R	2012-06-25 18:05:20 UTC (rev 44)
+++ branches/robKalman_2012/pkg/robKalman/R/allClass.R	2012-09-18 10:04:03 UTC (rev 45)
@@ -29,7 +29,7 @@
 
 ## Class: FunctionWithControl
 setClass("FunctionWithControl", contains = "function")
-### in validity method check whether has args dots and control
+### in validity method check whether has args dots.propagated and control
 
 setClassUnion("OptionalFunctionWithControl",
                c("FunctionWithControl","NULL")
@@ -40,70 +40,38 @@
                )
 
 setClass("SSstateEq",
-          representation = representation(F = "FunctionWithControl",
-                                          Q = "FunctionWithControl",
-                                          Exo = "OptionalFunctionWithControl",
-                                          distr = "OptionalDistribution"),
-          prototype = prototype(F = new("SSTransform",
-                                         fct=function(...)1, control = NULL,
-                                         name="state transition"),
-                                Q = new("SSVar",
-                                         fct=function(...)1, control = NULL,
-                                         name="state variance"),
-                                Exo = new("SSExo",
-                                         fct=function(...)1, control = NULL,
-                                         name="state Exogenous variable")
-                                distr = Norm())
+          representation = representation(Ffct = "FunctionWithControl",
+                                          Qfct = "FunctionWithControl",
+                                          Exofct = "OptionalFunctionWithControl",
+                                          distrfct = "OptionalFunctionWithControl"))
  )
 setClass("SSobsEq",
-          representation = representation(Z = "FunctionWithControl",
-                                          V = "FunctionWithControl",
-                                          Exo = "OptionalFunctionWithControl",
-                                          distr = "OptionalDistribution"),
-          prototype = prototype(Z = new("SSTransform",
-                                         fct=function(...)1, control = NULL,
-                                         name="state transition"),
-                                V = new("SSVar",
-                                         fct=function(...)1, control = NULL,
-                                         name="state variance"),
-                                Exo = new("SSExo",
-                                         fct=function(...)1, control = NULL,
-                                         name="state Exogenous variable")
-                                distr = Norm())
+          representation = representation(Zfct = "FunctionWithControl",
+                                          Vfct = "FunctionWithControl",
+                                          Exofct = "OptionalFunctionWithControl",
+                                          distrfct = "OptionalFunctionWithControl"))
  )
 setClass("SSinitEq",
           representation = representation(a0 = "numeric",
                                           Sigma0 = "matrix",
-                                          Exo = "OptionalFunctionWithControl",
-                                          distr = "OptionalDistribution"),
-          prototype = prototype(a0 = 1,
-                                Sigma0 = matrix(1,1,1),
-                                Exo = new("SSExo",
-                                         fct=function(...)0, control = NULL,
-                                         name="state Exogenous variable"),
-                                distr = Norm())
+                                          Exofct = "OptionalFunctionWithControl",
+                                          distrfct = "OptionalDistribution"))
 
  )
 setClass("SSM",
           representation = representation(initEq  = "SSinitEq",
                                           statesEq = "SSstateEq",
                                           obsEq = "SSobsEq",
-                                          p = "numeric", q = "numeric"))
+                                          pdim = "numeric", qdim = "numeric"))
 )
 setClass("SStimes", representation = representation(times = "numeric",
                                    inX = "logical"))
 
 setClass("SSObs",
-          representation = representation(Y = "numeric",
-                                          origData = "ANY",
-                                          Exo = "SSVar",
-                                          mu = "function"),
+          representation = representation(Y = "numeric", ### soll Matrix bleiben?
+                                          origData = "ANY"),
           prototype = prototype(Y = 1,
-                                origData = 1,
-                                Exo = new("SSExo",
-                                         fct=function(...)0, control = NULL,
-                                         name="state Exogenous variable"),
-                                mu = function(...)0)
+                                origData = 1)
 
  )
 
@@ -117,7 +85,7 @@
 setClass("SSSmoother", representation = representation(filt = "SSfilter",
                                     smoothStep = "FunctionWithControl",
                                     smoothCov = "FunctionWithControl",
-                                    lagoneCov = = "FunctionWithControl"))
+                                    lagoneCov = "FunctionWithControl"))
                                     
 setClass("SSrobSmoother", representation = representation(classSmoother = "SSSmoother",
                                        robSmoother = "SSSmoother"))
@@ -138,15 +106,31 @@
 setClass("SSStateReconstr", contains = "matrix")
 
 
+
 setClass("SSPredOrFilt", representation = representation(values = "matrix",
-                      variances = "array", diagnostics = "SSDiagnostic"),
+                      variances = "array",
+                      dots.propagated = "list",
+                      control = "list",
+                      diagnostics = "SSDiagnostic"),
                       contains = "VIRTUAL")
-setClass("SSPredicted", contains = "SSPredFiltSmooth")
+
+### serve as class of return values for stepfunction initstep, predstep, @Bern: prepstep?,
+### correction step (in variant as only 1-dim in time)
+### and as slot classes (in variant as multi-step in time) for return value
+### of recFilter
+setClass("SSPrepared", representation = representation(dots.propagated = "list",
+                      control = "list",
+                      diagnostics = "SSDiagnostic"))
+setClass("SSPredicted", contains = "SSPredOrFilt")
 setClass("SSFiltered",  representation = representation(KalmanGain = "array",
                       CovObs = "array", DeltaY = "matrix"),
-                      contains = "SSPredFiltSmooth")
+                      contains = "SSPredOrFilt")
 setClass("SSSmoothed", representation = representation(lagoneCov = "array"),
                      contains = "SSPredOrFilt")
+
+setClassUnion("OptionalSSPrepared",
+               c("SSPrepared","NULL")
+               )
 setClassUnion("OptionalSSPredicted",
                c("SSPredicted","NULL")
                )
@@ -164,10 +148,12 @@
 
 setClass("SSOutput", representation = representation(pred.cl = "SSPredicted",
                                                      filt.cl = "SSFiltered",
+                                                     prep.cl = "OptionalSSPrepared"
                                                      smooth.cl = "OptionalSSSmoothed",
                                                      pred.rob = "OptionalSSPredicted",
                                                      filt.rob = "OptionalSSFiltered",
-                                                     smooth.rob = "OptionalSSSmoothed"))
+                                                     smooth.rob = "OptionalSSSmoothed",
+                                                     prep.rob = "OptionalSSPrepared"))
 
 setClass("SSrecResult", representation = representation(input="SSInput", output="SSOutput"))
 
@@ -182,25 +168,25 @@
 setClass("SSSimList", contains = "list")
 
 setClass("SSContSimulation", representation = representation(SimList = "SSSimList")
-          contains = "SSimulation")
+          contains = "SSSimulation")
 
 setClass("SSretValueF", representation = representation(x1 = "numeric",
-                           F = "matrix", R = "matrix", t = "numeric",
+                           Fmat = "matrix", Rmat = "matrix", t = "numeric",
                            x0 = "numeric", v = "numeric", u = "numeric",
-                           control = "OptionalList", dots = "OptionalList",
+                           control = "OptionalList", dots.propagated = "OptionalList",
                            call = "call", diagnostics = "SSDiagnostic"))
 
 setClass("SSretValueZ", representation = representation(y = "numeric",
-                           Z = "matrix", T = "matrix", t = "numeric",
+                           Zmat = "matrix", Tmat = "matrix", t = "numeric",
                            x1 = "numeric", eps = "numeric", w = "numeric",
-                           control = "OptionalList", dots = "OptionalList",
+                           control = "OptionalList", dots.propagated = "OptionalList",
                            call = "call", diagnostics = "SSDiagnostic"))
 setClass("SSretValueQ", representation = representation( Q = "matrix",
                     t = "numeric", x0 = "numeric", exQ = "ANY",
-                    control = "OptionalList", dots = "OptionalList",
+                    control = "OptionalList", dots.propagated = "OptionalList",
                     call = "call", diagnostics = "SSDiagnostic"))
 
 setClass("SSretValueV", representation = representation( V = "matrix",
                     t = "numeric", x1 = "numeric", exV = "ANY",
-                    control = "OptionalList", dots = "OptionalList",
+                    control = "OptionalList", dots.propagated = "OptionalList",
                     call = "call", diagnostics = "SSDiagnostic"))



More information about the Robkalman-commits mailing list