Skip to content

luiarthur/dlmScala

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dlmScala

Univariate DLMs in Scala

To Do

  • discount factor

  • Superposition (define + operator for DLM objects)

  • filter method

  • forecast method

  • smooth method

  • backSample method (see p. 114 of WH)

  • Gibbs object (for FFBS)

  • Merge Model class with DLM class

object DLM {
  abstract class Generic(F:Any,G:Any,V:Any,W:Any) {
    type Obs
    type ObsVar
    type Prior
    // Param is the posterior updates like in Param.scala
    type Param 
    // This is the type of the state parameter (vector, matrix)
    type State

    def filter(y:List[Obs],init:Param,prior:Prior):List[Param]
    def forecast(y:List[Obs],filt:List[Param],nAhead:Int=1):List[(Obs,ObsVar)]
    def smooth(y:List[Obs],filt:List[Param]):List[(Obs,ObsVar)]
    def backSample(y:List[Obs],filt:List[Param]):List[State]
  }

}

Interesting Excursions for Univariate and Multivariate?

  • type unions?
type ~[A] = A=>Nothing
type V[U,T] = ~[ ~[U] with ~[T] ]
type ~~[A] = ~[~[A]]
type OR[T,U] = { type Lambda[X] = ~~[X] <:< (T V U) }

type OR[T,U] = {
  type ~[A] = A=>Nothing
  type V[U,T] = ~[ ~[U] with ~[T] ]
  type ~~[A] = ~[~[A]]
  type Lambda[X] = ~~[X] <:< (T V U)
}

def bla[T: (Int OR Double)#Lambda](x: T):Double = x match {
  case x:Int => x.toDouble
  case x:Double => x + 1
}

bla(10)
bla(11.1)

Or try this.

About

DLMs in Scala

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages